Skip to content

Commit bbb2bf4

Browse files
committed
ADD travis support, UPDATE build configuration
1 parent 067725f commit bbb2bf4

12 files changed

+327
-75
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
node_js:
3+
- "5"
4+
- "6"
5+
6+
before_install:
7+
- "npm i -g [email protected]"
8+
9+
install:
10+
- npm install
11+
- npm run setup
12+
13+
script:
14+
- npm test

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[![Build Status](https://travis-ci.org/PistachoSoft/NMM-frontend.png?branch=develop)](https://travis-ci.org/PistachoSoft/NMM-frontend)
2+
3+
# NMM-Frontend
4+
5+
React browser application for NMM.
6+
7+
## Building the application
8+
9+
Before anything, run
10+
11+
```
12+
npm install
13+
npm run setup
14+
npm start
15+
```
16+
17+
Once this is done, you can open [localhost:8080](http://localhost:8080) file to browse
18+
the application.
19+
20+
The test account is `test:test`.
21+
22+
## Scripts
23+
24+
- `npm run setup`: run this command to install typings.
25+
- `npm start`: run the default dev task.
26+
- `npm run build`: build TypeScript sources and UMD distributable.
27+
- `npm test`: run all tests.
28+
- `npm run test:unit`: run unit tests only.
29+
- `npm run test:coverage`: run coverage tests.
30+
31+
## Coverage
32+
33+
The coverage reports can be found under `test/results/coverage`.
34+
35+
## Sonar
36+
37+
You will need to add the plugin [SonarTsPlugin](https://github.com/Pablissimo/SonarTsPlugin).

package.json

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "nmm-frontend",
33
"version": "1.0.0",
44
"description": "NMM Frontend",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/PistachoSoft/NMM-frontend.git"
8+
},
59
"license": "UNLICENSED",
610
"dependencies": {
711
"es6-promise": "3.2.1",
@@ -45,16 +49,27 @@
4549
"webpack-dev-server": "1.15.1"
4650
},
4751
"scripts": {
48-
"start": "webpack-dev-server --inline --content-base . --history-api-fallback --host 0.0.0.0",
49-
"build:dev": "webpack -w",
50-
"build": "webpack",
51-
"clean": "rimraf tmp && rimraf dist && rimraf test/results",
52-
"test": "npm run clean && npm run test:unit && npm run test:cov",
52+
"setup": "typings install",
53+
"start": "npm run build:dev",
54+
"clean": "npm run clean:tmp && npm run clean:dist && npm run clean:test",
55+
"clean:dist": "rimraf dist",
56+
"clean:test": "rimraf test/results",
57+
"clean:tmp": "rimraf tmp",
58+
"clean:tmp:test": "rimraf test/results/tmp",
59+
"build": "npm run build:ts && npm run build:umd",
60+
"build:dev": "webpack-dev-server --inline --content-base . --history-api-fallback --host 0.0.0.0",
61+
"build:min": "webpack -p",
62+
"build:umd": "webpack",
63+
"build:w": "webpack -w",
64+
"build:ts": "tsc -p tsconfig.json",
65+
"lint": "npm run lint:app && npm run lint:test",
66+
"lint:app": "tslint --project tsconfig.json --type-check -c tslint.json",
67+
"lint:test": "tslint -c tslint.json test/**/*.ts",
68+
"test": "npm run clean && npm run test:unit && npm run test:coverage",
5369
"test:unit": "karma start test/config/karma.unit.conf.js",
54-
"test:cov": "karma start test/config/karma.cov.conf.js && npm run istanbul:remap",
55-
"test:func": "echo 'No functional test yet'",
70+
"test:coverage": "karma start test/config/karma.coverage.conf.js && npm run istanbul:remap && npm run clean:tmp:test",
5671
"istanbul:remap": "npm run istanbul:remap:html && npm run istanbul:remap:lcov",
57-
"istanbul:remap:html": "remap-istanbul -i test/results/coverage/karma-coverage/json/coverage.json -o test/results/coverage/istanbul-remap/html -t html -e test",
58-
"istanbul:remap:lcov": "remap-istanbul -i test/results/coverage/karma-coverage/json/coverage.json -o test/results/coverage/istanbul-remap/lcov/lcov.info -t lcovonly -e test"
72+
"istanbul:remap:html": "remap-istanbul -i test/results/tmp/json/coverage.json -o test/results/coverage/html -t html -e test",
73+
"istanbul:remap:lcov": "remap-istanbul -i test/results/tmp/json/coverage.json -o test/results/coverage/lcov/lcov.info -t lcovonly -e test"
5974
}
6075
}

sonar-project.properties

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Required metadata
2+
sonar.projectKey=PistachoSoft.NMM-frontend
3+
sonar.projectName=NMM-frontend
4+
5+
# Comma-separated paths to directories with sources (required)
6+
sonar.sources=app
7+
sonar.exclusions=**/test/**/*,**/*.d.ts,app/*.ts,**/I*.ts
8+
9+
# Language
10+
sonar.language=ts
11+
12+
# TypeScript
13+
sonar.ts.excludetypedefinitionfiles=true
14+
sonar.ts.tslintconfigpath=tslint.json
15+
sonar.ts.tslintpath=./node_modules/.bin/tslint
16+
17+
# Encoding of sources files
18+
sonar.sourceEncoding=UTF-8
19+
20+
# Coverage
21+
sonar.ts.lcov.reportpath=test/results/coverage/lcov/lcov.info

test/config/karma.conf.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
var webpackConf = require('../../webpack.config.test');
2-
3-
// Karma shared configuration
41
module.exports = function(config) {
2+
var webpackConfig = require('../../webpack.config.test');
3+
54
config.set({
65
basePath: '../../',
76
autoWatch: true,
@@ -12,27 +11,26 @@ module.exports = function(config) {
1211
'chai-sinon',
1312
'source-map-support'
1413
],
14+
files: [
15+
'node_modules/lodash/lodash.min.js',
16+
'node_modules/sinon/pkg/sinon.js',
17+
'node_modules/sinon-chai/lib/sinon-chai.js',
18+
'test/config/mocha-globals.js',
19+
'test/**/*.spec.ts'
20+
],
21+
exclude: [],
1522
plugins: [
1623
'karma-*'
1724
],
18-
reporters: ['spec'],
1925
preprocessors: {
2026
'test/specs/unit/**/*.spec.ts': ['webpack']
2127
},
22-
webpack: webpackConf,
23-
files: [
24-
'node_modules/lodash/lodash.min.js',
25-
'node_modules/jquery/dist/jquery.min.js',
26-
// 'test/config/mocha-globals.ts',
27-
'test/specs/unit/**/*.spec.ts'
28-
],
29-
exclude: [],
30-
logLevel: config.LOG_ERROR,
28+
webpack: webpackConfig,
29+
reporter: ['spec'],
3130
port: 9876,
3231
colors: true,
33-
browsers: [
34-
'PhantomJS'
35-
],
32+
logLevel: config.LOG_ERROR,
33+
browsers: ['PhantomJS'],
3634
singleRun: true
3735
});
3836
};

test/config/karma.cov.conf.js renamed to test/config/karma.coverage.conf.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
var baseConfig = require('./karma.conf');
2-
3-
// Karma coverage configuration
41
module.exports = function(config) {
5-
baseConfig(config);
2+
require('./karma.conf')(config);
63

74
config.set({
85
preprocessors: {
9-
'test/**/*.spec.ts': ['webpack', 'coverage']
6+
'test/specs/unit/**/*.spec.ts': ['webpack', 'coverage']
107
},
11-
128
reporters: ['dots', 'coverage'],
13-
149
coverageReporter: {
15-
dir: 'test/results/coverage/karma-coverage',
10+
dir: 'test/results/tmp',
1611
reporters: [
1712
{
18-
type: 'html',
19-
subdir: 'html'
20-
}, {
2113
type: 'json',
2214
subdir: 'json',
2315
file: 'coverage.json'

test/config/karma.unit.conf.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
var baseConfig = require('../config/karma.conf');
2-
3-
// Karma configuration
41
module.exports = function(config) {
5-
baseConfig(config);
2+
require('./karma.conf')(config);
63

74
config.set({
8-
reporters: ['spec'],
9-
5+
reports: ['dots', 'junit'],
106
junitReporter: {
117
outputFile: 'test/results/unit/test-results.xml'
128
}

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
},
1111
"exclude": [
1212
"node_modules",
13-
"dist"
13+
"dist",
14+
"app/main.tsx",
15+
"test"
1416
]
1517
}

0 commit comments

Comments
 (0)