Skip to content

Commit

Permalink
Add Grunt & .gitignore
Browse files Browse the repository at this point in the history
* build
* makepot
* wp deploy - if we get listed :)
  • Loading branch information
tamarazuk committed Dec 18, 2014
1 parent 4f2b23d commit 5f07d0f
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.zip
.DS_Store

# Grunt.js SASS cache files
/.sass-cache

# NPM packages used by Grunt.js
/node_modules

# NPM debug log
npm-debug.log

# build directory
/build
60 changes: 60 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* jshint node:true */
module.exports = function( grunt ) {
'use strict';

// load all grunt tasks matching the `grunt-*` pattern
require( 'load-grunt-tasks' )( grunt );

// Show elapsed time
require( 'time-grunt' )( grunt );

var _ = require( 'underscore' );
var path = require( 'path' );

// Set plugin slug option
grunt.option( 'plugin-slug', path.basename( process.cwd() ) );

var gruntConfig = {};

// options
gruntConfig.options = {};

// Set folder templates
gruntConfig.dirs = {
css: 'assets/css',
js: 'assets/js',
images: 'assets/images',
fonts: 'assets/fonts',
build: 'build'
};

function loadConfig( filepath ) {
var object = {};
var key;

filepath = path.normalize( path.resolve( process.cwd(), filepath ) + '/' )

var files = grunt.file.glob.sync( '*', { cwd: filepath } );

files.forEach( function( option ) {
key = option.replace(/\.js$/,'');
object = _.extend( object, require( filepath + option )( grunt ) );
});

return object;
};

// load task configs
gruntConfig = _.extend( gruntConfig, loadConfig( './grunt/configs/' ) );

// Init Grunt
grunt.initConfig( gruntConfig );

// Register Tasks
grunt.registerTask( 'default', [
'makepot',
'clean:build_dir',
'copy:build',
'clean:build'
] );
};
54 changes: 54 additions & 0 deletions grunt/configs/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* jshint node:true */
module.exports = function( grunt ) {
'use strict';

var _ = require( 'underscore' );
var config = {};

// Delete source map from the CoffeeScript compilation
config.clean = {
dev: [ '<%= dirs.js %>/admin/*.min.js.map', '<%= dirs.js %>/frontend/*.min.js.map' ],
build_dir: [ '<%= dirs.build %>/**' ],
build: [
// Delete dev files and dirs
'<%= dirs.build %>/grunt',
'<%= dirs.build %>/node_modules',
'<%= dirs.build %>/wp-assets',
'<%= dirs.build %>/package.json',
'<%= dirs.build %>/Gruntfile.js',

// Delete map files
'<%= dirs.build %>/<%= dirs.js %>/admin/*.map',
'<%= dirs.build %>/<%= dirs.js %>/frontend/*.map',
'<%= dirs.build %>/<%= dirs.css %>/admin/*.map',
'<%= dirs.build %>/<%= dirs.css %>/frontend/*.map',

// Delete .coffee files
'<%= dirs.build %>/<%= dirs.js %>/admin/*.coffee',
'<%= dirs.build %>/<%= dirs.js %>/frontend/*.coffee',

// Delete unminified .js files
'<%= dirs.build %>/<%= dirs.js %>/admin/*.js',
'<%= dirs.build %>/<%= dirs.js %>/frontend/*.js',
'!<%= dirs.build %>/<%= dirs.js %>/admin/*.min.js',
'!<%= dirs.build %>/<%= dirs.js %>/frontend/*.min.js',

// Delete .scss files
'<%= dirs.build %>/<%= dirs.css %>/admin/*.scss',
'<%= dirs.build %>/<%= dirs.css %>/frontend/*.scss',

// Delete unminified .css files
'<%= dirs.build %>/<%= dirs.css %>/admin/*.css',
'<%= dirs.build %>/<%= dirs.css %>/frontend/*.css',
'!<%= dirs.build %>/<%= dirs.css %>/admin/*.min.css',
'!<%= dirs.build %>/<%= dirs.css %>/frontend/*.min.css',

// Delete misc files
'<%= dirs.build %>/modman',
'<%= dirs.build %>/**.DS_Store',
'<%= dirs.build %>/**.zip'
]
};

return config;
};
36 changes: 36 additions & 0 deletions grunt/configs/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* jshint node:true */
module.exports = function( grunt ) {
'use strict';

var util = grunt.option( 'util' );
var config = {};

function cleanSourceMaps( content, srcpath ) {

if ( '.min.js' == srcpath.match( '.min.js$' ) || '.min.css' == srcpath.match( '.min.css$' ) ) { // jshint ignore:line
content = content.replace( /^.*sourceMappingURL=.*$/mg, '' );
}

return content;
}

// copy files to /build dir
config.copy = {
build: {
files: [{
expand: true,
src: [ '**' ],
dest: 'build/'
}],
options: {
process: cleanSourceMaps,
noProcess: [
'**/*.{png,jpg,gif}',
'**/*.{eot,svg,ttf,woff}'
]
}
}
};

return config;
};
27 changes: 27 additions & 0 deletions grunt/configs/makepot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* jshint node:true */
module.exports = function( grunt ) {
'use strict';

var config = {};

// Makepot
config.makepot = {
makepot: {
options: {
cwd: '',
domainPath: 'i18n/languages',
potFilename: grunt.option( 'plugin-slug' ) + '.pot',
potHeaders: { 'report-msgid-bugs-to': 'https://github.com/skyverge/' + grunt.option( 'plugin-slug' ) + '/issues' },
processPot: function( pot ) {
delete pot.headers['x-generator'];
return pot;
}, // jshint ignore:line
type: 'wp-plugin',
updateTimestamp: false
}
}
};


return config;
};
20 changes: 20 additions & 0 deletions grunt/configs/wp_deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* jshint node:true */
module.exports = function( grunt ) {
'use strict';

var config = {};

// Makepot
config.wp_deploy = {
deploy: {
options: {
plugin_slug: grunt.option( 'plugin-slug' ),
svn_user: 'SkyVerge',
build_dir: 'build',
assets_dir: 'wp-assets'
}
}
};

return config;
};
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "woocommerce-google-trusted-stores-integration",
"version": "0.1.0-2",
"author": "Enollo Team",
"homepage": "http://enollo.com",
"repository": {
"type": "git",
"url": "https://github.com/enollo/woocommerce-google-trusted-stores-integration.git"
},
"bugs": {
"url": "https://github.com/enollo/woocommerce-google-trusted-stores-integration/issues"
},
"engines": {
"node": ">= 0.10.0"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-newer": "~0.7.0",
"grunt-notify": "~0.3.0",
"grunt-wp-deploy": "~1.0.3",
"grunt-wp-i18n": "~0.4.5",
"load-grunt-tasks": "~0.6.0",
"time-grunt": "~0.4.0",
"underscore": "~1.6.0",
"underscore.string": "~2.3.3"
}
}

0 comments on commit 5f07d0f

Please sign in to comment.