Skip to content

Commit 8723ca7

Browse files
author
Leo Vo
committed
Merge branch 'testing'
2 parents 08fa37b + 38782d0 commit 8723ca7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+10241
-734
lines changed

.angular-cli.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@
55
},
66
"apps": [
77
{
8+
"name": "lib",
9+
"root": "src",
10+
"outDir": "dist/demo",
11+
"assets": [
12+
"assets",
13+
"favicon.ico"
14+
],
15+
"index": "index.html",
16+
"main": "main.ts",
17+
"polyfills": "polyfills.ts",
18+
"test": "test.ts",
19+
"tsconfig": "tsconfig.lib.json",
20+
"testTsconfig": "tsconfig.spec.json",
21+
"prefix": "ngx",
22+
"styles": [
23+
"../node_modules/font-awesome/scss/font-awesome.scss",
24+
"../node_modules/bootstrap/scss/bootstrap.scss",
25+
"styles.scss"
26+
],
27+
"scripts": [],
28+
"environmentSource": "environments/environment.ts",
29+
"environments": {
30+
"dev": "environments/environment.ts",
31+
"prod": "environments/environment.prod.ts"
32+
}
33+
},
34+
{
35+
"name": "demo",
836
"root": "src",
937
"outDir": "dist/demo",
1038
"assets": [
@@ -48,6 +76,13 @@
4876
}
4977
],
5078
"test": {
79+
"codeCoverage": {
80+
"exclude": [
81+
"src/polyfills.ts",
82+
"**/test.ts",
83+
"src/testing/*.*"
84+
]
85+
},
5186
"karma": {
5287
"config": "./karma.conf.js"
5388
}
@@ -56,4 +91,4 @@
5691
"styleExt": "scss",
5792
"component": {}
5893
}
59-
}
94+
}

.travis.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
1+
#
2+
# Configuration
3+
#
4+
15
sudo: required
26
dist: trusty
7+
8+
notifications:
9+
email: true
10+
311
addons:
412
apt:
513
sources:
614
- google-chrome
715
packages:
816
- google-chrome-stable
17+
918
language: node_js
1019
node_js:
1120
- 6
21+
22+
branches:
23+
only:
24+
- master
25+
26+
#
27+
# Build Lifecycle:
28+
#
29+
30+
install:
31+
- npm config set loglevel warn
32+
- npm install
33+
1234
before_script:
1335
- export DISPLAY=:99.0
1436
- sh -e /etc/init.d/xvfb start
15-
install:
16-
- npm install
37+
1738
script:
18-
- npm run lint
19-
- npm run test-ci
20-
- npm run e2e
39+
- npm run ci
40+
41+
after_success:
42+
# Send coverage info off to cloud ppl
43+
- ./node_modules/.bin/codecov

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Place your settings in this file to overwrite the default settings
2+
{
3+
"typescript.check.tscVersion": true,
4+
"files.autoSave": "off",
5+
"eslint.enable": false
6+
}

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@
66
# [0.0.5](https://www.npmjs.com/package/ngx-treeview) (2017-05-25)
77

88
### Enhancement:
9-
* Item always expands when matching search filter.
9+
* Item always expands when matching search filter.
10+
11+
# [0.0.6](https://www.npmjs.com/package/ngx-treeview) (2017-05-25)
12+
13+
### Enhancement:
14+
* Build bundles.
15+
* 100% code coverage.

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# ngx-treeview [![Build Status](https://travis-ci.org/leovo2708/ngx-treeview.svg?branch=master)](https://travis-ci.org/leovo2708/ngx-treeview) [![npm version](https://img.shields.io/npm/v/ngx-treeview.svg)](https://www.npmjs.com/package/ngx-treeview)
1+
[![Build Status](https://travis-ci.org/leovo2708/ngx-treeview.svg)](https://travis-ci.org/leovo2708/ngx-treeview)
2+
[![codecov](https://codecov.io/gh/leovo2708/ngx-treeview/badge.svg)](https://codecov.io/gh/leovo2708/ngx-treeview)
3+
[![npm version](https://img.shields.io/npm/v/ngx-treeview.svg)](https://www.npmjs.com/package/ngx-treeview)
4+
[![npm](https://img.shields.io/npm/l/ngx-treeview.svg)]()
5+
6+
# ngx-treeview
27

38
An Angular treeview component with checkbox
49

bs-config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"server": {
3+
"baseDir": "dist/demo",
4+
"routes": {
5+
"/node_modules": "node_modules"
6+
}
7+
}
8+
}

gulpfile.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const path = require('path');
2+
const gulp = require('gulp');
3+
const through = require('through2');
4+
const sass = require('node-sass');
5+
const fs = require('fs');
6+
7+
const paths = {
8+
src: 'src/lib',
9+
dist: 'dist/lib'
10+
}
11+
12+
gulp.task('inline', function () {
13+
const globs = [
14+
path.join(paths.dist, '**', '*.js'),
15+
];
16+
gulp.src(globs).pipe(through.obj((file, encode, callback) => {
17+
const filePath = file.path;
18+
19+
function resolveUrl(url) {
20+
return path.join(paths.src, url);
21+
}
22+
23+
function inlineTemplate(content) {
24+
return content.replace(/templateUrl:\s*'([^']+?\.html)'/g, (matchers, templateUrl) => {
25+
const templateFile = resolveUrl(templateUrl);
26+
const templateContent = fs.readFileSync(templateFile, encode);
27+
const shortenedTemplate = templateContent
28+
.replace(/([\n\r]\s*)+/gm, ' ');
29+
return `template: '${shortenedTemplate}'`;
30+
});
31+
}
32+
33+
function inlineStyles(content) {
34+
return content.replace(/styleUrls:\s*(\[[\s\S]*?\])/gm, (matchers, styleUrls) => {
35+
const urls = eval(styleUrls);
36+
return 'styles: ['
37+
+ urls.map(styleUrl => {
38+
const styleFile = resolveUrl(styleUrl);
39+
let styleContent = fs.readFileSync(styleFile, encode);
40+
if (/\.(scss)$/i.test(styleUrl)) {
41+
styleContent = compileSass(styleContent, styleFile);
42+
}
43+
const shortenedStyle = styleContent
44+
.replace(/([\n\r]\s*)+/gm, ' ');
45+
return `'${shortenedStyle}'`;
46+
}).join(',\n') + ']';
47+
});
48+
}
49+
50+
function compileSass(content, file) {
51+
const result = sass.renderSync({
52+
data: content,
53+
file: file,
54+
outputStyle: 'compact'
55+
});
56+
return result.css.toString();
57+
}
58+
59+
function removeModuleId(content) {
60+
return content.replace(/\s*moduleId:\s*module\.id\s*,?\s*/gm, '');
61+
}
62+
63+
function inline(content) {
64+
return [
65+
inlineTemplate,
66+
inlineStyles,
67+
removeModuleId
68+
].reduce((content, fn) => fn(content), content);
69+
}
70+
71+
if (/\.(component.js)$/i.test(filePath)) {
72+
let fileContent = file.contents.toString();
73+
fileContent = inline(fileContent);
74+
file.contents = new Buffer(fileContent);
75+
}
76+
77+
return callback(null, file);
78+
})).pipe(gulp.dest(paths.dist));
79+
});
80+
81+
gulp.task('default', ['inline']);

karma.conf.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,14 @@ module.exports = function (config) {
1515
client:{
1616
clearContext: false // leave Jasmine Spec Runner output visible in browser
1717
},
18-
files: [
19-
{ pattern: './src/test.ts', watched: false }
20-
],
21-
preprocessors: {
22-
'./src/test.ts': ['@angular/cli']
23-
},
24-
mime: {
25-
'text/x-typescript': ['ts','tsx']
26-
},
2718
coverageIstanbulReporter: {
2819
reports: [ 'html', 'lcovonly' ],
2920
fixWebpackSourcePaths: true
3021
},
3122
angularCli: {
3223
environment: 'dev'
3324
},
34-
reporters: config.angularCli && config.angularCli.codeCoverage
35-
? ['progress', 'coverage-istanbul']
36-
: ['progress', 'kjhtml'],
25+
reporters: ['progress', 'kjhtml'],
3726
port: 9876,
3827
colors: true,
3928
logLevel: config.LOG_INFO,

0 commit comments

Comments
 (0)