forked from PatrickJS/NG6-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7c501a7
Showing
48 changed files
with
951 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.git | ||
node_modules | ||
.settings | ||
*.log | ||
client/app/bundle.js | ||
client/app/bundle.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
var gulp = require('gulp'), | ||
webpack = require('gulp-webpack'), | ||
path = require('path'), | ||
sync = require('run-sequence'), | ||
serve = require('browser-sync'), | ||
rename = require('gulp-rename'), | ||
template = require('gulp-template'), | ||
fs = require('fs'), | ||
yargs = require('yargs').argv, | ||
lodash = require('lodash'), | ||
reload = function () { return serve.reload() }; | ||
|
||
|
||
// helper method to resolveToApp paths | ||
var resolveToApp = function(glob){ | ||
glob = glob || ''; | ||
return path.join(root, 'app', glob); // app/{glob} | ||
}; | ||
|
||
var resolveToComponents = function(glob){ | ||
glob = glob || ''; | ||
return path.join(root, 'app/components', glob); // app/components/{glob} | ||
}; | ||
|
||
var root = 'client'; | ||
|
||
// map of all our paths | ||
var paths = { | ||
js: resolveToApp('components/**/*!(.spec.js).js'), // don't include spec files | ||
styl: resolveToApp('**/*.styl'), // our stylus files | ||
html: [ | ||
resolveToApp('components/**/*.html'), | ||
path.join(root, 'index.html') | ||
], | ||
|
||
entry: path.join(root, 'app/app.js'), | ||
output: root, | ||
blankTemplates: path.join(__dirname, 'generator', 'component/**/*.**') | ||
}; | ||
|
||
// use our webpack.config.js to | ||
// build our modules | ||
gulp.task('webpack', function(){ | ||
return gulp.src(paths.entry) | ||
.pipe(webpack(require('./webpack.config'))) | ||
.pipe(gulp.dest(paths.output)); | ||
}); | ||
|
||
gulp.task('serve', function(){ | ||
serve({ | ||
port: process.env.PORT || 3000, | ||
open: false, | ||
server: { | ||
baseDir: root | ||
} | ||
}); | ||
}); | ||
|
||
|
||
gulp.task('watch', function(){ | ||
var allPaths = [].concat( | ||
paths.js, | ||
paths.html, | ||
paths.styl | ||
); | ||
|
||
|
||
gulp.watch(allPaths, ['webpack', reload]); | ||
}); | ||
|
||
gulp.task('component', function(){ | ||
var cap = function(val){ | ||
return val.charAt(0).toUpperCase() + val.slice(1); | ||
}; | ||
|
||
var name = yargs.name; | ||
var parentPath = yargs.parent || ''; | ||
var destPath = path.join(resolveToComponents(), parentPath, name); | ||
|
||
return gulp.src(paths.blankTemplates) | ||
.pipe(template({ | ||
name: name, | ||
upCaseName: cap(name) | ||
})) | ||
.pipe(rename(function(path){ | ||
path.basename = path.basename.replace('temp', name); | ||
})) | ||
.pipe(gulp.dest(destPath)); | ||
}); | ||
|
||
|
||
gulp.task('default', function(done){ | ||
sync('webpack', 'serve', 'watch', done); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import template from './app.html'; | ||
import './app.styl'; | ||
|
||
let appComonent = ()=>{ | ||
return { | ||
template, // because we have a variable name template we can use the shorcut here | ||
restrict: 'E' | ||
}; | ||
}; | ||
|
||
export default appComonent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<!--Anything you want to be on every page, place it in this file--> | ||
<div ui-view></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import angular from 'angular'; | ||
import uiRouter from 'angular-ui-router'; | ||
import Common from './common/common'; | ||
import Components from './components/components'; | ||
import AppComponent from './app.component'; | ||
|
||
angular.module('app', [ | ||
uiRouter, | ||
Common.name, | ||
Components.name | ||
]) | ||
.directive('app', AppComponent); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import angular from 'angular'; | ||
import Navbar from './navbar/navbar'; | ||
import Hero from './hero/hero'; | ||
import User from './user/user'; | ||
|
||
let commonModule = angular.module('app.common', [ | ||
Navbar.name, | ||
Hero.name, | ||
User.name | ||
]); | ||
|
||
export default commonModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@import 'reset' | ||
|
||
primaryColor = red | ||
accentColor = blue | ||
|
||
darkBgColor = lighten(black, 30%) | ||
lightBgColor = lighten(black, 50%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import template from './hero.html'; | ||
import controller from './hero.controller'; | ||
import './hero.styl'; | ||
|
||
let heroComponent = function(){ | ||
return { | ||
template, | ||
controller, | ||
restrict: 'E', | ||
controllerAs: 'vm', | ||
scope: {}, | ||
bindToController: true | ||
}; | ||
}; | ||
|
||
export default heroComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class HeroController { | ||
constructor(){ | ||
this.name = 'hero'; | ||
} | ||
} | ||
|
||
|
||
export default HeroController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div> | ||
<h1>{{ vm.name }}</h1> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import angular from 'angular'; | ||
import uiRouter from 'angular-ui-router'; | ||
import heroComponent from './hero.component'; | ||
|
||
let heroModule = angular.module('hero', [ | ||
uiRouter | ||
]) | ||
.directive('hero', heroComponent); | ||
|
||
export default heroModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import HeroModule from './hero' | ||
import HeroController from './hero.controller'; | ||
import HeroComponent from './hero.component'; | ||
import HeroTemplate from './hero.html'; | ||
|
||
describe('Hero', ()=>{ | ||
let $rootScope, | ||
makeController; | ||
|
||
beforeEach(window.module(HeroModule.name)); | ||
beforeEach(inject((_$rootScope_)=>{ | ||
$rootScope = _$rootScope_; | ||
makeController = ()=>{ | ||
return new HeroController(); | ||
}; | ||
})); | ||
|
||
describe('Module', ()=>{ | ||
// test things about the component module | ||
// checking to see if it registers certain things and what not | ||
// test for best practices with naming too | ||
// test for routing | ||
}); | ||
|
||
describe('Controller', ()=>{ | ||
// test your controller here | ||
|
||
it('should have a name property [REMOVE]', ()=>{ // erase me if you remove this.name from the controller | ||
let controller = makeController(); | ||
|
||
expect(controller).to.have.property('name'); | ||
}); | ||
}); | ||
|
||
describe('Template', ()=>{ | ||
// test the template | ||
// use Regexes to test that you are using the right bindings {{ }} | ||
|
||
it('should have name in template [REMOVE]', ()=>{ | ||
expect(HeroTemplate).to.match(/{{\s?vm\.name\s?}}/g); | ||
}); | ||
}); | ||
|
||
|
||
describe('Component', ()=>{ | ||
// test the component/directive itself | ||
let component = HeroComponent(); | ||
|
||
it('should use the right template',()=>{ | ||
expect(component.template).to.equal(HeroTemplate); | ||
}); | ||
|
||
it('should use controllerAs', ()=>{ | ||
expect(component).to.have.property('controllerAs'); | ||
}); | ||
|
||
it('should use the right controller', ()=>{ | ||
expect(component.controller).to.equal(HeroController); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.hero | ||
color red |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import template from './navbar.html'; | ||
import controller from './navbar.controller'; | ||
import './navbar.styl'; | ||
|
||
let navbarComponent = function(){ | ||
return { | ||
template, | ||
controller, | ||
restrict: 'E', | ||
controllerAs: 'vm', | ||
scope: {}, | ||
bindToController: true | ||
}; | ||
}; | ||
|
||
export default navbarComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class NavbarController { | ||
constructor(){ | ||
this.name = 'navbar'; | ||
} | ||
} | ||
|
||
|
||
export default NavbarController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="navbar"> | ||
<h1>{{ vm.name }}</h1> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import angular from 'angular'; | ||
import uiRouter from 'angular-ui-router'; | ||
import navbarComponent from './navbar.component'; | ||
|
||
let navbarModule = angular.module('navbar', [ | ||
uiRouter | ||
]) | ||
.directive('navbar', navbarComponent); | ||
|
||
export default navbarModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import NavbarModule from './navbar' | ||
import NavbarController from './navbar.controller'; | ||
import NavbarComponent from './navbar.component'; | ||
import NavbarTemplate from './navbar.html'; | ||
|
||
describe('Navbar', ()=>{ | ||
let $rootScope, | ||
makeController; | ||
|
||
beforeEach(window.module(NavbarModule.name)); | ||
beforeEach(inject((_$rootScope_)=>{ | ||
$rootScope = _$rootScope_; | ||
makeController = ()=>{ | ||
return new NavbarController(); | ||
}; | ||
})); | ||
|
||
describe('Module', ()=>{ | ||
// test things about the component module | ||
// checking to see if it registers certain things and what not | ||
// test for best practices with naming too | ||
// test for routing | ||
}); | ||
|
||
describe('Controller', ()=>{ | ||
// test your controller here | ||
|
||
it('should have a name property [REMOVE]', ()=>{ // erase me if you remove this.name from the controller | ||
let controller = makeController(); | ||
|
||
expect(controller).to.have.property('name'); | ||
}); | ||
}); | ||
|
||
describe('Template', ()=>{ | ||
// test the template | ||
// use Regexes to test that you are using the right bindings {{ }} | ||
|
||
it('should have name in template [REMOVE]', ()=>{ | ||
expect(NavbarTemplate).to.match(/{{\s?vm\.name\s?}}/g); | ||
}); | ||
}); | ||
|
||
|
||
describe('Component', ()=>{ | ||
// test the component/directive itself | ||
let component = NavbarComponent(); | ||
|
||
it('should use the right template',()=>{ | ||
expect(component.template).to.equal(NavbarTemplate); | ||
}); | ||
|
||
it('should use controllerAs', ()=>{ | ||
expect(component).to.have.property('controllerAs'); | ||
}); | ||
|
||
it('should use the right controller', ()=>{ | ||
expect(component.controller).to.equal(NavbarController); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@import '../common' | ||
|
||
.navbar | ||
[navbar] | ||
height 65px | ||
background-color primaryColor | ||
padding 10px | ||
|
||
|
||
|
Oops, something went wrong.