Skip to content

Commit

Permalink
feat: aggregate all auth related components in auth module (close #535)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Mar 24, 2020
1 parent 626505c commit 8dbadb7
Show file tree
Hide file tree
Showing 38 changed files with 90 additions and 76 deletions.
42 changes: 21 additions & 21 deletions generators/app/templates/_package.json
Expand Up @@ -56,14 +56,14 @@
"generate": "ng generate"
},
"dependencies": {
"@angular/animations": "^9.0.0",
"@angular/common": "^9.0.0",
"@angular/compiler": "^9.0.0",
"@angular/core": "^9.0.0",
"@angular/forms": "^9.0.0",
"@angular/platform-browser": "^9.0.0",
"@angular/platform-browser-dynamic": "^9.0.0",
"@angular/router": "^9.0.0",
"@angular/animations": "^9.0.7",
"@angular/common": "^9.0.7",
"@angular/compiler": "^9.0.7",
"@angular/core": "^9.0.7",
"@angular/forms": "^9.0.7",
"@angular/platform-browser": "^9.0.7",
"@angular/platform-browser-dynamic": "^9.0.7",
"@angular/router": "^9.0.7",
"@ngx-translate/core": "^12.0.0",
<% if (props.target.includes('cordova')) { -%>
"@ionic-native/core": "^5.0.0",
Expand All @@ -81,18 +81,18 @@
"cordova-plugin-whitelist": "^1.3.3",
<% } -%>
<% if (props.pwa) { -%>
"@angular/service-worker": "^9.0.0",
"@angular/service-worker": "^9.0.7",
<% } -%>
<% if (props.ui === 'ionic') { -%>
"@ionic/angular": "^5.0.0",
<% } else if (props.ui === 'bootstrap') { -%>
"@ng-bootstrap/ng-bootstrap": "^5.0.0-rc.1",
"bootstrap": "^4.1.1",
"@fortawesome/fontawesome-free": "^5.1.0",
"@angular/localize": "^9.0.1",
"@angular/localize": "^9.0.7",
<% } else if (props.ui === 'material') { -%>
"@angular/cdk": "^9.0.0",
"@angular/material": "^9.0.0",
"@angular/cdk": "^9.1.3",
"@angular/material": "^9.1.3",
"@angular/flex-layout": "^9.0.0-beta.29",
"material-design-icons-iconfont": "^5.0.1",
<% } -%>
Expand All @@ -112,8 +112,8 @@
"date-fns": "^2.9.0",
<% } -%>
"rxjs": "^6.5.4",
"tslib": "^1.10.0",
"zone.js": "^0.10.2"
"tslib": "^1.10.1",
"zone.js": "^0.10.3"
},
"devDependencies": {
<% if (props.target.includes('cordova')) { -%>
Expand All @@ -122,10 +122,10 @@
<% if (props.tools.includes('jest')) { -%>
"@angular-builders/jest": "^8.3.2",
<% } -%>
"@angular/cli": "~9.0.1",
"@angular/compiler-cli": "^9.0.0",
"@angular/language-service": "^9.0.0",
"@angular-devkit/build-angular": "^0.900.1",
"@angular/cli": "~9.0.7",
"@angular/compiler-cli": "^9.0.1",
"@angular/language-service": "^9.0.1",
"@angular-devkit/build-angular": "^0.900.7",
"@angularclass/hmr": "^2.1.3",
"@biesbjerg/ngx-translate-extract": "^4.2.0",
"@ngx-rocket/scripts": "^4.0.0",
Expand Down Expand Up @@ -180,11 +180,11 @@
<% if (props.tools.includes('puppeteer')) { -%>
"puppeteer": "^2.1.1",
<% } -%>
"stylelint": "~13.2.0",
"stylelint": "~13.2.1",
"stylelint-config-recommended-scss": "~4.2.0",
"stylelint-config-standard": "~20.0.0",
"stylelint-scss": "~3.14.2",
"ts-node": "^8.3.0",
"stylelint-scss": "~3.16.0",
"ts-node": "^8.8.1",
"tslint": "~5.18.0",
"typescript": "~3.7.5"
<% if (props.tools.includes('prettier')) { -%>
Expand Down
8 changes: 4 additions & 4 deletions generators/app/templates/src/app/_app.module.ts
Expand Up @@ -35,14 +35,14 @@ import { environment } from '@env/environment';
<% } -%>
import { CoreModule } from '@app/core';
import { SharedModule } from '@app/shared';
<% if (props.auth) { -%>
import { AuthModule } from '@app/auth';
<% } -%>
import { HomeModule } from './home/home.module';
import { ShellModule } from './shell/shell.module';
<% if (!props.lazy) { -%>
import { AboutModule } from './about/about.module';
<% } -%>
<% if (props.auth) { -%>
import { LoginModule } from './login/login.module';
<% } -%>
<% if (props.layout === 'tabs') { -%>
import { SettingsModule } from './settings/settings.module';
<% } -%>
Expand Down Expand Up @@ -77,7 +77,7 @@ import { AppRoutingModule } from './app-routing.module';
AboutModule,
<% } -%>
<% if (props.auth) { -%>
LoginModule,
AuthModule,
<% } -%>
<% if (props.angulartics ) { -%>
Angulartics2Module.forRoot(),
Expand Down
Expand Up @@ -15,7 +15,7 @@ import { FlexLayoutModule } from '@angular/flex-layout';
import { SharedModule } from '@app/shared';
import { MaterialModule } from '@app/material.module';
<% } -%>
import { LoginRoutingModule } from './login-routing.module';
import { AuthRoutingModule } from './auth-routing.module';
import { LoginComponent } from './login.component';

@NgModule({
Expand All @@ -33,10 +33,10 @@ import { LoginComponent } from './login.component';
FlexLayoutModule,
MaterialModule,
<% } -%>
LoginRoutingModule
AuthRoutingModule
],
declarations: [
LoginComponent
]
})
export class LoginModule { }
export class AuthModule { }
Expand Up @@ -18,6 +18,9 @@ import { CoreModule } from '@app/core';
import { SharedModule } from '@app/shared';
import { MaterialModule } from '@app/material.module';
<% } -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
import { MockAuthenticationService } from '@app/auth/authentication.service.mock';
import { MockCredentialsService } from '@app/auth/credentials.service.mock';
import { LoginComponent } from './login.component';

