diff --git a/.travis.yml b/.travis.yml index 867db8075..f3c019d99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ os: - osx language: node_js node_js: + - '12' - '11' - '10' dist: xenial diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..1f4f7bafa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "workbench.colorCustomizations": { + "activityBar.background": "#c26c93", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#acd08e", + "activityBarBadge.foreground": "#15202b" + } +} \ No newline at end of file diff --git a/package.json b/package.json index 1a4863ccc..46ecdf970 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "electron:mac": "npm run build:prod && electron-builder build --mac", "test": "npm run postinstall:web && ng test", "e2e": "npm run build:prod && mocha --timeout 300000 --require ts-node/register e2e/**/*.spec.ts", - "version": "conventional-changelog -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md" + "version": "conventional-changelog -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md", + "lint": "ng lint" }, "devDependencies": { "@angular-devkit/build-angular": "0.800.0", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index a8c54884b..56201ff60 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,16 +1,21 @@ -import { HomeComponent } from './components/home/home.component'; import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; +import { PageNotFoundComponent } from './shared/components'; const routes: Routes = [ - { - path: '', - component: HomeComponent - } + { + path: '', + redirectTo: 'home', + pathMatch: 'full' + }, + { + path: '**', + component: PageNotFoundComponent + } ]; @NgModule({ - imports: [RouterModule.forRoot(routes, {useHash: true})], - exports: [RouterModule] + imports: [RouterModule.forRoot(routes, { useHash: true })], + exports: [RouterModule] }) -export class AppRoutingModule { } +export class AppRoutingModule {} diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index e8f25b530..4deab6e5e 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -2,21 +2,14 @@ import { TestBed, async } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { AppComponent } from './app.component'; import { TranslateModule } from '@ngx-translate/core'; -import { ElectronService } from './providers/electron.service'; +import { ElectronService } from './core/services'; describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - providers: [ - ElectronService - ], - imports: [ - RouterTestingModule, - TranslateModule.forRoot() - ] + declarations: [AppComponent], + providers: [ElectronService], + imports: [RouterTestingModule, TranslateModule.forRoot()] }).compileComponents(); })); @@ -28,6 +21,5 @@ describe('AppComponent', () => { }); class TranslateServiceStub { - setDefaultLang(lang: string): void { - } + setDefaultLang(lang: string): void {} } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 11b2b55f3..9e97aa5a3 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { ElectronService } from './providers/electron.service'; +import { ElectronService } from './core/services'; import { TranslateService } from '@ngx-translate/core'; import { AppConfig } from '../environments/environment'; @@ -9,13 +9,14 @@ import { AppConfig } from '../environments/environment'; styleUrls: ['./app.component.scss'] }) export class AppComponent { - constructor(public electronService: ElectronService, - private translate: TranslateService) { - + constructor( + public electronService: ElectronService, + private translate: TranslateService + ) { translate.setDefaultLang('en'); console.log('AppConfig', AppConfig); - if (electronService.isElectron()) { + if (electronService.isElectron) { console.log('Mode electron'); console.log('Electron ipcRenderer', electronService.ipcRenderer); console.log('NodeJS childProcess', electronService.childProcess); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 907863011..876d7ce96 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,10 +1,12 @@ import 'reflect-metadata'; import '../polyfills'; + import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; - import { HttpClientModule, HttpClient } from '@angular/common/http'; +import { CoreModule } from './core/core.module'; +import { SharedModule } from './shared/shared.module'; import { AppRoutingModule } from './app-routing.module'; @@ -12,12 +14,9 @@ import { AppRoutingModule } from './app-routing.module'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; -import { ElectronService } from './providers/electron.service'; - -import { WebviewDirective } from './directives/webview.directive'; +import { HomeModule } from './home/home.module'; import { AppComponent } from './app.component'; -import { HomeComponent } from './components/home/home.component'; // AoT requires an exported function for factories export function HttpLoaderFactory(http: HttpClient) { @@ -25,25 +24,24 @@ export function HttpLoaderFactory(http: HttpClient) { } @NgModule({ - declarations: [ - AppComponent, - HomeComponent, - WebviewDirective - ], + declarations: [AppComponent], imports: [ BrowserModule, FormsModule, HttpClientModule, + CoreModule, + SharedModule, + HomeModule, AppRoutingModule, TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useFactory: (HttpLoaderFactory), + useFactory: HttpLoaderFactory, deps: [HttpClient] } }) ], - providers: [ElectronService], + providers: [], bootstrap: [AppComponent] }) -export class AppModule { } +export class AppModule {} diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts new file mode 100644 index 000000000..5425ef7fb --- /dev/null +++ b/src/app/core/core.module.ts @@ -0,0 +1,10 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +@NgModule({ + declarations: [], + imports: [ + CommonModule + ] +}) +export class CoreModule { } diff --git a/src/app/core/services/electron/electron.service.spec.ts b/src/app/core/services/electron/electron.service.spec.ts new file mode 100644 index 000000000..38fe2f0ee --- /dev/null +++ b/src/app/core/services/electron/electron.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { ElectronService } from './electron.service'; + +describe('ElectronService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: ElectronService = TestBed.get(ElectronService); + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/providers/electron.service.ts b/src/app/core/services/electron/electron.service.ts similarity index 91% rename from src/app/providers/electron.service.ts rename to src/app/core/services/electron/electron.service.ts index eac7909dd..411ef54d0 100644 --- a/src/app/providers/electron.service.ts +++ b/src/app/core/services/electron/electron.service.ts @@ -6,18 +6,23 @@ import { ipcRenderer, webFrame, remote } from 'electron'; import * as childProcess from 'child_process'; import * as fs from 'fs'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class ElectronService { - ipcRenderer: typeof ipcRenderer; webFrame: typeof webFrame; remote: typeof remote; childProcess: typeof childProcess; fs: typeof fs; + get isElectron() { + return window && window.process && window.process.type; + } + constructor() { // Conditional imports - if (this.isElectron()) { + if (this.isElectron) { this.ipcRenderer = window.require('electron').ipcRenderer; this.webFrame = window.require('electron').webFrame; this.remote = window.require('electron').remote; @@ -26,9 +31,4 @@ export class ElectronService { this.fs = window.require('fs'); } } - - isElectron = () => { - return window && window.process && window.process.type; - } - } diff --git a/src/app/core/services/index.ts b/src/app/core/services/index.ts new file mode 100644 index 000000000..8102c5af9 --- /dev/null +++ b/src/app/core/services/index.ts @@ -0,0 +1 @@ +export * from './electron/electron.service'; diff --git a/src/app/home/home-routing.module.ts b/src/app/home/home-routing.module.ts new file mode 100644 index 000000000..8160256c3 --- /dev/null +++ b/src/app/home/home-routing.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { Routes, RouterModule } from '@angular/router'; +import { HomeComponent } from './home.component'; + +const routes: Routes = [ + { + path: 'home', + component: HomeComponent + } +]; + +@NgModule({ + declarations: [], + imports: [CommonModule, RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class HomeRoutingModule {} diff --git a/src/app/components/home/home.component.html b/src/app/home/home.component.html similarity index 100% rename from src/app/components/home/home.component.html rename to src/app/home/home.component.html diff --git a/src/app/components/home/home.component.scss b/src/app/home/home.component.scss similarity index 69% rename from src/app/components/home/home.component.scss rename to src/app/home/home.component.scss index cdbd6d33f..e10b7a38f 100644 --- a/src/app/components/home/home.component.scss +++ b/src/app/home/home.component.scss @@ -4,14 +4,13 @@ align-items: center; justify-content: center; - background: url(../../../assets/background.jpg) no-repeat center fixed; + background: url(/assets/background.jpg) no-repeat center fixed; -webkit-background-size: cover; /* pour anciens Chrome et Safari */ background-size: cover; /* version standardisée */ .title { color: white; - margin:0; - padding:50px 20px; + margin: 0; + padding: 50px 20px; } - } diff --git a/src/app/components/home/home.component.spec.ts b/src/app/home/home.component.spec.ts similarity index 76% rename from src/app/components/home/home.component.spec.ts rename to src/app/home/home.component.spec.ts index cd75937ff..583b01d00 100644 --- a/src/app/components/home/home.component.spec.ts +++ b/src/app/home/home.component.spec.ts @@ -9,12 +9,9 @@ describe('HomeComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ HomeComponent ], - imports: [ - TranslateModule.forRoot() - ] - }) - .compileComponents(); + declarations: [HomeComponent], + imports: [TranslateModule.forRoot()] + }).compileComponents(); })); beforeEach(() => { @@ -29,6 +26,8 @@ describe('HomeComponent', () => { it('should render title in a h1 tag', async(() => { const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('PAGES.HOME.TITLE'); + expect(compiled.querySelector('h1').textContent).toContain( + 'PAGES.HOME.TITLE' + ); })); }); diff --git a/src/app/components/home/home.component.ts b/src/app/home/home.component.ts similarity index 100% rename from src/app/components/home/home.component.ts rename to src/app/home/home.component.ts diff --git a/src/app/home/home.module.ts b/src/app/home/home.module.ts new file mode 100644 index 000000000..3bd43bc93 --- /dev/null +++ b/src/app/home/home.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { HomeRoutingModule } from './home-routing.module'; + +import { HomeComponent } from './home.component'; +import { SharedModule } from '../shared/shared.module'; + +@NgModule({ + declarations: [HomeComponent], + imports: [CommonModule, SharedModule, HomeRoutingModule] +}) +export class HomeModule {} diff --git a/src/app/shared/components/index.ts b/src/app/shared/components/index.ts new file mode 100644 index 000000000..88746a9f8 --- /dev/null +++ b/src/app/shared/components/index.ts @@ -0,0 +1 @@ +export * from './page-not-found/page-not-found.component'; diff --git a/src/app/shared/components/page-not-found/page-not-found.component.html b/src/app/shared/components/page-not-found/page-not-found.component.html new file mode 100644 index 000000000..330fbc2d0 --- /dev/null +++ b/src/app/shared/components/page-not-found/page-not-found.component.html @@ -0,0 +1,3 @@ +
+ page-not-found works! +
diff --git a/src/app/shared/components/page-not-found/page-not-found.component.scss b/src/app/shared/components/page-not-found/page-not-found.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/shared/components/page-not-found/page-not-found.component.spec.ts b/src/app/shared/components/page-not-found/page-not-found.component.spec.ts new file mode 100644 index 000000000..697a94657 --- /dev/null +++ b/src/app/shared/components/page-not-found/page-not-found.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PageNotFoundComponent } from './page-not-found.component'; + +describe('PageNotFoundComponent', () => { + let component: PageNotFoundComponent; + let fixture: ComponentFixture