Angular src restructured as modular as per angular official guidelines, .travis.yml support added for node 12
This commit is contained in:
@@ -3,6 +3,7 @@ os:
|
|||||||
- osx
|
- osx
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
|
- '12'
|
||||||
- '11'
|
- '11'
|
||||||
- '10'
|
- '10'
|
||||||
dist: xenial
|
dist: xenial
|
||||||
|
|||||||
9
.vscode/settings.json
vendored
Normal file
9
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"workbench.colorCustomizations": {
|
||||||
|
"activityBar.background": "#c26c93",
|
||||||
|
"activityBar.foreground": "#15202b",
|
||||||
|
"activityBar.inactiveForeground": "#15202b99",
|
||||||
|
"activityBarBadge.background": "#acd08e",
|
||||||
|
"activityBarBadge.foreground": "#15202b"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,7 +35,8 @@
|
|||||||
"electron:mac": "npm run build:prod && electron-builder build --mac",
|
"electron:mac": "npm run build:prod && electron-builder build --mac",
|
||||||
"test": "npm run postinstall:web && ng test",
|
"test": "npm run postinstall:web && ng test",
|
||||||
"e2e": "npm run build:prod && mocha --timeout 300000 --require ts-node/register e2e/**/*.spec.ts",
|
"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": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "0.800.0",
|
"@angular-devkit/build-angular": "0.800.0",
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import { HomeComponent } from './components/home/home.component';
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { Routes, RouterModule } from '@angular/router';
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
import { PageNotFoundComponent } from './shared/components';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: HomeComponent
|
redirectTo: 'home',
|
||||||
|
pathMatch: 'full'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '**',
|
||||||
|
component: PageNotFoundComponent
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -2,21 +2,14 @@ import { TestBed, async } from '@angular/core/testing';
|
|||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { ElectronService } from './providers/electron.service';
|
import { ElectronService } from './core/services';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [
|
declarations: [AppComponent],
|
||||||
AppComponent
|
providers: [ElectronService],
|
||||||
],
|
imports: [RouterTestingModule, TranslateModule.forRoot()]
|
||||||
providers: [
|
|
||||||
ElectronService
|
|
||||||
],
|
|
||||||
imports: [
|
|
||||||
RouterTestingModule,
|
|
||||||
TranslateModule.forRoot()
|
|
||||||
]
|
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -28,6 +21,5 @@ describe('AppComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
class TranslateServiceStub {
|
class TranslateServiceStub {
|
||||||
setDefaultLang(lang: string): void {
|
setDefaultLang(lang: string): void {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ElectronService } from './providers/electron.service';
|
import { ElectronService } from './core/services';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { AppConfig } from '../environments/environment';
|
import { AppConfig } from '../environments/environment';
|
||||||
|
|
||||||
@@ -9,13 +9,14 @@ import { AppConfig } from '../environments/environment';
|
|||||||
styleUrls: ['./app.component.scss']
|
styleUrls: ['./app.component.scss']
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
constructor(public electronService: ElectronService,
|
constructor(
|
||||||
private translate: TranslateService) {
|
public electronService: ElectronService,
|
||||||
|
private translate: TranslateService
|
||||||
|
) {
|
||||||
translate.setDefaultLang('en');
|
translate.setDefaultLang('en');
|
||||||
console.log('AppConfig', AppConfig);
|
console.log('AppConfig', AppConfig);
|
||||||
|
|
||||||
if (electronService.isElectron()) {
|
if (electronService.isElectron) {
|
||||||
console.log('Mode electron');
|
console.log('Mode electron');
|
||||||
console.log('Electron ipcRenderer', electronService.ipcRenderer);
|
console.log('Electron ipcRenderer', electronService.ipcRenderer);
|
||||||
console.log('NodeJS childProcess', electronService.childProcess);
|
console.log('NodeJS childProcess', electronService.childProcess);
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import '../polyfills';
|
import '../polyfills';
|
||||||
|
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { HttpClientModule, HttpClient } from '@angular/common/http';
|
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';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
|
||||||
@@ -12,12 +14,9 @@ import { AppRoutingModule } from './app-routing.module';
|
|||||||
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
|
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
|
||||||
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
||||||
|
|
||||||
import { ElectronService } from './providers/electron.service';
|
import { HomeModule } from './home/home.module';
|
||||||
|
|
||||||
import { WebviewDirective } from './directives/webview.directive';
|
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { HomeComponent } from './components/home/home.component';
|
|
||||||
|
|
||||||
// AoT requires an exported function for factories
|
// AoT requires an exported function for factories
|
||||||
export function HttpLoaderFactory(http: HttpClient) {
|
export function HttpLoaderFactory(http: HttpClient) {
|
||||||
@@ -25,25 +24,24 @@ export function HttpLoaderFactory(http: HttpClient) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [AppComponent],
|
||||||
AppComponent,
|
|
||||||
HomeComponent,
|
|
||||||
WebviewDirective
|
|
||||||
],
|
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
|
CoreModule,
|
||||||
|
SharedModule,
|
||||||
|
HomeModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useFactory: (HttpLoaderFactory),
|
useFactory: HttpLoaderFactory,
|
||||||
deps: [HttpClient]
|
deps: [HttpClient]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
providers: [ElectronService],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|||||||
10
src/app/core/core.module.ts
Normal file
10
src/app/core/core.module.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [],
|
||||||
|
imports: [
|
||||||
|
CommonModule
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class CoreModule { }
|
||||||
12
src/app/core/services/electron/electron.service.spec.ts
Normal file
12
src/app/core/services/electron/electron.service.spec.ts
Normal file
@@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -6,18 +6,23 @@ import { ipcRenderer, webFrame, remote } from 'electron';
|
|||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'child_process';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
export class ElectronService {
|
export class ElectronService {
|
||||||
|
|
||||||
ipcRenderer: typeof ipcRenderer;
|
ipcRenderer: typeof ipcRenderer;
|
||||||
webFrame: typeof webFrame;
|
webFrame: typeof webFrame;
|
||||||
remote: typeof remote;
|
remote: typeof remote;
|
||||||
childProcess: typeof childProcess;
|
childProcess: typeof childProcess;
|
||||||
fs: typeof fs;
|
fs: typeof fs;
|
||||||
|
|
||||||
|
get isElectron() {
|
||||||
|
return window && window.process && window.process.type;
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// Conditional imports
|
// Conditional imports
|
||||||
if (this.isElectron()) {
|
if (this.isElectron) {
|
||||||
this.ipcRenderer = window.require('electron').ipcRenderer;
|
this.ipcRenderer = window.require('electron').ipcRenderer;
|
||||||
this.webFrame = window.require('electron').webFrame;
|
this.webFrame = window.require('electron').webFrame;
|
||||||
this.remote = window.require('electron').remote;
|
this.remote = window.require('electron').remote;
|
||||||
@@ -26,9 +31,4 @@ export class ElectronService {
|
|||||||
this.fs = window.require('fs');
|
this.fs = window.require('fs');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isElectron = () => {
|
|
||||||
return window && window.process && window.process.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
1
src/app/core/services/index.ts
Normal file
1
src/app/core/services/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './electron/electron.service';
|
||||||
18
src/app/home/home-routing.module.ts
Normal file
18
src/app/home/home-routing.module.ts
Normal file
@@ -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 {}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: 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 */
|
-webkit-background-size: cover; /* pour anciens Chrome et Safari */
|
||||||
background-size: cover; /* version standardisée */
|
background-size: cover; /* version standardisée */
|
||||||
|
|
||||||
@@ -13,5 +13,4 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 50px 20px;
|
padding: 50px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,11 +10,8 @@ describe('HomeComponent', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [HomeComponent],
|
declarations: [HomeComponent],
|
||||||
imports: [
|
imports: [TranslateModule.forRoot()]
|
||||||
TranslateModule.forRoot()
|
}).compileComponents();
|
||||||
]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -29,6 +26,8 @@ describe('HomeComponent', () => {
|
|||||||
|
|
||||||
it('should render title in a h1 tag', async(() => {
|
it('should render title in a h1 tag', async(() => {
|
||||||
const compiled = fixture.debugElement.nativeElement;
|
const compiled = fixture.debugElement.nativeElement;
|
||||||
expect(compiled.querySelector('h1').textContent).toContain('PAGES.HOME.TITLE');
|
expect(compiled.querySelector('h1').textContent).toContain(
|
||||||
|
'PAGES.HOME.TITLE'
|
||||||
|
);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
13
src/app/home/home.module.ts
Normal file
13
src/app/home/home.module.ts
Normal file
@@ -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 {}
|
||||||
1
src/app/shared/components/index.ts
Normal file
1
src/app/shared/components/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './page-not-found/page-not-found.component';
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<p>
|
||||||
|
page-not-found works!
|
||||||
|
</p>
|
||||||
@@ -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<PageNotFoundComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ PageNotFoundComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(PageNotFoundComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-page-not-found',
|
||||||
|
templateUrl: './page-not-found.component.html',
|
||||||
|
styleUrls: ['./page-not-found.component.scss']
|
||||||
|
})
|
||||||
|
export class PageNotFoundComponent implements OnInit {
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
ngOnInit() {}
|
||||||
|
}
|
||||||
1
src/app/shared/directives/index.ts
Normal file
1
src/app/shared/directives/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './webview/webview.directive';
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { WebviewDirective } from './webview.directive';
|
||||||
|
|
||||||
|
describe('WebviewDirective', () => {
|
||||||
|
it('should create an instance', () => {
|
||||||
|
const directive = new WebviewDirective();
|
||||||
|
expect(directive).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
import { Directive } from '@angular/core';
|
import { Directive } from '@angular/core';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: 'webview'
|
selector: '[webview]'
|
||||||
})
|
})
|
||||||
export class WebviewDirective {
|
export class WebviewDirective {
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
}
|
}
|
||||||
14
src/app/shared/shared.module.ts
Normal file
14
src/app/shared/shared.module.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
|
import { PageNotFoundComponent } from './components/';
|
||||||
|
import { WebviewDirective } from './directives/';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [PageNotFoundComponent, WebviewDirective],
|
||||||
|
imports: [CommonModule, TranslateModule],
|
||||||
|
exports: [TranslateModule, WebviewDirective]
|
||||||
|
})
|
||||||
|
export class SharedModule {}
|
||||||
Reference in New Issue
Block a user