Skip to content

Commit

Permalink
Removing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lathonez committed Apr 28, 2016
1 parent 1fae39c commit c67beae
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 66 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### Features

* **Unit Test**: Use browserify within Karma (see below) ([5f096f7](https://github.com/lathonez/clicker/commit/5f096f7))
* **Unit Test**: Remove glob, gulp-load-plugins and gulp-util dependencies, refactor gulpfile to remove most typing dependencies ([???????](https://github.com/lathonez/clicker/commit/???????))

### Browserify in Karma

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ External dependencies are listed here to justify their inclusion and to allow fo

* browserify-istanbul: coverage transformer for karma-browserify
* codecov.io: sending unit test coverage reports to codecov.io
* gulp-load-plugins: helper to load other gulp plugins easily
* gulp-tslint: access tslint from gulp
* gulp-typescript: transpile typescript in gulp
* gulp-util: logging in gulp
* isparta: ES6 unit test coverage reporter
* jasmine-core: jasmine coverage reporter
* jasmine-spec-reporter: e2e coverage reporter for jasmine
Expand Down
3 changes: 3 additions & 0 deletions app/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// http://stackoverflow.com/questions/33332394/angular-2-typescript-cant-find-names
/// <reference path="../node_modules/angular2/typings/browser.d.ts" />

'use strict';

import { Type } from 'angular2/core';
Expand Down
2 changes: 1 addition & 1 deletion app/services/clickers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class Clickers {
}

public getClicker(id: string): Clicker {
return this.clickers.find((clicker: Clicker) => { return clicker.getId() === id; } );
return this.clickers['find']((clicker: Clicker) => { return clicker.getId() === id; } );
}

public getClickers(): Array<Clicker> {
Expand Down
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@
"browserify-istanbul": "^2.0.0",
"codecov.io": "0.1.6",
"del": "2.2.0",
"glob": "^7.0.3",
"gulp": "3.9.1",
"gulp-load-plugins": "1.2.0",
"gulp-tslint": "4.3.5",
"gulp-typescript": "^2.12.1",
"gulp-util": "^3.0.7",
"gulp-watch": "4.3.5",
"ionic-gulp-browserify-typescript": "^1.0.1",
"ionic-gulp-fonts-copy": "^1.0.0",
"ionic-gulp-html-copy": "^1.0.0",
"ionic-gulp-sass-build": "^1.0.0",
"ionic-gulp-scripts-copy": "^1.0.0",
"ionic-gulp-webpack": "^1.0.0",
"isparta": "^4.0.0",
"jasmine-core": "^2.4.1",
"jasmine-spec-reporter": "^2.4.0",
Expand All @@ -44,11 +40,10 @@
"tsify": "^0.15.2",
"tslint": "3.7.4",
"tslint-eslint-rules": "1.2.0",
"typescript": "1.8.10",
"typings": "0.7.12"
},
"name": "clicker",
"version": "1.1.1",
"version": "1.2.0",
"description": "clicker: An Ionic project",
"cordovaPlugins": [
"cordova-sqlite-storage",
Expand Down
60 changes: 26 additions & 34 deletions test/gulpfile.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { join } from 'path';
import * as del from 'del';
import * as gulp from 'gulp';
import * as karma from 'karma';
import * as loadPlugins from 'gulp-load-plugins';
import * as runSequence from 'run-sequence';
import * as typescript from 'typescript';
// http://stackoverflow.com/questions/33332394/angular-2-typescript-cant-find-names
/// <reference path="../node_modules/angular2/typings/browser.d.ts" />

import { join } from 'path';

const config: any = {
gulp: require('gulp'),
appDir: 'app',
testDir: 'test',
testDest: 'www/build/test',
typingsDir: 'typings',
};

let plugins: any = loadPlugins();

let ionicGulpfile: any = {
gulpfile: require(join(process.cwd(), 'gulpfile.js')),
logline: 'sourced Ionic\'s gulpfile @ ' + join(process.cwd(), 'gulpfile.js'),
const imports: any = {
gulp: require('gulp'),
runSequence: require('run-sequence'),
ionicGulpfile: require(join(process.cwd(), 'gulpfile.js')),
};

plugins.util.log(ionicGulpfile.logline);
const gulp: any = imports.gulp;
const runSequence: any = imports.runSequence;

// just a hook into ionic's build
gulp.task('build-app', (done: Function) => {
Expand All @@ -31,17 +29,15 @@ gulp.task('build-app', (done: Function) => {
});

// compile E2E typescript into individual files, project directoy structure is replicated under www/build/test
gulp.task('build-e2e', () => {

let tsProject: any = plugins.typescript.createProject('tsconfig.json', {
typescript: typescript,
});
gulp.task('build-e2e', ['clean-test'], () => {
let typescript: any = require('gulp-typescript');
let tsProject: any = typescript.createProject('tsconfig.json');
let src: Array<any> = [
join(config.typingsDir, '/browser.d.ts'),
join(config.appDir, '**/*e2e.ts'),
];
let result: any = gulp.src(src)
.pipe(plugins.typescript(tsProject));
.pipe(typescript(tsProject));

return result.js
.pipe(gulp.dest(config.testDest));
Expand All @@ -50,15 +46,19 @@ gulp.task('build-e2e', () => {
// delete everything used in our test cycle here
gulp.task('clean-test', () => {

let del: any = require('del');

// You can use multiple globbing patterns as you would with `gulp.src`
return del([config.testDest]).then((paths: Array<any>) => {
plugins.util.log('Deleted', paths && paths.join(', ') || '-');
console.log('Deleted', paths && paths.join(', ') || '-');
});
});

// run jasmine unit tests using karma with PhantomJS2 in single run mode
gulp.task('karma', (done: Function) => {

let karma: any = require('karma');

new (<any>karma).Server(
{
configFile: join(process.cwd(), config.testDir, 'karma.config.js'),
Expand All @@ -71,6 +71,8 @@ gulp.task('karma', (done: Function) => {
// run jasmine unit tests using karma with Chrome, Karma will be left open in Chrome for debug
gulp.task('karma-debug', (done: Function) => {

let karma: any = require('karma');

new (<any>karma).Server(
{
configFile: join(process.cwd(), config.testDir, 'karma.config.js'),
Expand All @@ -84,28 +86,18 @@ gulp.task('karma-debug', (done: Function) => {
// run tslint against all typescript
gulp.task('lint', () => {

let tslint: any = require('gulp-tslint');

return gulp.src(join(config.appDir, '**/*.ts'))
.pipe(plugins.tslint())
.pipe(plugins.tslint.report(plugins.tslintStylish, {
emitError: true,
sort: true,
bell: true,
}));
.pipe(tslint())
.pipe(tslint.report('verbose'));
});

// build unit tests, run unit tests, remap and report coverage
gulp.task('unit-test', (done: Function) => {
runSequence(
'clean-test',
['lint', 'html'],
'karma',
(<any>done)
);
});

// watch app directory and trigger unit test rebuild on change
gulp.task('watch-unit', ['build-unit'], () => {
plugins.watch(join(config.appDir, '**/*.ts'), () => {
gulp.start('build-unit');
});
});
1 change: 0 additions & 1 deletion test/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
// 'www/build/test/test.bundle.js': 'coverage',
'**/*.ts': ['browserify']
},

Expand Down
23 changes: 1 addition & 22 deletions typings.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
{
"ambientDependencies": {
"angular-protractor": "registry:dt/angular-protractor#1.5.0+20160317120654",
"bluebird": "registry:dt/bluebird#2.0.0+20160319051630",
"chalk": "registry:dt/chalk#0.4.0+20160317120654",
"del": "registry:dt/del#2.2.0+20160317120654",
"es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
"express": "registry:dt/express#4.0.0+20160317120654",
"express-serve-static-core": "registry:dt/express-serve-static-core#0.0.0+20160322035842",
"glob": "registry:dt/glob#5.0.10+20160317120654",
"gulp": "registry:dt/gulp#3.8.0+20160316155526",
"gulp-load-plugins": "registry:dt/gulp-load-plugins#0.0.0+20160316155526",
"gulp-typescript": "registry:dt/gulp-typescript#0.0.0+20160317120654",
"gulp-util": "registry:dt/gulp-util#3.0.0+20141016163602",
"jasmine": "registry:dt/jasmine#2.2.0+20160412134438",
"karma": "registry:dt/karma#0.13.9+20160316155526",
"log4js": "registry:dt/log4js#0.0.0+20160316155526",
"mime": "registry:dt/mime#0.0.0+20160316155526",
"minimatch": "registry:dt/minimatch#2.0.8+20160317120654",
"node": "registry:dt/node#4.0.0+20160412142033",
"orchestrator": "registry:dt/orchestrator#0.0.0+20160316155526",
"q": "registry:dt/q#0.0.0+20160323171452",
"run-sequence": "registry:dt/run-sequence#0.0.0+20160316155526",
"selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654",
"serve-static": "registry:dt/serve-static#1.7.1+20160104095738",
"through2": "registry:dt/through2#2.0.0+20160317120654",
"vinyl": "registry:dt/vinyl#1.1.0+20160316155526"
"selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654"
}
}

0 comments on commit c67beae

Please sign in to comment.