Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GregTurner committed Oct 27, 2016
0 parents commit f3af409
Show file tree
Hide file tree
Showing 63 changed files with 1,391 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true

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

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
build/
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# webpack-test



# License
[Apache-2.0](/LICENSE)
67 changes: 67 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// @AngularClass
var path = require('path');

module.exports = function(config) {
var testWebpackConfig = require('./webpack.test.config.js');
config.set({

// base path that will be used to resolve all patterns (e.g. files, exclude)
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],

// list of files to exclude
exclude: [ ],

// list of files / patterns to load in the browser
// we are building the test environment in ./spec-bundle.js
files: [ { pattern: 'spec-bundle.js', watched: false } ],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: { 'spec-bundle.js': ['webpack', 'sourcemap'] },

// Webpack Config at ./webpack.test.config.js
webpack: testWebpackConfig,

coverageReporter: {
dir : 'coverage/',
reporters: [
{ type: 'text-summary' },
{ type: 'html' }
],
},

// Webpack please don't spam the console when running in karma!
webpackServer: { noInfo: true },

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: [ 'progress', 'coverage' ],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [ 'PhantomJS' ],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
});

};
98 changes: 98 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"name": "webpack-test",
"version": "0.0.0",
"description": "",
"author": " <[email protected]>",
"homepage": "",
"license": "Apache-2.0",
"scripts": {
"clean": "./node_modules/.bin/rimraf node_modules doc typings coverage dist && npm cache clean",
"clean:dist": "./node_modules/.bin/rimraf dist",
"preclean:install": "npm run clean",
"clean:install": "npm install",
"preclean:start": "npm run clean",
"clean:start": "npm start",
"watch": "npm run watch:dev",
"watch:dev": "./node_modules/.bin/webpack --watch --progress --profile --colors --display-error-details --display-cached",
"watch:prod": "./node_modules/.bin/webpack --watch --config webpack.prod.config.js --progress --profile --colors --display-error-details --display-cached",
"build": "npm run build:prod",
"prebuild:dev": "npm run clean:dist",
"build:dev": "./node_modules/.bin/webpack --progress --profile --colors --display-error-details --display-cached",
"prebuild:prod": "npm run clean:dist",
"build:prod": "./node_modules/.bin/webpack --config webpack.prod.config.js --progress --profile --colors --display-error-details --display-cached",
"server": "npm run server:dev",
"server:dev": "./node_modules/.bin/webpack-dev-server --progress --profile --colors --display-error-details --display-cached",
"server:prod": "./node_modules/.bin/http-server dist --cors",
"webdriver:update": "./node_modules/.bin/webdriver-manager update",
"webdriver:start": "./node_modules/.bin/webdriver-manager start",
"lint": "./node_modules/.bin/tsconfig-lint",
"e2e": "./node_modules/.bin/protractor",
"test": "./node_modules/.bin/karma start",
"ci": "npm run e2e && npm run test",
"docs": "./node_modules/.bin/typedoc --options typedoc.json src/**/*.ts",
"start": "npm run server:dev",
"postinstall": "./node_modules/.bin/typings install"
},
"dependencies": {
"angular2": "2.0.0-beta.1",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"es7-reflect-metadata": "^1.4.0",
"github-api": "^0.10.7",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
"devDependencies": {
"copy-webpack-plugin": "^0.3.3",
"css-loader": "^0.23.0",
"exports-loader": "0.6.2",
"expose-loader": "^0.7.1",
"file-loader": "^0.8.4",
"html-webpack-plugin": "^1.7.0",
"http-server": "^0.8.5",
"imports-loader": "^0.6.4",
"istanbul-instrumenter-loader": "^0.1.3",
"json-loader": "^0.5.3",
"karma": "^0.13.15",
"karma-chrome-launcher": "^0.2.1",
"karma-coverage": "^0.5.3",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "^0.2.1",
"karma-sourcemap-loader": "^0.3.6",
"karma-webpack": "1.7.0",
"phantomjs": "^1.9.18",
"phantomjs-polyfill": "0.0.1",
"protractor": "^3.0.0",
"raw-loader": "0.5.1",
"reflect-metadata": "0.1.2",
"remap-istanbul": "^0.5.1",
"rimraf": "^2.4.4",
"style-loader": "^0.13.0",
"ts-helper": "0.0.1",
"ts-loader": "^0.7.2",
"tsconfig-lint": "^0.4.3",
"tslint": "^3.2.0",
"tslint-loader": "^2.1.0",
"typedoc": "^0.3.12",
"typescript": "^1.7.3",
"typings": "^0.6.1",
"url-loader": "^0.5.6",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.12.1",
"webpack-md5-hash": "0.0.4"
},
"repository": {
"type": "git",
"url": "https://github.com/angularclass/angular2-webpack-starter.git"
},
"bugs": {
"url": "https://github.com/angularclass/angular2-webpack-starter/issues"
},
"engines": {
"node": ">= 4.2.1 <= 5",
"npm": ">= 3"
},
"keywords": [
""
]
}
44 changes: 44 additions & 0 deletions protractor.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// @AngularClass

