Skip to content

Commit

Permalink
Merge pull request #23 from mcfly-io/feat-beta3
Browse files Browse the repository at this point in the history
  • Loading branch information
thaiat committed Feb 5, 2016
2 parents f758057 + 75c3324 commit 1070d62
Show file tree
Hide file tree
Showing 23 changed files with 248 additions and 2,507 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
language: node_js
sudo: false
node_js:
- '5.4.1'
- v4
- '0.12'

cache:
directories:
Expand All @@ -19,7 +17,7 @@ deploy:
on:
tags: true
all_branches: true
node: '0.12'
node: 'v4'
repo: mcfly-io/generator-mcfly-ng2
api_key:
secure: l8KIctJUFziwsr4cl1y37gFBWXsV7+1syvRvC/f9Y+UXxqGTPOGixOmuNulMfnA6tEADzZGKnvhoaWgRk1WwqVDJY1vcnQGtRQ5QyoL/uouIFeGVVbUSv0oSl6AACrIOhQc/QrRoYBWZQt+tfTNwDln1CSf4F+UrXKYlI/RHoNm7Frhe+szWuDaxbwsIrkRJqMFC8hhZ5OQb4n5Cgus2mPhpm62mq8hVcKrhz6YNid7aHFraRZznD1D5YHA61TgmKVSQCGyyBsoUUfox32Fk3EdmbiAQ04ma8R2z5V02bqhTYZsJ7ygzdeI8rXKs2StSaPYiFj8uBrl1ee7LOB6vXAN+pih/0psmLkXXPHXb1l52B20CGMMM6Ydk9l+NSjVuu5ZJQBPdZ0J55lH9Fnm4rTWK6tRe5ORbNyd40m1H7Sio9rvNHadyZ8kRLHUwwHNgeXLw4vUu+sZ7UnTBMzCgO9R6evFlntsgJ2xE1++9u4GffOGU/0Yp4HW9b0GNNLAS77WIdqfyK0nm3INJ6EeZlx9tJ9nFUfZ5tiAXCLufNhlKOvpEW9ZENmNJSaMLGIEweiUem4jeZ4KIUNofjAiZe9M++fUfTTRlC4aXD7CUxIvd3YZnTb+UCp1j1BFsfynRvCDaWTTbPQuSgCNksWPeRKj/WW3RdUMF8lxKpoEkDUo=
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ You have access to the following npm scripts
* **npm run clean** (clean the `dist` folder)
* **npm run build** (build the code to the `dist` folder)
* **npm run browsersync** (open a live browser on port 5000, recompiling the code on each change)
* **npm run webpack-server** (same as browsersync but uses webpack-dev-server)
* **npm run webpack:server** (same as browsersync but uses webpack-dev-server)
* **npm run lint** (run eslint and tslint)
* **npm run karma** (run unit test)
* **npm run karma:watch** (run unit test in watch mode)
* **npm run e2e** (run e2e test - make sure that browsersync or webpack:server is running in another console window)
* **npm run e2e:live** (run e2e test and stop to allow debug - make sure that browsersync or webpack:server is running in another console window)

