Skip to content

Commit

Permalink
Merge pull request #147 from lvarayut/master
Browse files Browse the repository at this point in the history
Refactoring the project based on airbnb/johnpapa style guides
  • Loading branch information
lvarayut committed Oct 30, 2015
2 parents 09aed2e + 70f3e02 commit a872d4c
Show file tree
Hide file tree
Showing 18 changed files with 2,115 additions and 2,230 deletions.
17 changes: 17 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"quotmark": "single",
"node": true,
"globals": {
"angular": false,
"document": false,
"jasmine": false,
"module": false,
"describe": false,
"beforeEach": false,
"afterEach": false,
"it": false,
"inject": false,
"expect": false,
"spyOn": false
}
}
185 changes: 92 additions & 93 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,99 @@
module.exports = function(grunt) {
require('time-grunt')(grunt);

// Variable
var ROOT_PATH = '.';

require('time-grunt')(grunt);

// Grunt Config
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
dist: {
files: [{
dot: true,
src: [
'dist'
]
}]
}
},
copy: {
main: {
files: [
// {expand: true, cwd: 'demo', src: ['script.js'], dest: 'dist'} // partials html file
// {expand: true, cwd: 'app', src: ['*.*'], dest: 'dist/'}
]
}
},
concat: {
basic_and_extras: {
files: {
'dist/angular-validation.js': ['src/module.js', 'src/provider.js', 'src/directive.js'],
'dist/angular-validation-rule.js': ['src/rule.js']
}
}
},
uglify: {
my_target: {
files: {
'dist/angular-validation.min.js': ['dist/angular-validation.js'],
'dist/angular-validation-rule.min.js': ['dist/angular-validation-rule.js']
}
}
},
jsbeautifier: {
files: ['*.js', 'src/**/*.js', 'test/unit/*.js'],
options: {}
},
jshint: {
all: ['*.js', 'src/**/*.js'],
options: {
quotmark: 'single'
}
},
browserSync: {
dev: {
bsFiles: {
src: ['index.html', 'demo/**', 'dist/angular-validation.js']
},
options: {
host: 'localhost',
ports: {
min: 8000,
max: 8100
},
server: {
baseDir: '.'
},
watchTask: true
}
}
},
watch: {
files: ['src/*.js'],
tasks: ['build'],
options: {
spawn: false,
interrupt: true
}
// Grunt Config
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
dist: {
files: [{
dot: true,
src: [
'dist'
]
}]
}
},
copy: {
main: {
files: [
// {expand: true, cwd: 'demo', src: ['script.js'], dest: 'dist'} // partials html file
// {expand: true, cwd: 'app', src: ['*.*'], dest: 'dist/'}
]
}
},
concat: {
basic_and_extras: {
files: {
'dist/angular-validation.js': ['src/module.js', 'src/provider.js', 'src/*.directive.js'],
'dist/angular-validation-rule.js': ['src/rule.js']
}
}
},
uglify: {
my_target: {
files: {
'dist/angular-validation.min.js': ['dist/angular-validation.js'],
'dist/angular-validation-rule.min.js': ['dist/angular-validation-rule.js']
}
}
},
jsbeautifier: {
files: ['*.js', 'src/**/*.js', 'test/unit/*.js', 'demo/*.js'],
options: {
js: {
indent_size: 2
}
}
},
jshint: {
all: ['*.js', 'src/**/*.js', 'test/unit/*.js', 'demo/*.js'],
options: {
jshintrc: true
}
},
browserSync: {
dev: {
bsFiles: {
src: ['index.html', 'demo/**', 'dist/angular-validation.js']
},
karma: {
// angular 1.2.x support to version angular-validation 1.2.x
// angular1_2: {
// configFile: 'config/karma.conf.angular.1.2.js'
// }
angular1_3: {
configFile: 'config/karma.conf.angular.1.3.js'
}
options: {
host: 'localhost',
ports: {
min: 8000,
max: 8100
},
server: {
baseDir: '.'
},
watchTask: true
}
});

require('load-grunt-tasks')(grunt);
}
},
watch: {
files: ['src/*.js'],
tasks: ['build'],
options: {
spawn: false,
interrupt: true
}
},
karma: {
// angular 1.2.x support to version angular-validation 1.2.x
// angular1_2: {
// configFile: 'config/karma.conf.angular.1.2.js'
// }
angular1_3: {
configFile: 'config/karma.conf.angular.1.3.js'
}
}
});

// Register Task
grunt.registerTask('dev', ['browserSync', 'watch']);
grunt.registerTask('build', ['clean', 'concat', 'uglify']);
grunt.registerTask('check', ['jshint', 'jsbeautifier', 'build']); // use this before commit
grunt.registerTask('test', ['karma']);
require('load-grunt-tasks')(grunt);

// Register Task
grunt.registerTask('dev', ['browserSync', 'watch']);
grunt.registerTask('check', ['jshint', 'jsbeautifier']); // use this before commit
grunt.registerTask('build', ['check', 'clean', 'concat', 'uglify']);
grunt.registerTask('test', ['build', 'karma']);
};
122 changes: 60 additions & 62 deletions config/karma.conf.angular.1.3.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,76 @@
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '../',
config.set({
// base path, that will be used to resolve files and exclude
basePath: '../',

frameworks: ['jasmine'],
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: [
'test/lib/angular.1.3.18.js',
'test/lib/angular-mocks.1.3.18.js',
'dist/angular-validation.js',
'dist/angular-validation-rule.js',
'test/unit/*.js'
],
// list of files / patterns to load in the browser
files: [
'test/lib/angular.1.3.18.js',
'test/lib/angular-mocks.1.3.18.js',
'dist/angular-validation.js',
'dist/angular-validation-rule.js',
'test/unit/*.js'
],

// list of files to exclude
exclude: [
// list of files to exclude
exclude: [],

],
preprocessors: {
'test/*.js': []
},

preprocessors: {
'test/*.js': []
},
// use dots reporter, as travis terminal does not support escaping sequences
// possible values: 'dots', 'progress'
// CLI --reporters progress
reporters: ['progress'],

// use dots reporter, as travis terminal does not support escaping sequences
// possible values: 'dots', 'progress'
// CLI --reporters progress
reporters: ['progress'],
// web server port
// CLI --port 9876
port: 9876,

// web server port
// CLI --port 9876
port: 9876,
// enable / disable colors in the output (reporters and logs)
// CLI --colors --no-colors
colors: true,

// enable / disable colors in the output (reporters and logs)
// CLI --colors --no-colors
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
// CLI --log-level debug
logLevel: config.LOG_INFO,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
// CLI --log-level debug
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
// CLI --auto-watch --no-auto-watch
autoWatch: false,

// enable / disable watching file and executing tests whenever any file changes
// CLI --auto-watch --no-auto-watch
autoWatch: false,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
// CLI --browsers Chrome,Firefox,Safari
browsers: ['PhantomJS'],

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
// CLI --browsers Chrome,Firefox,Safari
browsers: ['PhantomJS'],
// If browser does not capture in given timeout [ms], kill it
// CLI --capture-timeout 5000
captureTimeout: 20000,

// If browser does not capture in given timeout [ms], kill it
// CLI --capture-timeout 5000
captureTimeout: 20000,
// Auto run tests on start (when browsers are captured) and exit
// CLI --single-run --no-single-run
singleRun: true,

// Auto run tests on start (when browsers are captured) and exit
// CLI --single-run --no-single-run
singleRun: true,
// report which specs are slower than 500ms
// CLI --report-slower-than 500
reportSlowerThan: 500,

// report which specs are slower than 500ms
// CLI --report-slower-than 500
reportSlowerThan: 500,

plugins: [
'karma-jasmine',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-phantomjs-launcher'
]
});
plugins: [
'karma-jasmine',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-phantomjs-launcher'
]
});
};
Loading

0 comments on commit a872d4c

Please sign in to comment.