Skip to content

Commit

Permalink
feat(packages): updated to angular 2.0
Browse files Browse the repository at this point in the history
 - updated tests to latest angular changes
 - added test-setup
 - added eslint
 - changes for devdeps
  • Loading branch information
stephenlautier committed Sep 26, 2016
1 parent 17d9c6e commit a7c5663
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 87 deletions.
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rules": {
"no-trailing-spaces": "error",
"comma-dangle": "off",
"quotes": ["error", "double"],
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"]
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export class AppModule {
## Setup Machine for Development
Install/setup the following:
- NodeJS v5+
- NodeJS v6+
- Visual Studio Code or similar code editor
- TypeScript 1.8+
- TypeScript 2.0+
- Git + SourceTree, SmartGit or similar (optional)
- Ensure to install **global NPM modules** using the following:
Expand Down
9 changes: 5 additions & 4 deletions build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ const typings = "typings/index.d.ts";

module.exports = {
output: {
dist: `./dist`,
artifact: `./_artifact`,
dist: "./dist",
artifact: "./_artifact",
},
src: {
root: srcRoot,
typings: [typings, "./jspm_packages/**/*.d.ts"],
ts: `./${srcRoot}/**/*.ts`,
testTs: `./${srcRoot}/**/*.spec.ts`,
karmaConfig: `karma.conf.js`
karmaConfig: "karma.conf.js"
},
test: {
reporters: ["mocha"],
browsers: ["Chrome"]
browsers: ["Chrome"],
setup: "test/test-setup.ts"
},
doc: "./doc",
packageName: pkg.name
Expand Down
2 changes: 1 addition & 1 deletion build/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ gulp.task("compile:ts", () => {
.pipe(plumber())
//.pipe(changed(paths.output.dist, { extension: ".js" }))
.pipe(sourcemaps.init())
.pipe(tsc(tsProject));
.pipe(tsProject());

return merge([
tsResult.js
Expand Down
58 changes: 28 additions & 30 deletions karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,44 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
// we will call `__karma__.start()` later, once all the specs are loaded.
__karma__.loaded = function () { };

System.config({
SystemJS.config({
baseURL: "/base/",
defaultJSExtensions: true,
paths: {
"n:*": "node_modules/*"
"npm:*": "node_modules/*"
},
map: {
"@angular": "n:@angular",
"@ssv": "n:@ssv",
"rxjs": "n:rxjs",
"@angular": "npm:@angular",
"@ssv": "npm:@ssv",
"rxjs": "npm:rxjs",

// angular bundles
"@angular/core": "npm:@angular/core/bundles/core.umd.js",
"@angular/common": "npm:@angular/common/bundles/common.umd.js",
"@angular/compiler": "npm:@angular/compiler/bundles/compiler.umd.js",
"@angular/platform-browser": "npm:@angular/platform-browser/bundles/platform-browser.umd.js",
"@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js",
"@angular/http": "npm:@angular/http/bundles/http.umd.js",
"@angular/router": "npm:@angular/router/bundles/router.umd.js",
"@angular/forms": "npm:@angular/forms/bundles/forms.umd.js",

// angular testing umd bundles
"@angular/core/testing": "npm:@angular/core/bundles/core-testing.umd.js",
"@angular/common/testing": "npm:@angular/common/bundles/common-testing.umd.js",
"@angular/compiler/testing": "npm:@angular/compiler/bundles/compiler-testing.umd.js",
"@angular/platform-browser/testing": "npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js",
"@angular/platform-browser-dynamic/testing": "npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js",
"@angular/http/testing": "npm:@angular/http/bundles/http-testing.umd.js",
"@angular/router/testing": "npm:@angular/router/bundles/router-testing.umd.js",
"@angular/forms/testing": "npm:@angular/forms/bundles/forms-testing.umd.js",
},
packages: {
"@angular/common": { main: "index.js", defaultExtension: "js" },
"@angular/compiler": { main: "index.js", defaultExtension: "js" },
"@angular/core": { main: "index.js", defaultExtension: "js" },
"@angular/platform-browser": { main: "index.js", defaultExtension: "js" },
"@angular/platform-browser-dynamic": { main: "index.js", defaultExtension: "js" },

"@ssv/ng2-core": { main: "dist/amd/index.js", defaultExtension: "js" },
"@ssv/ng2-core": { mainpm: "dist/amd/index.js", defaultExtensionpm: "js" },
}
});

System.import("@angular/platform-browser/src/browser/browser_adapter")
.then(function (browser_adapter) {
browser_adapter.BrowserDomAdapter.makeCurrent();
})
.then(function () {
return Promise.all([
System.import("@angular/core/testing"),
System.import("@angular/platform-browser-dynamic/testing")
]).then(function (providers) {
var testing = providers[0];
var testingBrowser = providers[1];

testing.TestBed.initTestEnvironment(
testingBrowser.BrowserDynamicTestingModule,
testingBrowser.platformBrowserDynamicTesting()
);
});
})
SystemJS.import("test/test-setup")
.then(function () {
return Promise.all(resolveTestFiles());
})
Expand All @@ -65,6 +63,6 @@ function resolveTestFiles() {
return Object.keys(window.__karma__.files) // All files served by Karma.
.filter(onlySpecFiles)
.map(function (moduleName) {
return System.import(moduleName);
return SystemJS.import(moduleName);
});
}
14 changes: 10 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ module.exports = function (config) {
frameworks: ["jasmine"],

files: [
"node_modules/systemjs/dist/system.src.js",

"node_modules/es6-shim/es6-shim.js",

"node_modules/reflect-metadata/Reflect.js",
"node_modules/zone.js/dist/zone.js",
"node_modules/zone.js/dist/async-test.js",
"node_modules/zone.js/dist/fake-async-test.js",
"node_modules/zone.js/dist/long-stack-trace-zone.js",
"node_modules/zone.js/dist/proxy.js",
"node_modules/zone.js/dist/sync-test.js",
"node_modules/zone.js/dist/jasmine-patch.js",
"node_modules/systemjs/dist/system.src.js",
"node_modules/reflect-metadata/Reflect.js",
"node_modules/zone.js/dist/async-test.js",
"node_modules/zone.js/dist/fake-async-test.js",

{ pattern: "node_modules/reflect-metadata/**/*.js.map", included: false, watched: false, served: true },
{ pattern: "node_modules/systemjs/dist/system-polyfills.js", included: false, watched: false, served: true }, // PhantomJS2 (and possibly others) might require it
Expand All @@ -25,6 +29,7 @@ module.exports = function (config) {
{ pattern: "node_modules/@ssv/*/dist/**/*.js.map", included: false, watched: false, served: true },

{ pattern: conf.src.ts, included: false, watched: true }, // source files
{ pattern: conf.test.setup, included: false, watched: true },
"karma-test-shim.js"
],
exclude: [
Expand All @@ -34,6 +39,7 @@ module.exports = function (config) {
preprocessors: {
// "src/**/*.html": ["ng-html2js"],
[conf.src.ts]: ["typescript"],
[conf.test.setup]: ["typescript"],
},
typescriptPreprocessor: {
options: {
Expand Down
47 changes: 23 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,46 @@
"url": "https://github.com/sketch7/ssv-ng2-core.git"
},
"devDependencies": {
"@angular/common": "^2.0.0-rc.5",
"@angular/compiler": "^2.0.0-rc.5",
"@angular/core": "^2.0.0-rc.5",
"@angular/platform-browser": "^2.0.0-rc.5",
"@angular/platform-browser-dynamic": "^2.0.0-rc.5",
"del": "^2.2.1",
"@angular/common": "^2.0.1",
"@angular/compiler": "^2.0.1",
"@angular/core": "^2.0.1",
"@angular/platform-browser": "^2.0.1",
"@angular/platform-browser-dynamic": "^2.0.1",
"del": "^2.2.2",
"es6-module-loader": "^0.17.11",
"es6-shim": "^0.35.1",
"gulp": "^3.9.1",
"gulp-bump": "^2.1.0",
"gulp-bump": "^2.4.0",
"gulp-conventional-changelog": "^1.1.0",
"gulp-git": "^1.7.2",
"gulp-git": "^1.11.3",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.0.0-alpha",
"gulp-tslint": "^5.0.0",
"gulp-tslint": "^6.1.1",
"gulp-tslint-stylish": "^1.1.1",
"gulp-typescript": "^2.13.6",
"gulp-typescript": "^3.0.1",
"gulp-util": "^3.0.7",
"jasmine-core": "^2.4.1",
"karma": "^0.13.22",
"jasmine-core": "^2.5.2",
"karma": "^1.3.0",
"karma-appveyor-reporter": "^0.3.0",
"karma-chrome-launcher": "^1.0.1",
"karma-chrome-launcher": "^2.0.0",
"karma-jasmine": "^1.0.2",
"karma-mocha-reporter": "^2.0.4",
"karma-mocha-reporter": "^2.2.0",
"karma-typescript-preprocessor": "^0.2.1",
"merge2": "^1.0.2",
"reflect-metadata": "^0.1.3",
"require-dir": "^0.3.0",
"run-sequence": "^1.2.1",
"rxjs": "5.0.0-beta.6",
"systemjs": "^0.19.31",
"tslint": "^3.11.0",
"typescript": "^1.8.10",
"yargs": "^4.7.1",
"zone.js": "^0.6.12"
"run-sequence": "^1.2.2",
"rxjs": "5.0.0-beta.12",
"systemjs": "^0.19.39",
"tslint": "^3.15.1",
"typescript": "^2.0.3",
"yargs": "^5.0.0",
"zone.js": "^0.6.25"
},
"dependencies": {},
"peerDependencies": {
"@angular/core": "^2.0.0-rc.5",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"
"@angular/core": "^2.0.0",
"rxjs": "^5.0.0-beta.12"
},
"typings": "dist/typings/index.d.ts"
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./logging/logging";
export * from "./logging/index";
export * from "./module";
4 changes: 2 additions & 2 deletions src/logging/logging.ts → src/logging/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {LoggerFactory} from "./logger.factory";
import {LoggerService} from "./logger.service";
import { LoggerFactory } from "./logger.factory";
import { LoggerService } from "./logger.service";

export * from "./logger.service";
export * from "./logger.factory";
Expand Down
6 changes: 3 additions & 3 deletions src/logging/logger.factory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Injectable} from "@angular/core";
import { Injectable } from "@angular/core";

import {ILog} from "./logger.model";
import {Log, LoggerService} from "./logger.service";
import { ILog } from "./logger.model";
import { Log, LoggerService } from "./logger.service";

@Injectable()
export class LoggerFactory {
Expand Down
17 changes: 6 additions & 11 deletions src/logging/logger.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
import {inject, TestBed} from "@angular/core/testing";
import { TestBed } from "@angular/core/testing";

import {LoggerService} from "./logger.service";
import { LoggerService } from "./logger.service";

describe("LoggerService", () => {

let SUT: LoggerService;

beforeEach(() => {

TestBed.configureTestingModule({
providers: [LoggerService]
});
});

beforeEach(inject([
LoggerService
], (
logger: LoggerService
) => {
SUT = logger;
spyOn(console, "log");
}));
beforeEach(() => {
SUT = TestBed.get(LoggerService);
spyOn(console, "log");
});

it("should log successfully", () => {
let message = "Hello";
Expand Down
4 changes: 2 additions & 2 deletions src/logging/logger.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Injectable} from "@angular/core";
import { Injectable } from "@angular/core";

import {ILog} from "./logger.model";
import { ILog } from "./logger.model";

@Injectable()
export class LoggerService {
Expand Down
9 changes: 6 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {NgModule} from "@angular/core";
import {LOGGER_PROVIDERS} from "./logging/logging";
import { NgModule } from "@angular/core";

import { LOGGER_PROVIDERS } from "./logging/index";

@NgModule({
providers: [LOGGER_PROVIDERS]
providers: [
LOGGER_PROVIDERS
]
})
export class CoreModule {
}
4 changes: 4 additions & 0 deletions test/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { TestBed } from "@angular/core/testing";
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from "@angular/platform-browser-dynamic/testing";

TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());

0 comments on commit a7c5663

Please sign in to comment.