describe('LoginComponent', () => {
Expand Down Expand Up @@ -46,8 +49,10 @@ describe('LoginComponent', () => {
<% if (props.ui === 'ionic') { -%>
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{ provide: AuthenticationService, useClass: MockAuthenticationService },
{ provide: CredentialsService, useClass: MockCredentialsService },
Platform,
LoadingController,
LoadingController
],
<% } -%>
declarations: [LoginComponent]
Expand Down
Expand Up @@ -9,7 +9,8 @@ import { forkJoin, from } from 'rxjs';
import { finalize } from 'rxjs/operators';

import { environment } from '@env/environment';
import { Logger, I18nService, AuthenticationService, untilDestroyed } from '@app/core';
import { Logger, I18nService, untilDestroyed } from '@app/core';
import { AuthenticationService } from './authentication.service';

const log = new Logger('Login');

Expand Down
Expand Up @@ -13,4 +13,4 @@ const routes: Routes = [
exports: [RouterModule],
providers: []
})
export class LoginRoutingModule { }
export class AuthRoutingModule { }
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';

import { Logger } from '../logger.service';
import { Logger } from '@app/core';
import { CredentialsService } from './credentials.service';

const log = new Logger('AuthenticationGuard');
Expand Down
4 changes: 4 additions & 0 deletions generators/app/templates/src/app/auth/index.ts
@@ -0,0 +1,4 @@
export * from './auth.module';
export * from './authentication.service';
export * from './credentials.service';
export * from './authentication.guard';
5 changes: 0 additions & 5 deletions generators/app/templates/src/app/core/_index.ts
@@ -1,9 +1,4 @@
export * from './core.module';
<% if (props.auth) { -%>
export * from './authentication/authentication.service';
export * from './authentication/credentials.service';
export * from './authentication/authentication.guard';
<% } -%>
export * from './i18n.service';
export * from './http/http.service';
export * from './http/http-cache.service';
Expand Down
Expand Up @@ -7,6 +7,11 @@ import { IonicModule } from '@ionic/angular';

import { SharedModule } from '@app/shared';
import { CoreModule } from '@app/core';
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
import { MockAuthenticationService } from '@app/auth/authentication.service.mock';
import { MockCredentialsService } from '@app/auth/credentials.service.mock';
<% } -%>
import { SettingsComponent } from './settings.component';

describe('SettingsComponent', () => {
Expand All @@ -25,9 +30,13 @@ describe('SettingsComponent', () => {
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SettingsComponent],
providers: [
<% if (props.auth) { -%>
{ provide: AuthenticationService, useClass: MockAuthenticationService },
{ provide: CredentialsService, useClass: MockCredentialsService },
<% } -%>
Platform,
AlertController,
ActionSheetController,
ActionSheetController
]
})
.compileComponents();
Expand Down
Expand Up @@ -4,10 +4,9 @@ import { TranslateService } from '@ngx-translate/core';
import { ActionSheetController, AlertController, Platform } from '@ionic/angular';
import { TextFieldTypes } from '@ionic/core';

<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService, I18nService } from '@app/core';
<% } else { -%>
import { I18nService } from '@app/core';
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
<% } -%>

