Skip to content

Commit

Permalink
Add fixes and improvements from seng-boilerplate
Browse files Browse the repository at this point in the history
Added fixes and improvements to unit testing from the
seng-boilerplate repo:
mediamonks/seng-boilerplate#28
mediamonks/seng-boilerplate#27
mediamonks/seng-boilerplate#23

Replaced some mediamonks/seng boilerplate names to
knockout-validator equivalents.
  • Loading branch information
flut1 committed Jul 13, 2016
1 parent 23f44ab commit ac2d8cb
Show file tree
Hide file tree
Showing 12 changed files with 226 additions and 137 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016 MediaMonks B.V.
Copyright (c) 2016 Floris Bernard

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand All @@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
OTHER DEALINGS IN THE SOFTWARE.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Travis](https://img.shields.io/travis/mediamonks/knockout-validator.svg?maxAge=2592000)](https://travis-ci.org/mediamonks/knockout-validator)
[![Code Climate](https://img.shields.io/codeclimate/github/mediamonks/knockout-validator.svg?maxAge=2592000)](https://codeclimate.com/github/mediamonks/knockout-validator)
[![Coveralls](https://img.shields.io/coveralls/mediamonks/knockout-validator.svg?maxAge=2592000)](https://coveralls.io/github/mediamonks/knockout-validator?branch=master)
[![Travis](https://img.shields.io/travis/flut1/knockout-validator.svg?maxAge=2592000)](https://travis-ci.org/flut1/knockout-validator)
[![Code Climate](https://img.shields.io/codeclimate/github/flut1/knockout-validator.svg?maxAge=2592000)](https://codeclimate.com/github/flut1/knockout-validator)
[![Coveralls](https://img.shields.io/coveralls/flut1/knockout-validator.svg?maxAge=2592000)](https://coveralls.io/github/flut1/knockout-validator?branch=master)
[![npm](https://img.shields.io/npm/v/knockout-validator.svg?maxAge=2592000)](https://www.npmjs.com/package/knockout-validator)
[![npm](https://img.shields.io/npm/dm/knockout-validator.svg?maxAge=2592000)](https://www.npmjs.com/package/knockout-validator)

Expand All @@ -24,7 +24,7 @@ the browser yourself, and grab one of the following files from the
`/dist/` folder:

```sh
git clone [email protected]:mediamonks/knockout-validator.git
git clone [email protected]:flut1/knockout-validator.git
cd knockout-validator
npm i
npm run build-dist
Expand All @@ -49,7 +49,7 @@ import KnockoutValidator from 'knockout-validator';

## Documentation

View the [generated documentation](https://rawgit.com/mediamonks/knockout-validator/master/doc/typedoc/index.html).
View the [generated documentation](https://rawgit.com/flut1/knockout-validator/master/doc/typedoc/index.html).


## Building
Expand All @@ -59,7 +59,7 @@ and [Node.js](http://nodejs.org/) installed.

Clone a copy of the repo:
```sh
git clone https://github.com/mediamonks/knockout-validator.git
git clone https://github.com/flut1/knockout-validator.git
```

Change to the knockout-validator directory:
Expand Down Expand Up @@ -104,6 +104,6 @@ View [AUTHORS.md](./AUTHORS.md)

## LICENSE

[MIT](./LICENSE) © MediaMonks
[MIT](./LICENSE) © Floris Bernard


98 changes: 26 additions & 72 deletions config/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,95 +1,49 @@
var path = require('path');
var webpackConfig = require('./webpack.config')();

webpackConfig.module.postLoaders = [
// instrument only testing sources with Istanbul
{
test: /\.ts$/,
include: path.resolve('src/'),
loader: 'istanbul-instrumenter'
}
];

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', 'chai'],

// list of files / patterns to load in the browser
frameworks: ['source-map-support', 'mocha', 'chai'],
files: [
'test/index.js'
'./test/index.ts'
],


// 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/index.js': ['webpack'],
'src/*.ts': ['webpack','coverage'] // only for webstorm, real coverage is injected as webpack-loader
},

webpack: {
module : webpackConfig.module,
resolve : webpackConfig.resolve
'./src/**/*.ts': [
'webpack',
'sourcemap',
'coverage'
],
'./test/**/*.ts': [
'webpack'
]
},


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

webpack: require('./webpack.config.test')(),
webpackServer: { noInfo: true },
reporters: ['progress', 'coverage', 'karma-remap-istanbul'],
coverageReporter: {
dir: 'coverage',
reporters: [
// reporters not supporting the `file` property
{ type: 'json', dir: 'coverage', subdir: '.' },
{ type: 'lcov', dir: 'coverage', subdir: '.' },

{ type: 'json', subdir: '.' },
{ type: 'text' }
]
},


// web server port
remapIstanbulReporter: {
src: 'coverage/coverage-final.json',
reports: {
lcovonly: 'coverage/lcov.info',
html: 'coverage/report'
},
timeoutNotCreated: 5000,
timeoutNoMoreFiles: 1000
},
logLevel: config.LOG_INFO,
browsers: ['PhantomJS'],
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: ['PhantomJS'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
};
17 changes: 17 additions & 0 deletions config/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"preserveConstEnums": true,
"noImplicitAny": false,
"removeComments": false,
"sourceMap": false,
"inlineSourceMap": true
},
"files": [
"typings/index.d.ts"
]
}
18 changes: 18 additions & 0 deletions config/tsconfig.webpack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"preserveConstEnums": true,
"noImplicitAny": false,
"removeComments": false,
"sourceMap": false,
"inlineSourceMap": false,
"outDir": "./"
},
"files": [
"typings/index.d.ts"
]
}
26 changes: 4 additions & 22 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,21 @@ module.exports = function()
resolve: {
extensions: ['', '.ts', '.js']
},
// entry is the "main" source file we want to include/import
entry: [
'./src/index.ts'
],
// externals let you tell webpack about external dependencies
// that shouldn't be resolved by webpack.
externals: [
{
// We're not only telling webpack that lodash should be an
// external dependency, but we're also specifying how
// lodash should be loaded in different scenarios

//lodash: {
// root: "_",
// commonjs: "lodash",
// commonjs2: "lodash",
// amd: "lodash"
//}
}
],
// output tells webpack where to put the bundle it creates
output: {
// in the case of a "plain global browser library", this
// will be used as the reference to our module that is
// hung off of the window object.
library: "KnockoutValidator"
},
module: {
loaders: [
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts'
loader: 'awesome-typescript-loader',
query: {
tsconfig: 'config/tsconfig.webpack.json'
}
}
]
},
Expand Down
37 changes: 37 additions & 0 deletions config/webpack.config.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*eslint-disable */
var path = require('path');

module.exports = function()
{
return {
devtool: 'inline-source-map',
resolve: {
extensions: ['', '.ts', '.js']
},
entry: './test/index.ts',
verbose: true,
module: {
loaders: [
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'awesome-typescript-loader',
query: {
tsconfig: 'config/tsconfig.test.json'
}
}
],
postLoaders: [
{
test: /\.ts$/,
loader: 'istanbul-instrumenter-loader',
exclude: [
/node_modules/,
/test/,
/Spec\.ts$/
]
}
]
}
};
};
31 changes: 15 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "knockout-validator",
"version": "1.0.0",
"description": "Boilerplate and example project for all Seng projects",
"description": "Painless form validation management using knockout.js",
"main": "index.js",
"typings": "index",
"scripts": {
Expand All @@ -14,15 +14,14 @@
"check-coverage": "istanbul check-coverage --statement 1 --branches 1 --functions 1 --lines 1",
"validate-webpack": "webpack-validator config/webpack.config.js",
"lint": "tslint -c tslint.json src/**/*.ts",
"clean": "rimraf dist lib index.js index.d.ts coverage",
"clean": "rimraf dist lib index.js index.d.ts coverage \"knockout-validator.@(zip|tar.gz)\"",
"compile": "npm-run-all typescript-npm typescript-system typescript-es6 webpack-dist",
"typescript-npm": "tsc -p ./ -d",
"typescript-system": "tsc -p ./ -m system --outFile ./dist/system/knockout-validator.js",
"typescript-system": "tsc -p ./ -m system --outFile ./dist/knockout-validator-system.js",
"typescript-es6": "tsc -p ./ -t es6 -m es6 --outDir ./dist/es6/",
"webpack-dist": "node script/webpack.js",
"doc": "npm-run-all -p typedoc yuidoc",
"doc": "npm-run-all -p typedoc",
"typedoc": "typedoc --out doc/typedoc/ src/",
"yuidoc": "yuidoc -o doc/yuidoc/ -t ./node_modules/yuidoc-mediamonks-theme -H ./node_modules/yuidoc-mediamonks-theme/helpers/helpers.js src/",
"generate": "npm-run-all clean compile test-unit doc",
"build": "npm-run-all clean compile",
"build-npm": "npm-run-all clean test typescript-npm",
Expand All @@ -32,50 +31,50 @@
"validate"
],
"author": "Floris Bernard <[email protected]> (flut1)",
"homepage": "https://www.mediamonks.com/",
"homepage": "https://github.com/flut1/knockout-validator/",
"license": "MIT",
"keywords": [
"seng",
"mediamonks",
"knockout",
"validator",
"forms",
"formvalidation",
"form validation",
"typescript",
"input"
],
"bugs": {
"url": "https://github.com/mediamonks/knockout-validator/issues"
"url": "https://github.com/flut1/knockout-validator/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/mediamonks/knockout-validator.git"
"url": "https://github.com/flut1/knockout-validator.git"
},
"devDependencies": {
"awesome-typescript-loader": "^2.0.1",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"coveralls": "^2.11.6",
"istanbul": "^0.4.3",
"istanbul-instrumenter-loader": "^0.1.3",
"istanbul-instrumenter-loader": "^0.2.0",
"karma": "^0.13.19",
"karma-chai": "^0.1.0",
"karma-coverage": "^0.5.3",
"karma-mocha": "^1.1.1",
"karma-phantomjs-launcher": "^1.0.0",
"karma-remap-istanbul": "^0.1.1",
"karma-source-map-support": "^1.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"marked": "^0.3.5",
"mocha": "^2.5.3",
"npm-run-all": "^2.2.0",
"phantomjs-prebuilt": "^2.1.3",
"pre-push": "^0.1.1",
"rimraf": "^2.5.2",
"ts-loader": "^0.8.0",
"tslint": "^3.3.0",
"typedoc": "^0.4.3",
"typescript": "^1.8.0",
"webpack": "^1.12.12",
"webpack-validator": "^2.1.3",
"yuidoc-mediamonks-theme": "^2.0.2",
"yuidocjs": "^0.10.0"
"webpack-validator": "^2.1.3"
},
"dependencies": {
"seng-disposable": "^1.0.1"
Expand Down
Loading

0 comments on commit ac2d8cb

Please sign in to comment.