-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): ng-tables updated to common:
- style guide -release\build\ci flow Added tests runner BREAKING CHANGES: - selector changed from to ngTable to ng-table
- Loading branch information
Showing
29 changed files
with
631 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
/*eslint no-console: 0, no-sync: 0*/ | ||
|
||
// System.js bundler | ||
// simple and yet reusable system.js bundler | ||
// bundles, minifies and gzips | ||
|
||
const fs = require('fs'); | ||
const del = require('del'); | ||
const path = require('path'); | ||
const zlib = require('zlib'); | ||
const async = require('async'); | ||
const Builder = require('systemjs-builder'); | ||
|
||
const pkg = require('../package.json'); | ||
const name = pkg.name; | ||
const targetFolder = path.resolve('./bundles'); | ||
|
||
async.waterfall([ | ||
cleanBundlesFolder, | ||
getSystemJsBundleConfig, | ||
buildSystemJs({minify: false, sourceMaps: true, mangle: false}), | ||
getSystemJsBundleConfig, | ||
buildSystemJs({minify: true, sourceMaps: true, mangle: false}), | ||
gzipSystemJsBundle | ||
], err => { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
|
||
function getSystemJsBundleConfig(cb) { | ||
const config = { | ||
baseURL: '..', | ||
transpiler: 'typescript', | ||
typescriptOptions: { | ||
module: 'cjs' | ||
}, | ||
map: { | ||
typescript: path.resolve('node_modules/typescript/lib/typescript.js'), | ||
'@angular/core': path.resolve('node_modules/@angular/core/index.js'), | ||
'@angular/common': path.resolve('node_modules/@angular/common/index.js'), | ||
'@angular/compiler': path.resolve('node_modules/@angular/compiler/index.js'), | ||
'@angular/platform-browser': path.resolve('node_modules/@angular/platform-browser/index.js'), | ||
'@angular/platform-browser-dynamic': path.resolve('node_modules/@angular/platform-browser-dynamic/'), | ||
rxjs: path.resolve('node_modules/rxjs') | ||
}, | ||
paths: { | ||
'*': '*.js' | ||
} | ||
}; | ||
|
||
config.meta = ['@angular/common','@angular/compiler','@angular/core', | ||
'@angular/platform-browser','@angular/platform-browser-dynamic', 'rxjs'].reduce((memo, currentValue) => { | ||
memo[path.resolve(`node_modules/${currentValue}/*`)] = {build: false}; | ||
return memo; | ||
}, {}); | ||
config.meta.moment = {build: false}; | ||
return cb(null, config); | ||
} | ||
|
||
function cleanBundlesFolder(cb) { | ||
return del(targetFolder) | ||
.then(paths => { | ||
console.log('Deleted files and folders:\n', paths.join('\n')); | ||
cb(); | ||
}); | ||
} | ||
|
||
function buildSystemJs(options) { | ||
return (config, cb) => { | ||
const minPostFix = options && options.minify ? '.min' : ''; | ||
const fileName = `${name}${minPostFix}.js`; | ||
const dest = path.resolve(__dirname, targetFolder, fileName); | ||
const builder = new Builder(); | ||
|
||
console.log('Bundling system.js file:', fileName, options); | ||
builder.config(config); | ||
return builder | ||
.bundle([name, name].join('/'), dest, options) | ||
.then(() => cb()) | ||
.catch(cb); | ||
}; | ||
} | ||
|
||
function gzipSystemJsBundle(cb) { | ||
const files = fs | ||
.readdirSync(path.resolve(targetFolder)) | ||
.map(file => path.resolve(targetFolder, file)) | ||
.filter(file => fs.statSync(file).isFile()) | ||
.filter(file => path.extname(file) !== 'gz'); | ||
|
||
return async.eachSeries(files, (file, gzipcb) => { | ||
process.nextTick(() => { | ||
console.log('Gzipping ', file); | ||
const gzip = zlib.createGzip({level: 9}); | ||
const inp = fs.createReadStream(file); | ||
const out = fs.createWriteStream(`${file}.gz`); | ||
|
||
inp.on('end', () => gzipcb()); | ||
inp.on('error', err => gzipcb(err)); | ||
return inp.pipe(gzip).pipe(out); | ||
}); | ||
}, cb); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "./node_modules/eslint-config-valorsoft/.eslintrc.json", | ||
"env": { | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
.idea | ||
demo | ||
gulp-tasks | ||
logs | ||
|
||
tsd.d.ts | ||
# typings | ||
typings | ||
|
||
# testing | ||
karma.conf.js | ||
test.bundle.js | ||
coverage | ||
|
||
# demo build | ||
demo | ||
demo-build | ||
webpack.config.js | ||
|
||
#typescript sources | ||
*.ts | ||
*.js.map | ||
!*.d.ts | ||
/components/**/*.ts | ||
!/components/**/*.d.ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: node_js | ||
node_js: | ||
- "6" | ||
|
||
script: | ||
- npm run flow.install:typings | ||
- npm test | ||
|
||
after_success: | ||
- ./node_modules/.bin/codecov | ||
|
||
addons: | ||
# sauce labs tunel connector (read more https://docs.travis-ci.com/user/sauce-connect/ ) | ||
sauce_connect: true | ||
firefox: "42.0" | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
# required by node-gyp to build some packages | ||
packages: | ||
- g++-4.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import {NgTable} from './table/ng-table.component'; | ||
import {NgTableFiltering} from './table/ng-table-filtering.directive'; | ||
import {NgTablePaging} from './table/ng-table-paging.directive'; | ||
import {NgTableSorting} from './table/ng-table-sorting.directive'; | ||
export const NG_TABLE_DIRECTIVES = [NgTable, NgTableFiltering, NgTablePaging, NgTableSorting]; | ||
import {NgTableComponent} from './table/ng-table.component'; | ||
import {NgTableFilteringDirective} from './table/ng-table-filtering.directive'; | ||
import {NgTablePagingDirective} from './table/ng-table-paging.directive'; | ||
import {NgTableSortingDirective} from './table/ng-table-sorting.directive'; | ||
export const NG_TABLE_DIRECTIVES = [NgTableComponent, NgTableFilteringDirective, NgTablePagingDirective, NgTableSortingDirective]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
import {Directive, EventEmitter, ElementRef, Renderer} from '@angular/core'; | ||
import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass} from '@angular/common'; | ||
import {Directive, EventEmitter, ElementRef, Renderer, HostListener, Input, Output} from '@angular/core'; | ||
|
||
// import {setProperty} from 'angular2/ts/src/core/forms/directives/shared'; | ||
function setProperty(renderer:Renderer, elementRef:ElementRef, propName:string, propValue:any) { | ||
function setProperty(renderer:Renderer, elementRef:ElementRef, propName:string, propValue:any):void { | ||
renderer.setElementProperty(elementRef, propName, propValue); | ||
} | ||
|
||
@Directive({ | ||
selector: '[ngTableFiltering]', | ||
inputs: ['config: ngTableFiltering'], | ||
outputs: ['tableChanged'], | ||
host: { | ||
'(input)': 'onChangeFilter($event.target.value)' | ||
} | ||
}) | ||
export class NgTableFiltering { | ||
public config:any = { | ||
@Directive({selector: '[ngTableFiltering]'}) | ||
export class NgTableFilteringDirective { | ||
@Input() public ngTableFiltering:any = { | ||
filterString: '', | ||
columnName: 'name' | ||
}; | ||
public tableChanged:EventEmitter<any> = new EventEmitter(); | ||
|
||
constructor(private element:ElementRef, private renderer:Renderer) { | ||
// Set default value for filter | ||
setProperty(this.renderer, this.element, 'value', this.config.filterString); | ||
@Output() public tableChanged:EventEmitter<any> = new EventEmitter(); | ||
|
||
@Input() | ||
public get config():any { | ||
return this.ngTableFiltering; | ||
} | ||
|
||
public set config(value:any) { | ||
this.ngTableFiltering = value; | ||
} | ||
|
||
onChangeFilter(event:any) { | ||
this.config.filterString = event; | ||
this.tableChanged.emit({filtering: this.config}); | ||
private element:ElementRef; | ||
private renderer:Renderer; | ||
|
||
@HostListener('input', ['$event.target.value']) | ||
public onChangeFilter(event:any):void { | ||
this.ngTableFiltering.filterString = event; | ||
this.tableChanged.emit({filtering: this.ngTableFiltering}); | ||
} | ||
|
||
public constructor(element:ElementRef, renderer:Renderer) { | ||
this.element = element; | ||
this.renderer = renderer; | ||
// Set default value for filter | ||
setProperty(this.renderer, this.element, 'value', this.ngTableFiltering.filterString); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {it, expect, describe, inject, beforeEachProviders} from '@angular/core/testing'; | ||
import {ComponentFixture} from '@angular/compiler/testing'; | ||
import {NgTableComponent} from './ng-table.component'; | ||
|
||
describe('Directive: FileSelectDirective', () => { | ||
beforeEachProviders(() => [ | ||
NgTableComponent | ||
]); | ||
it('should be fine', inject([NgTableComponent], (fixture:ComponentFixture<NgTableComponent>) => { | ||
expect(fixture).not.toBeNull(); | ||
})); | ||
}); |
Oops, something went wrong.