## Distribution
Note that the code is distributed to the `dist` folder
Expand Down
16 changes: 16 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ module.exports = generators.Base.extend({
this.templatePath('_npmrc'),
this.destinationPath('.npmrc')
);

this.fs.copyTpl(
this.templatePath('_travis.yml'),
this.destinationPath('.travis.yml')
);

this.fs.copyTpl(
this.templatePath('_package.json'),
this.destinationPath('package.json'), {
Expand Down Expand Up @@ -179,6 +185,16 @@ module.exports = generators.Base.extend({
this.destinationPath('test/sanity.spec.ts')
);

this.fs.copyTpl(
this.templatePath('protractor.conf.js'),
this.destinationPath('protractor.conf.js')
);

this.fs.copyTpl(
this.templatePath('protractor/browserExtension.js'),
this.destinationPath('protractor/browserExtension.js')
);

},

conflicts: function() {
Expand Down
5 changes: 4 additions & 1 deletion generators/app/templates/_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ You have access to the following npm scripts
* **npm run clean** (clean the `dist` folder)
* **npm run build** (build the code to the `dist` folder)
* **npm run browsersync** (open a live browser on port 5000, recompiling the code on each change)
* **npm run webpack-server** (same as browsersync but uses webpack-dev-server)
* **npm run webpack:server** (same as browsersync but uses webpack-dev-server)
* **npm run lint** (run eslint and tslint)
* **npm run karma** (run unit test)
* **npm run karma:watch** (run unit test in watch mode)
* **npm run e2e** (run e2e test - make sure that browsersync or webpack:server is running in another console window)
* **npm run e2e:live** (run e2e test and stop to allow debug - make sure that browsersync or webpack:server is running in another console window)

## Distribution
Note that the code is distributed to the `dist` folder
Expand Down
3 changes: 2 additions & 1 deletion generators/app/templates/_eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"sinon": true,
"xdescribe": true,
"xit": true,
"by": true
"by": true,
"element": true
},
"plugins": [
"nodeca"
Expand Down
31 changes: 23 additions & 8 deletions generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,83 @@
"type": "git",
"url": ""
},
"engines": {
"node": ">= 4.2.1 <= 5"
},
"scripts": {
"build": "webpack --progress --profile --display-error-details --display-cached",
"watch": "webpack --watch --progress --profile --display-error-details --display-cached",
"clean": "rm -rf dist coverage",
"clean": "rimraf dist coverage reports",
"tslint": "tslint -c tslint.json \"<%=clientFolder%>/**/*.ts\" ",
"eslint": "eslint .",
"lint": "npm run tslint && npm run eslint",
"browsersync": "npm run watch & browser-sync start --server=dist/${TARGET-app}/${MODE-dev} --files=\"dist/${TARGET-app}/${MODE-dev}/*.*\" --port 5000",
"webpack-server": "webpack-dev-server --hot --colors --progress",
"webpack:server": "webpack-dev-server --hot --colors --progress",
"karma": "karma start",
"pretest": "npm run lint",
"test": "npm run karma",
"karma:watch": "WATCH=true npm run karma -- --auto-watch --no-single-run",
"webdriver:update": "webdriver-manager update",
"webdriver:start": "webdriver-manager start",
"pree2e": "npm run webdriver:update -- --standalone",
"e2e": "ts-node node_modules/.bin/protractor",
"e2e:live": "protractor --elementExplorer",
"fuse.preview": "fuse preview",
"fuse.ios": "fuse build --target=iOS --run",
"fuse.android": "fuse build --target=Android --run",
"postinstall": "tsd install"
},
"dependencies": {
"angular2": "2.0.0-beta.1",
"angular2": "2.0.0-beta.3",
"es6-shim": "0.33.3",
"es7-reflect-metadata": "1.4.0",
"lodash": "^4.0.1",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
"zone.js": "0.5.11"
},
"devDependencies": {
"autoprefixer": "^6.3.1",
"browser-sync": "^2.10.1",
"coveralls": "^2.11.6",
"css-loader": "^0.23.1",
"eslint": "^1.10.3",
"eslint-plugin-nodeca": "^1.0.3",
"file-loader": "^0.8.5",
"gulp-mux": "^0.2.24",
"html-loader": "^0.4.0",
"html-webpack-plugin": "^1.7.0",
"html-webpack-plugin": "^2.8.1",
"istanbul-instrumenter-loader": "^0.1.3",
"json-loader": "^0.5.4",
"karma": "^0.13.11",
"karma-chrome-launcher": "^0.2.1",
"karma-chrome-launcher": "^0.2.2",
"karma-coverage": "^0.5.2",
"karma-jasmine": "^0.3.6",
"karma-mocha-reporter": "^1.1.3",
"karma-phantomjs-launcher": "^0.2.1",
"karma-nyan-reporter": "^0.2.3",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sourcemap-loader": "^0.3.6",
"karma-webpack": "1.7.0",
"ngux-loader": "mcfly-io/ngux-loader",
"node-sass": "^3.4.2",
"phantomjs": "^2.1.2",
"phantomjs-polyfill": "0.0.1",
"phantomjs-prebuilt": "^2.1.3",
"postcss-loader": "^0.8.0",
"protractor": "^3.0.0",
"raw-loader": "^0.5.1",
"rimraf": "^2.5.1",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.0",
"ts-loader": "^0.8.0",
"ts-node": "^0.5.5",
"tsd": "^0.6.5",
"tslint": "^3.2.1",
"tslint-eslint-rules": "^1.0.1",
"tslint-loader": "^2.1.0",
"typescript": "^1.7.5",
"url-loader": "^0.5.7",
"webpack": "^1.12.9",
"webpack": "^1.12.13",
"webpack-dev-server": "^1.14.0",
"yargs": "^3.31.0"
},
Expand Down
78 changes: 9 additions & 69 deletions generators/app/templates/_spec-bundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @AngularClass
'use strict';
/*
* When testing with webpack and ES6, we have to do some extra
* things get testing to work right. Because we are gonna write test
Expand All @@ -8,96 +8,36 @@
* 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/dist/zone-microtask.js');
require('zone.js/dist/long-stack-trace-zone.js');
require('zone.js/dist/jasmine-patch.js');
// these are global EmitHelpers used by compiled typescript
globalPolyfills();

require('angular2/testing');
var testing = require('angular2/testing');
var browser = require('angular2/platform/testing/browser');
testing.setBaseTestProviders(
browser.TEST_BROWSER_PLATFORM_PROVIDERS,
browser.TEST_BROWSER_APPLICATION_PROVIDERS);

/*
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 client/app and find
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 appContext = require.context('./<%=clientFolder%>', true, /\.spec\.ts/);
var testContext = require.context('./test', true, /\.spec\.ts/);
var appContext = require.context('./<%=clientFolder%>', true, /^((?!vendor)(?!bootstrap).)*\.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();

// these are helpers that typescript uses
// I manually added them by opting out of EmitHelpers by noEmitHelpers: false
function globalPolyfills() {
global.__extends = (this && this.__extends) || function(d, b) {
for (var p in b)
if (b.hasOwnProperty(p)) d[p] = b[p];
var __ = function() {
this.constructor = d;
};
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};

global.__decorate = global.Reflect.decorate;
global.__metadata = global.Reflect.metadata;

global.__param = (this && this.__param) || function(paramIndex, decorator) {
return function(target, key) {
decorator(target, key, paramIndex);
};
};

global.__awaiter = (this && this.__awaiter) ||
function(thisArg, _arguments, Promise, generator) {
return new Promise(function(resolve, reject) {
generator = generator.call(thisArg, _arguments);

function cast(value) {
return value instanceof Promise && value.constructor === Promise ?
value : new Promise(function(resolve) {
resolve(value);
});
}

function onfulfill(value) {
try {
step('next', value);
} catch (e) {
reject(e);
}
}

function onreject(value) {
try {
step('throw', value);
} catch (e) {
reject(e);
}
}

function step(verb, value) {
var result = generator[verb](value);
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
}
step('next', void 0);
});
};
}
12 changes: 12 additions & 0 deletions generators/app/templates/_travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: node_js
sudo: false
node_js:
- v4

cache:
directories:
- node_modules
- bower_components

after_success:
- cat ./coverage/unit/lcov.info | ./node_modules/coveralls/bin/coveralls.js --verbose
2 changes: 2 additions & 0 deletions generators/app/templates/_tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
],
"filesGlob": [
"<%=clientFolder%>/**/*.ts",
"test/**/*.ts",
"typings/tsd.d.ts",
"!./node_modules/**/*.ts"
]
}
19 changes: 8 additions & 11 deletions generators/app/templates/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var path = require('path');
var webpackConfig = require('./webpack.config');
var clientFolder = require('./.yo-rc.json')['generator-mcfly-ng2'].clientFolder;
module.exports = function(config) {
var _config = {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
Expand Down Expand Up @@ -64,14 +64,14 @@ module.exports = function(config) {
subdir: '.'
}, {
type: 'text',
subdir:'.'
subdir: '.'
}, {
type: 'text-summary',
subdir:'.'
subdir: '.'
}, {
type: 'cobertura',
file: 'coverage.xml',
subdir:'.'
subdir: '.'
}, {
type: 'lcov',
subdir: '.'
Expand All @@ -84,7 +84,7 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['mocha', 'coverage'],
reporters: process.env.WATCH === 'true' ? ['nyan'] : ['mocha', 'coverage'],

// web server port
port: 9876,
Expand All @@ -94,7 +94,7 @@ module.exports = function(config) {

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

// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
Expand All @@ -106,8 +106,5 @@ module.exports = function(config) {
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
};

config.set(_config);

};
});
};
Loading

0 comments on commit 1070d62

Please sign in to comment.