@Component({
Expand Down
Expand Up @@ -4,10 +4,9 @@ import { ActionSheetController, AlertController, Platform } from '@ionic/angular
import { ActionSheetButton, ActionSheetOptions, TextFieldTypes } from '@ionic/core';
import { TranslateService } from '@ngx-translate/core';

<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService, I18nService } from '@app/core';
<% } else {-%>
import { I18nService } from '@app/core';
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
<% } -%>

@Component({
Expand Down
Expand Up @@ -3,10 +3,9 @@ import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { MediaObserver } from '@angular/flex-layout';

<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService, I18nService } from '@app/core';
<% } else { -%>
import { I18nService } from '@app/core';
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
<% } -%>

@Component({
Expand Down
Expand Up @@ -12,12 +12,11 @@ import { FlexLayoutModule } from '@angular/flex-layout';
import { MaterialModule } from '@app/material.module';
<% } -%>

<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService, CoreModule } from '@app/core';
import { MockAuthenticationService } from '@app/core/authentication/authentication.service.mock';
import { MockCredentialsService } from '@app/core/authentication/credentials.service.mock';
<% } else {-%>
import { CoreModule } from '@app/core';
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
import { MockAuthenticationService } from '@app/auth/authentication.service.mock';
import { MockCredentialsService } from '@app/auth/credentials.service.mock';
<% } -%>

import { ShellComponent } from './shell.component';
Expand Down
6 changes: 6 additions & 0 deletions generators/app/templates/src/app/shell/_shell.module.ts
Expand Up @@ -12,6 +12,9 @@ import { IonicModule } from '@ionic/angular';
<% if (props.ui === 'material') { -%>
import { MaterialModule } from '@app/material.module';
<% } -%>
<% if (props.auth) { -%>
import { AuthModule } from '@app/auth';
<% } -%>

import { ShellComponent } from './shell.component';
<% if (props.ui === 'bootstrap' || (props.ui === 'material' && props.layout === 'simple') || props.ui === 'raw') { -%>
Expand All @@ -29,6 +32,9 @@ import { HeaderComponent } from './header/header.component';
MaterialModule,
<% } else if (props.ui === 'ionic') { -%>
IonicModule,
<% } -%>
<% if (props.auth) { -%>
AuthModule,
<% } -%>
RouterModule
],
Expand Down
4 changes: 2 additions & 2 deletions generators/app/templates/src/app/shell/_shell.service.spec.ts
@@ -1,8 +1,8 @@
import { TestBed, inject } from '@angular/core/testing';

