Skip to content

Separate dev and prod files #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 53 additions & 41 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@

const SRC_DIR = './form-validator/src/';
const MODULE_DIR = './form-validator/';
const LANG_DIR = './form-validator/lang/';
//TODO: During next major version bump change to /dist. Leaving at ./form-validator for backwards
//compabilitiy
const DIST_DIR = './form-validator';
const MAIN_PLUGIN_FILE = 'form-validator/jquery.form-validator.min.js';
const JS_EXTENSION = '.js';
const DEV_EXTENSION = '.dev.js';
const SRC_DIR = './src';
const MAIN_DIR = '/main/';
const MODULE_DIR = '/modules/';
const LANG_DIR = '/lang/';
const CSS_FILE = 'theme-default.css';


var fs = require('fs'),
filesToBuild = {
uglify: {},
concat: {
main:{
src:[SRC_DIR+'core-validators.js'],
src: [SRC_DIR + MAIN_DIR+'core-validators.js'],
dest: MAIN_PLUGIN_FILE
}
},
devFiles: []
},
isJavascriptFile = function(fileName) {
return fileName.substr(-3) == JS_EXTENSION;
},
isDevFile = function(fileName) {
return fileName.substr(-1 * DEV_EXTENSION.length) == DEV_EXTENSION;
}
},
readFile = function (file) {
return fs.readFileSync(file, 'utf-8');
Expand All @@ -31,31 +27,40 @@ var fs = require('fs'),
};

