From d55d96bb98fd67a176d3130b6e0434819c198adf Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Mon, 4 Jan 2016 10:44:30 -0800 Subject: [PATCH] chore(Conventions): naming standards closes https://github.com/AngularClass/angular2-webpack-starter/issues/185 --- package.json | 2 +- .../app.component.spec.ts} | 6 ++--- .../{app.ts => components/app.component.ts} | 8 +++--- .../home/home.component.spec.ts} | 12 ++++----- .../home/home.component.ts} | 10 ++++---- src/app/{ => components}/home/home.css | 0 src/app/{ => components}/home/home.html | 0 .../x-large.directive.spec.ts} | 2 +- .../x-large.directive.ts} | 0 .../title.provider.spec.ts} | 2 +- .../title.ts => providers/title.provider.ts} | 0 src/main.ts | 4 +-- tsconfig.json | 25 +++++++++++-------- 13 files changed, 38 insertions(+), 33 deletions(-) rename src/app/{app.spec.ts => components/app.component.spec.ts} (77%) rename src/app/{app.ts => components/app.component.ts} (88%) rename src/app/{home/home.spec.ts => components/home/home.component.spec.ts} (76%) rename src/app/{home/home.ts => components/home/home.component.ts} (80%) rename src/app/{ => components}/home/home.css (100%) rename src/app/{ => components}/home/home.html (100%) rename src/app/{home/directives/x-large.spec.ts => directives/x-large.directive.spec.ts} (95%) rename src/app/{home/directives/x-large.ts => directives/x-large.directive.ts} (100%) rename src/app/{home/providers/title.spec.ts => providers/title.provider.spec.ts} (88%) rename src/app/{home/providers/title.ts => providers/title.provider.ts} (100%) diff --git a/package.json b/package.json index 6bd6f19c17..3f55ab8666 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "tslint-loader": "^2.1.0", "typedoc": "^0.3.12", "typescript": "^1.7.3", - "typings": "^0.3.1", + "typings": "^0.4.1", "url-loader": "^0.5.6", "webpack": "^1.12.9", "webpack-dev-server": "^1.12.1" diff --git a/src/app/app.spec.ts b/src/app/components/app.component.spec.ts similarity index 77% rename from src/app/app.spec.ts rename to src/app/components/app.component.spec.ts index abcf74eccb..7c9caf5007 100644 --- a/src/app/app.spec.ts +++ b/src/app/components/app.component.spec.ts @@ -7,15 +7,15 @@ import { } from 'angular2/testing'; // Load the implementations that should be tested -import {App} from './app'; +import {AppCmp} from './app.component'; describe('App', () => { // provide our implementations or mocks to the dependency injector beforeEachProviders(() => [ - App + AppCmp ]); - it('should have a url', inject([ App ], (app) => { + it('should have a url', inject([ AppCmp ], (app) => { expect(app.url).toEqual('https://twitter.com/AngularClass'); })); diff --git a/src/app/app.ts b/src/app/components/app.component.ts similarity index 88% rename from src/app/app.ts rename to src/app/components/app.component.ts index a92d5f6d8d..47f3e2e4ce 100644 --- a/src/app/app.ts +++ b/src/app/components/app.component.ts @@ -5,7 +5,7 @@ import {Component} from 'angular2/core'; import {RouteConfig, Router, ROUTER_DIRECTIVES} from 'angular2/router'; import {FORM_PROVIDERS} from 'angular2/common'; -import {Home} from './home/home'; +import {HomeCmp} from './home/home.component'; /* * App Component @@ -36,10 +36,10 @@ import {Home} from './home/home'; ` }) @RouteConfig([ - { path: '/', component: Home, name: 'Index' }, - { path: '/home', component: Home, name: 'Home' } + { path: '/', component: HomeCmp, name: 'Index' }, + { path: '/home', component: HomeCmp, name: 'Home' } ]) -export class App { +export class AppCmp { name = 'Angular 2 Webpack Starter'; url = 'https://twitter.com/AngularClass'; constructor() { diff --git a/src/app/home/home.spec.ts b/src/app/components/home/home.component.spec.ts similarity index 76% rename from src/app/home/home.spec.ts rename to src/app/components/home/home.component.spec.ts index 76ff653512..4b7da21060 100644 --- a/src/app/home/home.spec.ts +++ b/src/app/components/home/home.component.spec.ts @@ -12,14 +12,14 @@ import {BaseRequestOptions, Http} from 'angular2/http'; import {MockBackend} from 'angular2/http/testing'; // Load the implementations that should be tested -import {Home} from './home'; -import {Title} from './providers/title'; +import {HomeCmp} from './home.component'; +import {Title} from '../../providers/title.provider'; describe('Home', () => { // provide our implementations or mocks to the dependency injector beforeEachProviders(() => [ Title, - Home, + HomeCmp, BaseRequestOptions, MockBackend, provide(Http, { @@ -29,15 +29,15 @@ describe('Home', () => { deps: [MockBackend, BaseRequestOptions]}) ]); - it('should have a title', inject([ Home ], (home) => { + it('should have a title', inject([ HomeCmp ], (home) => { expect(home.title.value).toEqual('Angular 2'); })); - it('should have a http', inject([ Home ], (home) => { + it('should have a http', inject([ HomeCmp ], (home) => { expect(!!home.http).toEqual(true); })); - it('should log ngOnInit', inject([ Home ], (home) => { + it('should log ngOnInit', inject([ HomeCmp ], (home) => { spyOn(console, 'log'); expect(console.log).not.toHaveBeenCalled(); diff --git a/src/app/home/home.ts b/src/app/components/home/home.component.ts similarity index 80% rename from src/app/home/home.ts rename to src/app/components/home/home.component.ts index 5dddfde1df..b5f6ea777a 100644 --- a/src/app/home/home.ts +++ b/src/app/components/home/home.component.ts @@ -1,13 +1,13 @@ -import {Component} from 'angular2/core'; +import {Component, OnInit} from 'angular2/core'; import {FORM_DIRECTIVES} from 'angular2/common'; import {Http} from 'angular2/http'; -import {Title} from './providers/title'; -import {XLarge} from './directives/x-large'; +import {Title} from '../../providers/title.provider'; +import {XLarge} from '../../directives/x-large.directive'; @Component({ // The selector is what angular internally uses - // for `document.querySelectorAll(selector)` in our index.html + // for document.querySelectorAll(selector) in our index.html // where, in this case, selector is the string 'app' selector: 'home', // // We need to tell Angular's Dependency Injection which providers are in our app. @@ -27,7 +27,7 @@ import {XLarge} from './directives/x-large'; // Every Angular template is first compiled by the browser before Angular runs it's compiler template: require('./home.html') }) -export class Home { +export class HomeCmp implements OnInit { // TypeScript public modifiers constructor(public title: Title, public http: Http) { diff --git a/src/app/home/home.css b/src/app/components/home/home.css similarity index 100% rename from src/app/home/home.css rename to src/app/components/home/home.css diff --git a/src/app/home/home.html b/src/app/components/home/home.html similarity index 100% rename from src/app/home/home.html rename to src/app/components/home/home.html diff --git a/src/app/home/directives/x-large.spec.ts b/src/app/directives/x-large.directive.spec.ts similarity index 95% rename from src/app/home/directives/x-large.spec.ts rename to src/app/directives/x-large.directive.spec.ts index 1903d17440..c0ed1869f7 100644 --- a/src/app/home/directives/x-large.spec.ts +++ b/src/app/directives/x-large.directive.spec.ts @@ -12,7 +12,7 @@ import {BaseRequestOptions, Http} from 'angular2/http'; import {MockBackend} from 'angular2/http/testing'; // Load the implementations that should be tested -import {XLarge} from './x-large'; +import {XLarge} from './x-large.directive'; describe('x-large directive', () => { // Create a test component to test directives diff --git a/src/app/home/directives/x-large.ts b/src/app/directives/x-large.directive.ts similarity index 100% rename from src/app/home/directives/x-large.ts rename to src/app/directives/x-large.directive.ts diff --git a/src/app/home/providers/title.spec.ts b/src/app/providers/title.provider.spec.ts similarity index 88% rename from src/app/home/providers/title.spec.ts rename to src/app/providers/title.provider.spec.ts index a9b34e8e36..c759dbb1ed 100644 --- a/src/app/home/providers/title.spec.ts +++ b/src/app/providers/title.provider.spec.ts @@ -5,7 +5,7 @@ import { beforeEachProviders, TestComponentBuilder } from 'angular2/testing'; -import {Title} from './title'; +import {Title} from './title.provider'; describe('Title', () => { let title; diff --git a/src/app/home/providers/title.ts b/src/app/providers/title.provider.ts similarity index 100% rename from src/app/home/providers/title.ts rename to src/app/providers/title.provider.ts diff --git a/src/main.ts b/src/main.ts index 36c20d56a9..f721ff361b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,13 +10,13 @@ import {HTTP_PROVIDERS} from 'angular2/http'; * App Component * our top level component that holds all of our components */ -import {App} from './app/app'; +import {AppCmp} from './app/components/app.component'; /* * Bootstrap our Angular app with a top level component `App` and inject * our Services and Providers into Angular's dependency injection */ document.addEventListener('DOMContentLoaded', function main() { - bootstrap(App, [ + bootstrap(AppCmp, [ ...('production' === process.env.ENV ? [] : ELEMENT_PROBE_PROVIDERS), ...HTTP_PROVIDERS, ...ROUTER_PROVIDERS, diff --git a/tsconfig.json b/tsconfig.json index c6f4094096..abf0c709fc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,15 +9,18 @@ "sourceMap": true }, "files": [ - "typings/main.d.ts", - "test/injector.spec.ts", - "test/sanity-test.spec.ts", - "src/app/app.spec.ts", - "src/app/home/home.spec.ts", - "src/app/home/directives/x-large.spec.ts", - "src/app/home/providers/title.spec.ts", - "src/main.ts", - "src/vendor.ts" + "./src/app/components/app.component.spec.ts", + "./src/app/components/app.component.ts", + "./src/app/components/home/home.component.spec.ts", + "./src/app/components/home/home.component.ts", + "./src/app/directives/x-large.directive.spec.ts", + "./src/app/directives/x-large.directive.ts", + "./src/app/providers/title.provider.spec.ts", + "./src/app/providers/title.provider.ts", + "./src/main.ts", + "./src/vendor.ts", + "./test/injector.spec.ts", + "./test/sanity-test.spec.ts" ], "filesGlob": [ "./src/**/*.ts", @@ -26,5 +29,7 @@ ], "compileOnSave": false, "buildOnSave": false, - "atom": { "rewriteTsconfig": true } + "atom": { + "rewriteTsconfig": true + } }