Skip to content

Commit

Permalink
Merge pull request #12 from evansmwendwa/feature/angular-cli
Browse files Browse the repository at this point in the history
Feature/angular cli
  • Loading branch information
evansmwendwa authored Mar 31, 2017
2 parents f18b647 + 40aa90e commit 81bb4ea
Show file tree
Hide file tree
Showing 33 changed files with 772 additions and 58 deletions.
59 changes: 59 additions & 0 deletions .angular-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "ci"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [

],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

[*.{json,config.js}]
indent_size = 2
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ jspm_packages
bower_components
aot/*
lib/*
src/daterangepicker/*.json
src/daterangepicker/*.ngfactory.ts
src/app/daterangepicker/*.json
src/app/daterangepicker/*.ngfactory.ts
yarn.lock

# Ignore Compass/SASS cache
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class AppComponent {
public selectedDate(value: any) {
this.daterange.start = value.start;
this.daterange.end = value.end;
this.daterange.label = value.label;
}
}
```
Expand Down
14 changes: 14 additions & 0 deletions e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { CiPage } from './app.po';

describe('ci App', () => {
let page: CiPage;

beforeEach(() => {
page = new CiPage();
});

it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!');
});
});
11 changes: 11 additions & 0 deletions e2e/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { browser, element, by } from 'protractor';

export class CiPage {
navigateTo() {
return browser.get('/');
}

getParagraphText() {
return element(by.css('app-root h1')).getText();
}
}
12 changes: 12 additions & 0 deletions e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types":[
"jasmine",
"node"
]
}
}
44 changes: 44 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
56 changes: 38 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "ng2-daterangepicker",
"version": "2.0.5",
"version": "2.0.6",
"description": "Angular 2 DaterangePicker component",
"scripts": {
"watch": "tsc -p src -w",
"build": "rm -rf lib && tsc -p .",
"ngc-build": "rm -rf lib && \"node_modules/.bin/ngc\" -p tsconfig.json"
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"ngc-build": "rm -rf lib && \"node_modules/.bin/ngc\" -p tsconfig-aot.json"
},
"repository": {
"type": "git",
Expand All @@ -32,19 +36,35 @@
"moment": "^2.16.0"
},
"devDependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/compiler-cli": "^2.4.9",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/platform-server": "^2.4.9",
"@angular/router": "~3.4.0",
"rxjs": "5.0.1",
"typescript": "^2.0.10",
"zone.js": "^0.7.4",
"@types/es6-shim": "^0.31.32"
"@angular/cli": "1.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/compiler-cli": "^4.0.1",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/platform-server": "^4.0.1",
"@angular/router": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"core-js": "^2.4.1",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"moment": "^2.18.1",
"protractor": "~5.1.0",
"rxjs": "^5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0",
"zone.js": "^0.8.4"
}
}
30 changes: 30 additions & 0 deletions protractor.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
3 changes: 3 additions & 0 deletions src/app/app.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.main-container{
max-width: 650px;
}
75 changes: 75 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<div class="container-fluid main-container">
<h1>ng2-daterangepicker (Demos)</h1>
<br /><br />

<form>
<h3>Using Datepicker with Events</h3>
<div style="max-height:250px; overflow-y:scroll;">
<pre>
{{ eventLog }}
</pre>
</div>
<div class="form-group">

<div class="input-group" daterangepicker (selected)="selectedDate($event, mainInput)"
(cancelDaterangepicker)="calendarEventsHandler($event)"
(applyDaterangepicker)="calendarEventsHandler($event)"
(hideDaterangepicker)="calendarEventsHandler($event)"
(showDaterangepicker)="calendarEventsHandler($event)"
>
<span class="form-control uneditable-input" name="daterange" >
{{ mainInput.start | date:'M/dd/y' }} - {{ mainInput.end| date:'M/dd/y' }}
</span>
<span class="input-group-btn">
<a type="button" class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></a>
</span>
</div>
</div>

<p>
Above example demonstrates how to tap to the events fired by the daterangepicker
</p>

<hr />

<h3>Single Datepicker</h3>

<div class="form-group">

<div class="input-group" daterangepicker [options]="singlePicker" (selected)="singleSelect($event)">
<span class="form-control uneditable-input" name="daterange" >
{{ singleDate | date:'M/dd/y' }}
</span>
<span class="input-group-btn">
<a type="button" class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></a>
</span>
</div>
</div>

<p>
Above example demonstrates how to tap to the events fired by the daterangepicker
</p>

<hr />

<h3>Different Presets</h3>

<div class="form-group" *ngFor="let dateInput of dateInputs">

<div class="input-group" daterangepicker [options]="{startDate:dateInput.start, endDate:dateInput.end }" (selected)="selectedDate($event, dateInput)" >
<span class="form-control uneditable-input" name="daterange" >
{{ dateInput.start | date:'M/dd/y' }} - {{ dateInput.end| date:'M/dd/y' }}
</span>
<span class="input-group-btn">
<a type="button" class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></a>
</span>
</div>

<br />

<pre>{{ dateInput | json }}</pre>
<hr />
</div>
</form>

</div>
32 changes: 32 additions & 0 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { TestBed, async } from '@angular/core/testing';

import { AppComponent } from './app.component';

describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));

it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));

it(`should have as title 'app works!'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
}));

it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
}));
});
Loading

0 comments on commit 81bb4ea

Please sign in to comment.