<% if (props.auth) { -%>
import { AuthenticationGuard, AuthenticationService } from '@app/core';
import { MockAuthenticationService } from '@app/core/authentication/authentication.service.mock';
import { AuthenticationGuard, AuthenticationService } from '@app/auth';
import { MockAuthenticationService } from '@app/auth/authentication.service.mock';
<% } -%>
import { ShellComponent } from './shell.component';
import { Shell } from './shell.service';
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/src/app/shell/_shell.service.ts
@@ -1,7 +1,7 @@
import { Routes, Route } from '@angular/router';

<% if (props.auth) { -%>
import { AuthenticationGuard } from '@app/core';
import { AuthenticationGuard } from '@app/auth';
<% } -%>
import { ShellComponent } from './shell.component';

Expand Down
Expand Up @@ -3,12 +3,11 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
import { RouterTestingModule } from '@angular/router/testing';

<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService, I18nService } from '@app/core';
import { MockAuthenticationService } from '@app/core/authentication/authentication.service.mock';
import { MockCredentialsService } from '@app/core/authentication/credentials.service.mock';
<% } else {-%>
import { I18nService } from '@app/core';
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
import { MockAuthenticationService } from '@app/auth/authentication.service.mock';
import { MockCredentialsService } from '@app/auth/credentials.service.mock';
<% } -%>
import { HeaderComponent } from './header.component';

Expand Down
Expand Up @@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core';
<% if (props.auth) { -%>
import { Router } from '@angular/router';

import { AuthenticationService, CredentialsService, I18nService } from '@app/core';
import { I18nService } from '@app/core';
import { AuthenticationService, CredentialsService } from '@app/auth';
<% } else { -%>

import { I18nService } from '@app/core';
Expand Down
Expand Up @@ -3,13 +3,12 @@ import { TranslateModule } from '@ngx-translate/core';
import { RouterTestingModule } from '@angular/router/testing';

import { MaterialModule } from '@app/material.module';
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService, I18nService } from '@app/core';
import { MockAuthenticationService } from '@app/core/authentication/authentication.service.mock';
import { MockCredentialsService } from '@app/core/authentication/credentials.service.mock';
<% } else {-%>
import { I18nService } from '@app/core';
<% }-%>
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
import { MockAuthenticationService } from '@app/auth/authentication.service.mock';
import { MockCredentialsService } from '@app/auth/credentials.service.mock';
<% } -%>
import { HeaderComponent } from './header.component';

describe('HeaderComponent', () => {
Expand Down
Expand Up @@ -3,10 +3,9 @@ import { Component, OnInit, Input } from '@angular/core';
import { Router } from '@angular/router';
import { MatSidenav } from '@angular/material/sidenav';

<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService, I18nService } from '@app/core';
<% } else { -%>
import { I18nService } from '@app/core';
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
<% } -%>

@Component({
Expand Down
Expand Up @@ -2,12 +2,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { RouterTestingModule } from '@angular/router/testing';

<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService, I18nService } from '@app/core';
import { MockAuthenticationService } from '@app/core/authentication/authentication.service.mock';
import { MockCredentialsService } from '@app/core/authentication/credentials.service.mock';
<% } else { -%>
import { I18nService } from '@app/core';
<% if (props.auth) { -%>
import { AuthenticationService, CredentialsService } from '@app/auth';
import { MockAuthenticationService } from '@app/auth/authentication.service.mock';
import { MockCredentialsService } from '@app/auth/credentials.service.mock';
<% } -%>
import { HeaderComponent } from './header.component';

Expand Down

0 comments on commit 8dbadb7

Please sign in to comment.