module.exports = function (grunt) {

// Gather up all module and language files
[MODULE_DIR, LANG_DIR].forEach(function (path) {
fs.readdirSync(path).forEach(function (fileName) {
if (isDevFile(fileName)) {
var name = fileName.substr(0, fileName.length - DEV_EXTENSION.length),
fullPath = path + name + JS_EXTENSION;

filesToBuild.uglify[fullPath] = [fullPath];
filesToBuild.concat['file' + name] = {
src: [path + fileName],
dest: path + name + JS_EXTENSION
var srcPath = SRC_DIR + path;
var distPath = DIST_DIR + path;
if (path === MODULE_DIR) {
distPath = DIST_DIR + '/';
}

fs.readdirSync(srcPath).forEach(function (fileName) {
var fullPath = srcPath + fileName;
filesToBuild.uglify[distPath + fileName] = fullPath;
filesToBuild.concat[fullPath] = {
src: [fullPath],
dest: distPath + fileName
};
filesToBuild.devFiles.push(path + fileName);
}
});
});

// Gather up all source files that will added to minified core library
fs.readdirSync(SRC_DIR).forEach(function (fileName) {
var fullPath = SRC_DIR + fileName;
if (isJavascriptFile(fileName) && filesToBuild.concat.main.src.indexOf(fullPath) == -1) {
fs.readdirSync(SRC_DIR + MAIN_DIR).forEach(function (fileName) {
var fullPath = SRC_DIR + MAIN_DIR + fileName;
if (filesToBuild.concat.main.src.indexOf(fullPath) === -1) {
filesToBuild.concat.main.src.unshift(fullPath);
}
});

filesToBuild.cssFiles = [];
filesToBuild.cssFiles.push({
dest: DIST_DIR,
src: CSS_FILE,
cwd: SRC_DIR,
expand: true
});

// Add options for concat and uglify
filesToBuild.concat.options = {
banner: "<%= meta.banner %>"
Expand Down Expand Up @@ -87,11 +92,17 @@ module.exports = function (grunt) {
// Concat definitions.
concat: filesToBuild.concat,

cssmin: {
target: {
files: filesToBuild.cssFiles
}
},
// Lint definitions
jshint: {
files: [MODULE_DIR+"*"+DEV_EXTENSION, SRC_DIR+"*.js"],
files: [SRC_DIR + '/*'],
options: {
jshintrc: ".jshintrc"
jshintrc: ".jshintrc",
ignores: [SRC_DIR + '/' + CSS_FILE]
}
},

Expand All @@ -102,8 +113,8 @@ module.exports = function (grunt) {
// Better than calling grunt a million times
// (call 'grunt watch')
watch: {
files: [SRC_DIR+'/*', LANG_DIR+'/*', MODULE_DIR+'/*'],
tasks: ['build'],
files: [SRC_DIR + '/**'],
tasks: ['test'],
options : { nospawn : true }
},

Expand Down Expand Up @@ -143,7 +154,8 @@ module.exports = function (grunt) {

grunt.log.writeln('* Moving from version ' + currentVersion + ' to ' + newVersion);

replaceInFile('package.json', '"version": "' + currentVersion + '"', '"version": "' + newVersion + '"');
replaceInFile('package.json', '"version": "' + currentVersion + '"',
'"version": "' + newVersion + '"');
replaceInFile('formvalidator.jquery.json', '"version": "' + currentVersion + '"', '"version": "' + newVersion + '"');

// Set new version globally (can later on be used by concat/uglify)
Expand All @@ -158,10 +170,10 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-qunit');

grunt.registerTask("build", ["version", "concat", "uglify"]);
grunt.registerTask('test', ['concat', 'jshint', 'qunit']);
grunt.registerTask('test-uglify', ['concat', 'uglify', 'jshint', 'qunit']);
grunt.registerTask("default", ["test", "build"]);

grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask("build-production", ["version", "cssmin", "test", "uglify"]);
grunt.registerTask('test', ['concat', 'cssmin','jshint', 'qunit']);
grunt.registerTask("default", ["test", "watch"]);
//TODO: add clean task, don't minify CSS in dev build, ?remove volo (its {version} is busted anyway)
//Add unminified CSS to prod build
};
2 changes: 1 addition & 1 deletion form-validator/brazil.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/date.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* JQUERY-FORM-VALIDATOR
*
* @version 2.2.187
* @version 2.2.188
* @website http://formvalidator.net/
* @author Victor Jonsson, http://victorjonsson.se
* @license MIT
Expand Down
2 changes: 1 addition & 1 deletion form-validator/file.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/html5.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions form-validator/jquery.form-validator.min.js

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions form-validator/jsconf.js

This file was deleted.

2 changes: 1 addition & 1 deletion form-validator/lang/cz.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/de.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/fr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions form-validator/lang/it.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/pl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/pt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/ro.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/ru.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/sv.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/location.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/sanitize.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/security.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/sweden.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 1 addition & 108 deletions form-validator/theme-default.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion form-validator/theme-default.min.css

This file was deleted.

2 changes: 1 addition & 1 deletion form-validator/toggleDisabled.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/uk.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* JQUERY-FORM-VALIDATOR
*
* @version 2.2.187
* @version 2.2.188
* @website http://formvalidator.net/
* @author Victor Jonsson, http://victorjonsson.se
* @license MIT
Expand Down
2 changes: 1 addition & 1 deletion formvalidator.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"validation",
"validator"
],
"version": "2.2.187",
"version": "2.2.188",
"author": {
"name": "Victor Jonsson",
"url": "http://victorjonsson.se",
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery-form-validator",
"description": "With this feature rich jQuery plugin it becomes easy to validate user input while keeping your HTML markup clean from javascript code. Even though this plugin has a wide range of validation functions it's designed to require as little bandwidth as possible. This is achieved by grouping together validation functions in \"modules\", making it possible for the programmer to load only those functions that's needed to validate a particular form.",
"version": "2.2.187",
"version": "2.2.188",
"main": "./form-validator/jquery.form-validator.min.js",
"keywords": [
"form",
Expand Down Expand Up @@ -30,9 +30,10 @@
"grunt-cli": "~0.1.13",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-connect": "^0.11.2",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-cssmin": "~0.14.0",
"grunt-contrib-jshint": "~1.0.0",
"grunt-contrib-qunit": "^0.7.0",
"grunt-contrib-uglify": "^0.8.0",
"grunt-contrib-uglify": "~0.11.1",
"grunt-contrib-watch": "^0.6.1",
"jquery": "^2.1.4",
"numeral": "~1.5.3",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading