Skip to content

Commit

Permalink
refactor(Build): Rewriten all the way the library is built.
Browse files Browse the repository at this point in the history
Added semantic-release, travis-ci, webpack to build the bundle, removed some dependency.

Closes #58
  • Loading branch information
Bigous committed Jan 6, 2017
1 parent bbf4c2b commit fe75e8b
Show file tree
Hide file tree
Showing 19 changed files with 3,557 additions and 104 deletions.
42 changes: 30 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
# Node
#################
## Misc
#################
**/.DS_Store
nbproject
manifest.mf
build.xml
node_modules/*
npm-debug.log

# TypeScript
*.js
!config/*
!karma.conf.js
!webpack.config.js
*.map
*.d.ts
!make.js
!examples/**/*.js
coverage
*.metadata.json
bundles

# JetBrains
#################
## JetBrains
#################
.idea
.project
.settings
.idea/*
*.iml

# Windows
############
## Windows
############

# Windows image file caches
Thumbs.db

# Folder config file
Desktop.ini

# Mac
############
## Mac
############

# Mac crap
.DS_Store
**/.DS_Store

# AoT
aot
*.metadata.json
48 changes: 30 additions & 18 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
# Node
#################
## Misc
#################
nbproject
manifest.mf
build.xml
node_modules/*
npm-debug.log
tsconfig.json

# DO NOT IGNORE TYPESCRIPT FILES FOR NPM
# TypeScript
# *.js
# *.map
# *.ts
*.ts
!*.d.ts
tests
examples
.github
coverage
!*.metadata.json
!bundles/*.js

# Typings
typings/*

# JetBrains
#################
## JetBrains
#################
.idea
.project
.settings
.idea/*
*.iml

# Windows
############
## Windows
############

# Windows image file caches
Thumbs.db

# Folder config file
Desktop.ini

# Mac
############
## Mac
############

# Mac crap
.DS_Store
**/.DS_Store

# VSCode
.vscode

# Tools
tools
# Config
config
34 changes: 33 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
language: node_js

cache:
directories:
- $HOME/.npm
- $HOME/.yarn-cache
- node_modules

sudo: false

notifications:
email: false

node_js:
- '4.2.1'
- '6'

branches:
except:
- "/^v\\d+\\.\\d+\\.\\d+$/"

before_install:
- export CHROME_BIN=chromium-browser
- npm i -g yarn

before_script:
- npm prune

install:
- yarn

after_success:
- npm run semantic-release

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
32 changes: 32 additions & 0 deletions config/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* taken from angular2-webpack-starter
*/
var path = require('path');

// Helper functions
var ROOT = path.resolve(__dirname, '..');

function hasProcessFlag(flag) {
return process.argv.join('').indexOf(flag) > -1;
}

function isWebpackDevServer() {
return process.argv[1] && !! (/webpack-dev-server$/.exec(process.argv[1]));
}

function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [ROOT].concat(args));
}

function checkNodeImport(context, request, cb) {
if (!path.isAbsolute(request) && request.charAt(0) !== '.') {
cb(null, 'commonjs ' + request); return;
}
cb();
}

exports.hasProcessFlag = hasProcessFlag;
exports.isWebpackDevServer = isWebpackDevServer;
exports.root = root;
exports.checkNodeImport = checkNodeImport;
14 changes: 14 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { Ng2Highcharts } from './src/ng2-highcharts';
import { Ng2Highmaps } from './src/ng2-highmaps';
import { Ng2Highstocks } from './src/ng2-highstocks';

export * from './src/ng2-highcharts';
export * from './src/ng2-highstocks';
export * from './src/ng2-highmaps';

@NgModule({
declarations: [Ng2Highcharts, Ng2Highmaps, Ng2Highstocks],
exports: [Ng2Highcharts, Ng2Highmaps, Ng2Highstocks]
})
export class Ng2HighchartsModule { }
1 change: 1 addition & 0 deletions ng2-highcharts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './index';
71 changes: 45 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"name": "ng2-highcharts",
"version": "0.6.3",
"version": "0.0.0-development",
"scripts": {
"test": "echo No tests available yet...",
"postinstall": "npm prune",
"release": "standard-version",
"prepublish": "ngc",
"build": "ngc",
"add-commit-check": "node tools/commit-msg.js"
"commit": "git-cz",
"prepublish": "ngc && npm run build",
"build": "webpack && cp bundles/ng2-highcharts.umd.js bundles/index.js",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"repository": {
"type": "git",
"url": "https://github.com/Bigous/ng2-highcharts"
"url": "https://github.com/Bigous/ng2-highcharts.git"
},
"author": {
"name": "Richard Natal",
Expand All @@ -25,30 +24,50 @@
"bugs": {
"url": "https://github.com/Bigous/ng2-highcharts/issues"
},
"main": "index.js",
"main": "bundles/ng2-highcharts.umd.js",
"module": "index.js",
"typings": "./index.d.ts",
"typings": "index.d.ts",
"homepage": "https://githuc.com/Bigous/ng2-highcharts",
"dependencies": {
"@types/highcharts": "^4.2.1",
"highcharts": "^4.2.1"
"@types/highcharts": "^4.2.1"
},
"peerDependencies": {
"@angular/core": "^2.0.0"
},
"devDependencies": {
"@angular/common": "^2.0.1",
"@angular/compiler": "^2.0.1",
"@angular/compiler-cli": "^0.6.3",
"@angular/core": "^2.0.1",
"@angular/platform-browser": "^2.0.1",
"@angular/platform-server": "^2.0.1",
"angular-precommit": "^1.0.3",
"es6-shim": "^0.35.0",
"highcharts": "^4.2.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"standard-version": "^3.0.0",
"zone.js": "^0.6.21"
"@angular/common": "2.3.1",
"@angular/compiler": "2.3.1",
"@angular/compiler-cli": "2.3.1",
"@angular/core": "2.3.1",
"@angular/platform-browser": "2.3.1",
"@angular/platform-browser-dynamic": "2.3.1",
"@angular/platform-server": "2.3.1",
"@types/node": "6.0.52",
"awesome-typescript-loader": "3.0.0-beta.17",
"codelyzer": "2.0.0-beta.3",
"commitizen": "^2.9.2",
"core-js": "2.4.1",
"cz-conventional-changelog": "^1.2.0",
"istanbul-instrumenter-loader": "0.2.0",
"loader-utils": "0.2.16",
"reflect-metadata": "0.1.8",
"rxjs": "5.0.0-rc.4",
"semantic-release": "^6.3.2",
"source-map-loader": "0.1.5",
"ts-helpers": "1.1.2",
"tslint": "4.0.2",
"tslint-loader": "3.3.0",
"typescript": "2.0.10",
"webpack": "2.1.0-beta.27",
"zone.js": "0.7.2"
},
"engines": {
"node": ">=4.2.0"
"node": ">=6.0.0"
},
"license": "MIT"
"license": "MIT",
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
4 changes: 0 additions & 4 deletions src/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/modules/ng2-highcharts.module.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export abstract class Ng2HighchartsBase implements OnDestroy, DoCheck {
}

reflow() {
if (!this.pChart || !this.options) return;
if (!this.pChart || !this.options) { return; }

if (getComputedStyle(this.hostElement.nativeElement).transitionDuration) {
var duration = parseFloat(getComputedStyle(this.hostElement.nativeElement).transitionDuration);
var interval = setInterval(() => {
if (duration < 0) clearInterval(interval);
if (duration < 0) { clearInterval(interval); }
this.pChart.reflow();
duration -= 50;
}, duration);
Expand All @@ -35,11 +35,11 @@ export abstract class Ng2HighchartsBase implements OnDestroy, DoCheck {
}

ngDoCheck() {
if (this.currentWidth != this.hostElement.nativeElement.offsetWidth) {
if (this.currentWidth !== this.hostElement.nativeElement.offsetWidth) {
this.reflow();
this.currentWidth = this.hostElement.nativeElement.offsetWidth;
}
if (this.currentHeight != this.hostElement.nativeElement.offsetHeight) {
if (this.currentHeight !== this.hostElement.nativeElement.offsetHeight) {
this.reflow();
this.currentHeight = this.hostElement.nativeElement.offsetHeight;
}
Expand Down
2 changes: 1 addition & 1 deletion src/directives/ng2-highcharts.ts → src/ng2-highcharts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Ng2Highcharts extends Ng2HighchartsBase {
opt.chart = {};
}
opt.chart.renderTo = this.hostElement.nativeElement;
this.pChart = new Highcharts.Chart(opt);
this.pChart = new (<any>window).Highcharts.Chart(opt);
} else {
console.log('No valid options...');
console.dir(opt);
Expand Down
2 changes: 1 addition & 1 deletion src/directives/ng2-highmaps.ts → src/ng2-highmaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Ng2Highmaps extends Ng2HighchartsBase {
opt.chart = {};
}
opt.chart.renderTo = this.hostElement.nativeElement;
this.pChart = new (<any>Highcharts).Map(opt);
this.pChart = new (<any>window).Highcharts.Map(opt);
} else {
console.log('No valid options...');
console.dir(opt);
Expand Down
2 changes: 1 addition & 1 deletion src/directives/ng2-highstocks.ts → src/ng2-highstocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Ng2Highstocks extends Ng2HighchartsBase {
opt.chart = {};
}
opt.chart.renderTo = this.hostElement.nativeElement;
this.pChart = new (<any>Highcharts).StockChart(opt);
this.pChart = new (<any>window).Highcharts.StockChart(opt);
} else {
console.log('No valid options...');
console.dir(opt);
Expand Down
3 changes: 0 additions & 3 deletions tools/commit-msg.js

This file was deleted.

Loading

0 comments on commit fe75e8b

Please sign in to comment.