exports.config = {
baseUrl: 'http://localhost:3000/',

specs: [
'test/**/*.e2e.js'
],
exclude: [],

framework: 'jasmine',

allScriptsTimeout: 110000,

jasmineNodeOpts: {
showTiming: true,
showColors: true,
isVerbose: false,
includeStackTrace: false,
defaultTimeoutInterval: 400000
},
directConnect: true,

capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['show-fps-counter=true']
}
},

onPrepare: function() {
browser.ignoreSynchronization = true;
},


/**
* Angular 2 configuration
*
* useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
* `rootEl`
*
*/
useAllAngular2AppRoots: true
};
43 changes: 43 additions & 0 deletions spec-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// @AngularClass
/*
* When testing with webpack and ES6, we have to do some extra
* things get testing to work right. Because we are gonna write test
* in ES6 to, we have to compile those as well. That's handled in
* karma.conf.js with the karma-webpack plugin. This is the entry
* file for webpack test. Just like webpack will create a bundle.js
* file for our client, when we run test, it well compile and bundle them
* all here! Crazy huh. So we need to do some setup
*/
Error.stackTraceLimit = Infinity;
require('phantomjs-polyfill');
require('es6-promise');
require('es6-shim');
require('es7-reflect-metadata/dist/browser');

require('zone.js/lib/browser/zone-microtask.js');
require('zone.js/lib/browser/long-stack-trace-zone.js');
require('zone.js/dist/jasmine-patch.js');

/*
Ok, this is kinda crazy. We can use the the context method on
require that webpack created in order to tell webpack
what files we actually want to require or import.
Below, context will be an function/object with file names as keys.
using that regex we are saying look in ./src/app and ./test then find
any file that ends with spec.js and get its path. By passing in true
we say do this recursively
*/
var testContext = require.context('./test', true, /\.spec\.ts/);
var appContext = require.context('./src', true, /\.spec\.ts/);

// get all the files, for each file, call the context function
// that will require the file and load it up here. Context will
// loop and require those spec files here
appContext.keys().forEach(appContext);
testContext.keys().forEach(testContext);

// Select BrowserDomAdapter.
// see https://github.com/AngularClass/angular2-webpack-starter/issues/124
var domAdapter = require('angular2/src/platform/browser/browser_adapter');
domAdapter.BrowserDomAdapter.makeCurrent();

22 changes: 22 additions & 0 deletions src/app/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {
it,
inject,
injectAsync,
beforeEachProviders,
TestComponentBuilder
} from 'angular2/testing';

// Load the implementations that should be tested
import {App} from './app';

describe('App', () => {
// provide our implementations or mocks to the dependency injector
beforeEachProviders(() => [
App
]);

it('should have a name', inject([App], (app) => {
expect(app.name).toEqual('webpack-test');
}));

});
78 changes: 78 additions & 0 deletions src/app/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Angular 2 decorators and services
*/
import {Component} from 'angular2/core';
import {RouteConfig, Router, ROUTER_DIRECTIVES} from 'angular2/router';
import {FORM_PROVIDERS} from 'angular2/common';

import {RouterActive} from './directives/router-active';
import {Home} from './home/home';

/*
* App Component
* Top Level Component
*/
@Component({
selector: 'app',
providers: [...FORM_PROVIDERS],
directives: [...ROUTER_DIRECTIVES, RouterActive],
pipes: [],
styles: [`
nav ul {
display: inline;
list-style-type: none;
margin: 0;
padding: 0;
width: 60px;
}
nav li {
display: inline;
}
nav li.active {
background-color: lightgray;
}
`],
template: `
<header>
<nav>
<h1>Hello {{ name }}</h1>
<ul>
<li router-active="active">
<a [routerLink]=" ['Index'] ">Index</a>
</li>
<li router-active="active">
<a [routerLink]=" ['Home'] ">Home</a>
</li>
</ul>
</nav>
</header>
<main>
<router-outlet>Random</router-outlet>
</main>
<footer>
webpack-test by <a href="mailto:[email protected]" target="_top"></a>
</footer>
`
})
@RouteConfig([
{ path: '/', component: Home, name: 'Index' },
{ path: '/home', component: Home, name: 'Home' },
{ path: '/**', redirectTo: ['Index'] }
])
export class App {
name = 'webpack-test';
constructor() {

}
}

/*
* Please review the https://github.com/AngularClass/angular2-examples/ repo for
* more angular app examples that you may copy/paste
* (The examples may not be updated as quickly. Please open an issue on github for us to update it)
* For help or questions please contact us at @AngularClass on twitter
* or our chat on Slack at https://AngularClass.com/slack-join
* or via chat on Gitter at https://gitter.im/AngularClass/angular2-webpack-starter
*/
Loading

0 comments on commit f3af409

Please sign in to comment.