Updates to angular 9

parent f835ace7
#!/bin/sh
echo "Installing npm modules"
npm install --verbose
npm install
echo "Running tslint"
node_modules/tslint/bin/tslint -c tslint.json -p tsconfig.json
echo "Running unit tests"
......@@ -28,7 +28,8 @@ echo "Generating preview screenshots"
node --experimental-modules GenerateImages.mjs --command=all --host=http://localhost:4711 --root=true
cd /usr/src/app
echo "Purifying css"
npm run purify
# Disabled for now since purifyCSS removes nearly all css with Angular 9
# echo "Purifying css"
# npm run purify
echo "Gzipping app files"
find dist/browser -name "*.*" -type f -print0 | xargs -0 gzip -9 -k
......@@ -28,8 +28,9 @@ fromDir('./dist/browser', /theme-.*\.css$/, function (filename) {
const options = {
output: filename,
minify: true,
minify: false,
info: true,
rejected: true,
};
console.log('-- found: ', filename);
purifycss(content, css, options);
......
import { NgModule } from '@angular/core';
import { AvailableQuizzesComponent } from '../modals/available-quizzes/available-quizzes.component';
import { ModalsModule } from '../modals/modals.module';
import { SharedModule } from '../shared/shared.module';
import { HeaderComponent } from './header/header.component';
@NgModule({
imports: [
ModalsModule,
SharedModule,
ModalsModule, SharedModule,
],
exports: [
HeaderComponent,
......@@ -15,7 +13,6 @@ import { HeaderComponent } from './header/header.component';
declarations: [HeaderComponent],
providers: [],
bootstrap: [HeaderComponent],
entryComponents: [AvailableQuizzesComponent],
})
export class HeaderModule {
}
import { HttpClient } from '@angular/common/http';
import { TranslateCompiler } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import MessageFormat from 'messageformat';
import { MessageFormatConfig, TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
// AoT requires an exported function for factories
export function createTranslateLoader(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
export function createTranslateCompiler(): TranslateCompiler {
return new TranslateMessageFormatCompiler(new MessageFormat() as MessageFormatConfig);
}
......@@ -13,7 +13,6 @@ import { ServerUnavailableModalComponent } from './server-unavailable-modal/serv
declarations: [
AvailableQuizzesComponent, AddModeComponent, AddUserComponent, QuizSaveComponent, ServerUnavailableModalComponent,
],
entryComponents: [AvailableQuizzesComponent, AddModeComponent, AddUserComponent, QuizSaveComponent, ServerUnavailableModalComponent],
exports: [AvailableQuizzesComponent, AddModeComponent, AddUserComponent, QuizSaveComponent, ServerUnavailableModalComponent],
})
export class ModalsModule {
......
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { TranslateService } from '@ngx-translate/core';
......@@ -61,7 +60,7 @@ describe('QuizFlow: ConfidenceRateComponent', () => {
},
],
declarations: [ConfidenceRateComponent, ServerUnavailableModalComponent],
}).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [ServerUnavailableModalComponent] } }).compileComponents();
}).compileComponents();
}));
beforeEach(async(() => {
......
......@@ -2,7 +2,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID, SecurityContext } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { DomSanitizer } from '@angular/platform-browser';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
......@@ -74,7 +73,7 @@ describe('LeaderboardComponent', () => {
},
],
declarations: [LeaderboardComponent, ServerUnavailableModalComponent],
}).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [ServerUnavailableModalComponent] } }).compileComponents();
}).compileComponents();
}));
beforeEach(async(() => {
......
......@@ -2,7 +2,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { SecurityContext, TemplateRef } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { DomSanitizer } from '@angular/platform-browser';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { NgbModal, NgbModalRef, NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
......@@ -76,7 +75,7 @@ describe('QuizLobbyComponent', () => {
}, SimpleMQ,
],
declarations: [QuizLobbyComponent, ServerUnavailableModalComponent],
}).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [ServerUnavailableModalComponent] } }).compileComponents();
}).compileComponents();
}));
beforeEach(async(() => {
......@@ -97,7 +96,9 @@ describe('QuizLobbyComponent', () => {
const modalContent = '<div></div>' as unknown as TemplateRef<any>;
const nickToRemove = 'TestNick';
spyOn(modalService, 'open').and.callFake(() => ({} as NgbModalRef));
spyOn(modalService, 'open').and.callFake(() => (
{} as NgbModalRef
));
component.openKickMemberModal(modalContent, nickToRemove);
......@@ -113,7 +114,11 @@ describe('QuizLobbyComponent', () => {
spyOn(component, 'kickMember').and.callThrough();
component.openKickMemberModal(modalContent, nickToRemove);
((async () => await component.kickMember(nickToRemove))());
(
(
async () => await component.kickMember(nickToRemove)
)()
);
expect(component.kickMember).toHaveBeenCalled();
}));
......
......@@ -2,7 +2,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { DomSanitizer } from '@angular/platform-browser';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
......@@ -72,7 +71,7 @@ describe('QuestionDetailsComponent', () => {
}, SimpleMQ,
],
declarations: [QuestionDetailsComponent, ServerUnavailableModalComponent],
}).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [ServerUnavailableModalComponent] } }).compileComponents();
}).compileComponents();
}));
beforeEach(async(() => {
......
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { TranslateService } from '@ngx-translate/core';
......@@ -87,9 +86,12 @@ describe('QuizResultsComponent', () => {
ProgressBarRangedComponent,
ProgressBarFreetextComponent,
ReadingConfirmationProgressComponent,
QuizResultsComponent, ProgressBarAnonymousComponent, VotingQuestionComponent, ServerUnavailableModalComponent,
QuizResultsComponent,
ProgressBarAnonymousComponent,
VotingQuestionComponent,
ServerUnavailableModalComponent,
],
}).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [ServerUnavailableModalComponent] } }).compileComponents();
}).compileComponents();
}));
beforeEach(async(inject([QuizService], (quizService: QuizService) => {
......
......@@ -2,7 +2,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID, SecurityContext } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { DomSanitizer } from '@angular/platform-browser';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
......@@ -66,7 +65,7 @@ describe('QuizFlow: ReadingConfirmationComponent', () => {
}, SimpleMQ,
],
declarations: [ReadingConfirmationComponent, ServerUnavailableModalComponent],
}).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [ServerUnavailableModalComponent] } }).compileComponents();
}).compileComponents();
}));
beforeEach(async(() => {
......
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { FaIconLibrary, FontAwesomeModule } from '@fortawesome/angular-fontawesome';
......@@ -65,7 +64,7 @@ describe('VotingComponent', () => {
}, MemberApiService, QuizApiService, SimpleMQ, QuestionTextService, HeaderLabelService,
],
declarations: [VotingComponent, VotingQuestionComponent, ServerUnavailableModalComponent, TranslatePipeMock],
}).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [ServerUnavailableModalComponent] } }).compileComponents();
}).compileComponents();
}));
beforeEach(async(() => {
......
......@@ -72,14 +72,18 @@ const quizManagerRoutes: Routes = [
@NgModule({
imports: [
FormsModule,
SharedModule, QuizManagerDetailsModule, MarkdownBarModule,
SharedModule,
QuizManagerDetailsModule,
MarkdownBarModule,
LivePreviewModule,
RouterModule.forChild(quizManagerRoutes), PipesModule, MarkdownModule.forChild(), InfiniteScrollModule,
RouterModule.forChild(quizManagerRoutes),
PipesModule,
MarkdownModule.forChild(),
InfiniteScrollModule,
],
declarations: [
QuizManagerComponent, NicknameManagerComponent, SoundManagerComponent, MemberGroupManagerComponent, QuizTypeSelectModalComponent,
],
entryComponents: [QuizTypeSelectModalComponent],
})
export class QuizManagerModule {
}
......@@ -12,13 +12,12 @@ import { Angulartics2Module } from 'angulartics2';
import { SimpleMQ } from 'ng2-simple-mq';
import { MarkdownModule, MarkedOptions, MarkedRenderer } from 'ngx-markdown';
import { ToastrModule } from 'ngx-toastr';
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
import { environment } from '../environments/environment';
import { FooterModule } from './footer/footer.module';
import { HeaderModule } from './header/header.module';
import { jwtOptionsFactory } from './lib/jwt.factory';
import { RoutePreloader } from './lib/route-preloader';
import { createTranslateLoader } from './lib/translation.factory';
import { createTranslateCompiler, createTranslateLoader } from './lib/translation.factory';
import { ModalsModule } from './modals/modals.module';
import { PipesModule } from './pipes/pipes.module';
import { HomeComponent } from './root/home/home.component';
......@@ -126,18 +125,23 @@ export function markedOptionsFactory(): MarkedOptions {
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
useFactory: (
createTranslateLoader
),
deps: [HttpClient],
},
compiler: {
provide: TranslateCompiler,
useClass: TranslateMessageFormatCompiler,
useFactory: (
createTranslateCompiler
),
},
}),
RouterModule.forRoot(appRoutes, {
preloadingStrategy: RoutePreloader,
enableTracing: false, // <-- debugging purposes only
}), FooterModule,
}),
FooterModule,
SharedModule,
Angulartics2Module.forRoot(),
JwtModule.forRoot({
......@@ -146,10 +150,16 @@ export function markedOptionsFactory(): MarkedOptions {
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},
}), PipesModule, HeaderModule, HttpClientModule, MarkdownModule.forRoot({
}),
PipesModule,
HeaderModule,
HttpClientModule,
MarkdownModule.forRoot({
markedOptions: {
provide: MarkedOptions,
useFactory: (markedOptionsFactory),
useFactory: (
markedOptionsFactory
),
},
}),
],
......
......@@ -85,7 +85,6 @@ import { NoDataErrorComponent } from './no-data-error/no-data-error.component';
],
providers: [TranslateStore],
declarations: [AudioPlayerComponent, GamificationAnimationComponent, NoDataErrorComponent],
entryComponents: [NoDataErrorComponent],
bootstrap: [],
})
export class SharedModule {
......
......@@ -9,7 +9,6 @@
"polyfills.ts"
],
"angularCompilerOptions": {
"enableIvy": false,
"generateDeepReexports": true
},
"include": [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment