Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.
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
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,54 @@ Before building make sure you have these installed:

- [node](http://nodejs.org)
- [gulp](http://gulpjs.com/)

#### Test Runner

KD uses [karma](http://karma-runner.github.io) for automatically running
tests. To launch karma, run

```bash
$ gulp karma
```

If you're editing test files, you'll also need to run the test watcher
to automatically build the test files:

```bash
$ gulp watch-test
```

There is also an html based test runner, which can be useful for
debugging tests. If you're running the playground server (started by
running `gulp`) the tests are available by going to

[http://localhost:8080/test/index.html](http://localhost:8080/test/index.html)

Alternately, you can view the tests directly in the browser:

```bash
$ open test/index.html
```

#### Running tests on Saucelabs

You can also run tests remotely on [SauceLabs](http://saucelabs.com)
browsers.

First, expose your saucelabs username and access key as environment
variables

```bash
$ export SAUCE_USERNAME=your-username SAUCE_ACCESS_KEY=your-access-key
```

Then fire up the SauceLabs test runner with

```bash
$ gulp sauce
```

The available browser definitions are configured in the
`customLaunchers` key in `karma.conf.js` and then
selected in the 'sauce' task in `gulpfile.coffe`.

79 changes: 48 additions & 31 deletions gulpfile.coffee
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
gulp = require 'gulp'
gulpif = require 'gulp-if'
gutil = require 'gulp-util'
browserify = require 'gulp-browserify'
browserify = require 'browserify'
coffeeify = require 'coffeeify'
rename = require 'gulp-rename'
uglify = require 'gulp-uglify'
stylus = require 'gulp-stylus'
livereload = require 'gulp-livereload'
concat = require 'gulp-concat'
minifyCSS = require 'gulp-minify-css'
karma = require 'gulp-karma'
fs = require 'fs'
http = require 'http'
coffee = require 'coffee-script'
argv = require('minimist') process.argv
source = require 'vinyl-source-stream'
gulpBuffer = require 'gulp-buffer'
ecstatic = require 'ecstatic'
readdir = require 'recursive-readdir'
{exec} = require 'child_process'

pistachioCompiler = require 'gulp-pistachio-compiler'

gulpBrowserify = (options, bundleOptions) ->
options.extensions or= ['.coffee']
bundleOptions or= {}
b = browserify options
b.transform coffeeify
b.bundle bundleOptions

STYLES_PATH = require './src/themes/styl.includes.coffee'
ENTRY_PATH = ['./playground/main.coffee']
COFFEE_PATH = ['./src/components/**/*.coffee','./src/core/**/*.coffee','./src/init.coffee']
LIBS_PATH = ['./libs/*.js']
TEST_PATH = ['./test/**/*.coffee']
TEST_PATH = ['./src/**/*.test.coffee']
LIBS = require './src/lib.includes.coffee'

buildDir = argv.outputDir ? 'build'
Expand All @@ -32,6 +42,7 @@ useLiveReload = !!argv.liveReload
useUglify = !!argv.uglify
useMinify = !!(argv.minify ? yes)


# Build Tasks

gulp.task 'styles', ->
Expand Down Expand Up @@ -68,52 +79,58 @@ gulp.task 'coffee', ->
# Throw here maybe?
console.error err if err?

stream = gulp.src entryPath, { read: false }
.pipe browserify
transform : ['coffeeify']
extensions : ['.coffee']
debug : yes
.pipe gulpif useUglify, uglify()
stream = gulpBrowserify
entries : entryPath
.pipe source entryPath
.pipe gulpBuffer()
.pipe pistachioCompiler()
.pipe concat "kd.js"
.pipe gulpif useUglify, uglify()
.pipe gulp.dest "playground/js"
.pipe rename "kd.#{version}js"
.pipe gulp.dest "#{buildDir}/js"

stream.pipe livereload() if useLiveReload


gulp.task 'test', ->

stream = gulp.src './test/test.coffee', { read: false }
.pipe browserify
transform : ['coffeeify']
extensions : ['.coffee']
debug : yes
.pipe concat "kd.test.js"
gulp.task 'coffee-test', ->
stream = gulpBrowserify
entries : './test/test.coffee'
.pipe source "kd.test.js"
.pipe gulp.dest 'test'

if useLiveReload
stream.pipe livereload()
gulp.src './test/index.html'
.pipe livereload()

gulp.task 'karma', ['coffee-test'], ->
gulp.src ['./test/kd.*']
.pipe karma
configFile : 'karma.conf.js'
action : 'watch'


gulp.task 'play', ->

stream = gulp.src ENTRY_PATH, { read: false }
.pipe browserify
transform : ['coffeeify']
extensions : ['.coffee']
debug : yes
.pipe concat "main.js"
stream = gulpBrowserify
entries : ENTRY_PATH
.pipe source "main.js"
.pipe gulp.dest "playground/js"

if useLiveReload
stream.pipe livereload()
gulp.src './playground/index.html'
.pipe livereload()

gulp.task 'sauce', ->
gulp.src ['./test/kd.*']
.pipe karma
browsers : [
'sl_firefox_windows'
'sl_chrome_windows'
'sl_ie_9'
'sl_ie_10'
]
configFile : 'karma.conf.js'
action : 'run'



gulp.task 'live', -> useLiveReload = yes

Expand All @@ -125,7 +142,7 @@ watchLogger = (color, watcher) ->


gulp.task 'watch-test', ->
watcher = gulp.watch TEST_PATH, ['test']
watcher = gulp.watch TEST_PATH, ['coffee-test']
watchLogger 'cyan', watcher


Expand Down Expand Up @@ -155,12 +172,12 @@ gulp.task 'watch-playground', ->

# Aggregate Tasks

gulp.task 'compile', ['styles', 'libs', 'coffee', 'test']
gulp.task 'compile', ['styles', 'libs', 'coffee']

defaultTasks = [
'live', 'compile', 'play',
'watch-styles', 'watch-coffee', 'watch-libs',
'watch-playground', 'watch-test'
'watch-styles', 'watch-coffee',
'watch-libs', 'watch-playground'
]

gulp.task 'default', defaultTasks , ->
Expand Down
103 changes: 103 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Karma configuration
// Generated on Wed Mar 19 2014 12:00:53 GMT-0700 (PDT)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],


// list of files / patterns to load in the browser
files: [
'test/kd.libs.js'
],

sauceLabs: {
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
startConnect: true,
testName: 'KD tests'
},

// define SauceLabs browsers
customLaunchers: {

sl_firefox_windows: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'Windows 7'
},

sl_chrome_windows: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Windows 7'
},

sl_ie_9: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '9'
},

sl_ie_10: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '10'
}
},

// list of files to exclude
exclude: [

],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {

},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome', 'Firefox'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"license": "MIT",
"devDependencies": {
"gulp": "^3.5.5",
"gulp-browserify": "^0.5.0",
"gulp-coffee": "^1.4.1",
"vinyl-source-stream": "^0.1.1",
"watchify": "^0.6.1",
Expand All @@ -36,12 +35,20 @@
"gulp-concat": "^2.1.7",
"recursive-readdir": "0.0.2",
"coffee-script": "^1.7.1",
"coffeeify": "0.6.0",
"coffeeify": "~0.6.0",
"minimist": "0.0.8",
"gulp-if": "0.0.5",
"gulp-pistachio-compiler": "0.0.3",
"chai": "~1.9.0",
"sinon": "~1.9.0",
"mocha": "~1.18.0"
"chai": "^1.9.0",
"sinon": "^1.9.0",
"mocha": "^1.18.0",
"karma": "^0.12.1",
"karma-mocha": "^0.1.3",
"karma-chrome-launcher": "^0.1.2",
"karma-firefox-launcher": "^0.1.3",
"gulp-karma": "0.0.4",
"gulp-buffer": "0.0.2",
"browserify": "^3.33.0",
"karma-sauce-launcher": "^0.2.3"
}
}