@tech4good/angular-schematics 13.4.0 → 13.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tech4good/angular-schematics",
3
- "version": "13.4.0",
3
+ "version": "13.6.0",
4
4
  "description": "A set of schematics for generating modules, containers, components, and entities",
5
5
  "scripts": {
6
6
  "build": "tsc -p tsconfig.json",
@@ -5,9 +5,8 @@ name: Angular Github CI
5
5
 
6
6
  on:
7
7
  push:
8
- branches: [ master ]
8
+ branches: [ master, main ]
9
9
  pull_request:
10
- branches: [ master ]
11
10
 
12
11
  jobs:
13
12
  build:
@@ -0,0 +1,55 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+
3
+ # compiled output
4
+ /dist
5
+ /tmp
6
+ /out-tsc
7
+ # Only exists if Bazel was run
8
+ /bazel-out
9
+
10
+ # dependencies
11
+ /node_modules
12
+
13
+ # profiling files
14
+ chrome-profiler-events*.json
15
+ speed-measure-plugin*.json
16
+
17
+ # IDEs and editors
18
+ /.idea
19
+ .project
20
+ .classpath
21
+ .c9/
22
+ *.launch
23
+ .settings/
24
+ *.sublime-workspace
25
+
26
+ # IDE - VSCode
27
+ .vscode/*
28
+ !.vscode/settings.json
29
+ !.vscode/tasks.json
30
+ !.vscode/launch.json
31
+ !.vscode/extensions.json
32
+ .history/*
33
+
34
+ # misc
35
+ .cache
36
+ /.sass-cache
37
+ /connect.lock
38
+ /coverage
39
+ /libpeerconnection.log
40
+ npm-debug.log
41
+ yarn-error.log
42
+ testem.log
43
+ /typings
44
+ *.swp
45
+ .angular
46
+ .cache
47
+
48
+ # System Files
49
+ .DS_Store
50
+ Thumbs.db
51
+
52
+ # Firebase
53
+ .firebase
54
+ *-debug.log
55
+ .runtimeconfig.json
@@ -16,7 +16,7 @@
16
16
  "schematics": {
17
17
  "@schematics/angular:component": {
18
18
  "style": "scss"
19
- },
19
+ }
20
20
  },
21
21
  "root": "",
22
22
  "sourceRoot": "src",
@@ -28,7 +28,7 @@
28
28
  "@ngrx/router-store": "^13.1.0",
29
29
  "@ngrx/store": "^13.1.0",
30
30
  "@ngrx/store-devtools": "^13.1.0",
31
- "@tech4good/angular-schematics": "^13.1.0",
31
+ "@tech4good/angular-schematics": "^13.5.0",
32
32
  "rxjs": "~7.5.0",
33
33
  "tslib": "^2.3.0",
34
34
  "zone.js": "~0.11.4"
@@ -1,3 +1,4 @@
1
1
  <div class="content-container">
2
+ <app-redeployment-warning></app-redeployment-warning>
2
3
  <router-outlet></router-outlet>
3
4
  </div>
@@ -1,4 +1,11 @@
1
1
  .content-container {
2
2
  height: 100%;
3
3
  width: 100%;
4
+ position: relative;
5
+
6
+ app-redeployment-warning {
7
+ position: fixed;
8
+ top: 15px;
9
+ right: 15px;
10
+ }
4
11
  }
@@ -5,6 +5,7 @@ import * as fromStore from './core/store/app.reducer';
5
5
  import { LoadAuth } from './core/store/auth/auth.actions';
6
6
  import { RoutingStateService } from './core/router/routing-state.service';
7
7
  import { TimeAnalyticsService } from './core/analytics/time-analytics.service';
8
+ import { DetectRedeploymentService } from './shared/components/redeployment-warning/redeployment-warning.service';
8
9
 
9
10
  @Component({
10
11
  selector: 'app-root',
@@ -17,6 +18,7 @@ export class AppComponent implements OnInit {
17
18
  private routingState: RoutingStateService,
18
19
  private store: Store<fromStore.State>,
19
20
  private analytics: TimeAnalyticsService,
21
+ private detectRedeployment: DetectRedeploymentService,
20
22
  ) {
21
23
  }
22
24
 
@@ -37,5 +39,8 @@ export class AppComponent implements OnInit {
37
39
  }
38
40
  document.getElementsByClassName('content-container')[0].scrollTop = 0;
39
41
  });
42
+
43
+ // Continually check whether a new app version has been deployed.
44
+ this.detectRedeployment.init();
40
45
  }
41
46
  }
@@ -11,14 +11,14 @@ export class MainAngularFirestore extends AngularFirestore { }
11
11
  @Injectable()
12
12
  export class LoggingAngularFirestore extends AngularFirestore { }
13
13
 
14
- export function MainAngularFirestoreFactory(platformId: Object, zone: NgZone): MainAngularFirestore {
14
+ export function MainAngularFirestoreFactory(platformId: Record<string, unknown>, zone: NgZone): MainAngularFirestore {
15
15
  const schedulers = new ɵAngularFireSchedulers(zone);
16
16
  const auth = new AngularFireAuth(environment.firebase, 'mainAuth', platformId, zone, schedulers, null, null, null, null, null, null, new AppCheckInstances());
17
17
 
18
18
  return new MainAngularFirestore(environment.firebase, 'main', true, {}, platformId, zone, schedulers, {}, null, auth, null, null, null, null, null, null, new AppCheckInstances());
19
19
  }
20
20
 
21
- export function LoggingAngularFirestoreFactory(platformId: Object, zone: NgZone): LoggingAngularFirestore {
21
+ export function LoggingAngularFirestoreFactory(platformId: Record<string, unknown>, zone: NgZone): LoggingAngularFirestore {
22
22
  const schedulers = new ɵAngularFireSchedulers(zone);
23
23
  const auth = new AngularFireAuth(environment.firebase, 'loggingAuth', platformId, zone, schedulers, null, null, null, null, null, null, new AppCheckInstances());
24
24
  return new LoggingAngularFirestore(environment.firebaseLogs, 'logging', true, {}, platformId, zone, schedulers, {}, null, auth, null, null, null, null, null, null, new AppCheckInstances());
@@ -0,0 +1,10 @@
1
+ <div
2
+ class="warning-container"
3
+ *ngIf="showRedeploymentWarning"
4
+ >
5
+ <div class="header">
6
+ <div class="title">This version is out of date!</div>
7
+ <img (click)="close()" src="/assets/img/close-x.svg" />
8
+ </div>
9
+ <button (click)="update()" class="update">Update Now</button>
10
+ </div>
@@ -0,0 +1,46 @@
1
+ :host {
2
+ z-index: 100;
3
+
4
+ .warning-container {
5
+ padding: 10px 13px;
6
+ display: flex;
7
+ flex-direction: column;
8
+ width: 350px;
9
+ height: 63px;
10
+ background: #fff;
11
+ border-radius: 5px;
12
+ border: 1px solid #999;
13
+ box-shadow: 0px 1px 4px #999;
14
+
15
+ .header {
16
+ display: flex;
17
+ width: 100%;
18
+
19
+ .title {
20
+ text-transform: uppercase;
21
+ color: #283262;
22
+ font-weight: bold;
23
+ font-size: 13px;
24
+ }
25
+
26
+ img {
27
+ cursor: pointer;
28
+ margin-left: auto;
29
+ }
30
+ }
31
+
32
+ button {
33
+ margin-top: auto;
34
+ border: none;
35
+ padding: 0;
36
+ width: fit-content;
37
+ outline: 0;
38
+ font-weight: bold;
39
+ font-size: 13px;
40
+ text-decoration-line: underline;
41
+ background: none;
42
+ text-transform: capitalize;
43
+ cursor: pointer;
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,24 @@
1
+ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { RedeploymentWarningComponent } from './redeployment-warning.component';
4
+
5
+ describe('RedeploymentWarningComponent', () => {
6
+ let component: RedeploymentWarningComponent;
7
+ let fixture: ComponentFixture<RedeploymentWarningComponent>;
8
+
9
+ beforeEach(waitForAsync(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [RedeploymentWarningComponent],
12
+ }).compileComponents();
13
+ }));
14
+
15
+ beforeEach(() => {
16
+ fixture = TestBed.createComponent(RedeploymentWarningComponent);
17
+ component = fixture.componentInstance;
18
+ fixture.detectChanges();
19
+ });
20
+
21
+ it('should create', () => {
22
+ expect(component).toBeTruthy();
23
+ });
24
+ });
@@ -0,0 +1,29 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+ import { DetectRedeploymentService } from './redeployment-warning.service';
3
+
4
+ @Component({
5
+ selector: 'app-redeployment-warning',
6
+ templateUrl: './redeployment-warning.component.html',
7
+ styleUrls: ['./redeployment-warning.component.scss'],
8
+ })
9
+ export class RedeploymentWarningComponent implements OnInit {
10
+ showRedeploymentWarning: boolean = false;
11
+
12
+ constructor(public detectRedeployment: DetectRedeploymentService) {}
13
+
14
+ ngOnInit() {
15
+ this.detectRedeployment.redeployed().subscribe(() => {
16
+ this.showRedeploymentWarning = true;
17
+ });
18
+ }
19
+
20
+ /** Triggers a refresh. */
21
+ update() {
22
+ this.detectRedeployment.refresh();
23
+ }
24
+
25
+ /** Ignores the warning. */
26
+ close() {
27
+ this.showRedeploymentWarning = false;
28
+ }
29
+ }
@@ -0,0 +1,63 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { BehaviorSubject, Observable, interval, Subject, from, ConnectableObservable } from 'rxjs';
3
+ import { startWith, multicast, distinctUntilChanged, tap, skip, map, filter, mergeMap } from 'rxjs/operators';
4
+
5
+ @Injectable({
6
+ providedIn: 'root',
7
+ })
8
+ export class DetectRedeploymentService {
9
+ /** Event stream that emits when an app redeployment is detected. */
10
+ private redeployed$: Observable<void>;
11
+ private initialized$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
12
+
13
+ constructor() {}
14
+
15
+ /** Sets redeployed$ and returns it. */
16
+ public init() {
17
+ // Matches the filename of the main javascript file, which contains the hash in the name
18
+ const regexp = /main[-a-z0-9]*\.([a-f0-9]*)\.js/;
19
+
20
+ const observable: ConnectableObservable<void> = interval(2 * 60 * 1000) // every 2 minutes
21
+ .pipe(
22
+ startWith(0),
23
+ // Fetch index.html with a timestamp query parameter so it definitely doesn't get cached anywhere.
24
+ mergeMap(() => fetch('/index.html?t=' + Date.now())),
25
+ mergeMap((urlResponse) => urlResponse.text()),
26
+ map((responseText) => {
27
+ const m = responseText.match(regexp);
28
+ if (m === null) {
29
+ // Probably running a dev build or something where there's no hash.
30
+ // No biggie, we'll just do nothing.
31
+ return null;
32
+ } else {
33
+ return m[1];
34
+ }
35
+ }),
36
+ filter((val) => !!val),
37
+ // Only emit when there are unique versions
38
+ distinctUntilChanged(),
39
+ // Skip the first starting version so we only get changes
40
+ skip(1),
41
+ // Modeled after example 1 in: https://www.learnrxjs.io/operators/multicasting/multicast.html
42
+ multicast(() => new Subject()),
43
+ ) as ConnectableObservable<void>;
44
+
45
+ observable.connect();
46
+
47
+ this.redeployed$ = observable;
48
+ this.initialized$.next(true);
49
+
50
+ return observable;
51
+ }
52
+
53
+ public redeployed() {
54
+ return this.initialized$.pipe(
55
+ filter((val) => val),
56
+ mergeMap(() => this.redeployed$),
57
+ );
58
+ }
59
+
60
+ public refresh() {
61
+ window.location.reload();
62
+ }
63
+ }
@@ -23,6 +23,7 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
23
23
  // Containers
24
24
 
25
25
  // Components
26
+ import { RedeploymentWarningComponent } from './components/redeployment-warning/redeployment-warning.component';
26
27
 
27
28
  // Pipes
28
29
 
@@ -53,6 +54,7 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
53
54
  declarations: [
54
55
  // Containers
55
56
  // Components
57
+ RedeploymentWarningComponent,
56
58
  // Pipes
57
59
  ],
58
60
  exports: [
@@ -75,6 +77,7 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
75
77
  MatRadioModule,
76
78
  // Containers
77
79
  // Components
80
+ RedeploymentWarningComponent,
78
81
  // Pipes
79
82
  ],
80
83
  })
@@ -0,0 +1,31 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "compileOnSave": false,
4
+ "compilerOptions": {
5
+ "baseUrl": "./",
6
+ "outDir": "./dist/out-tsc",
7
+ "forceConsistentCasingInFileNames": true,
8
+ "noImplicitOverride": true,
9
+ "noPropertyAccessFromIndexSignature": true,
10
+ "noImplicitReturns": true,
11
+ "noFallthroughCasesInSwitch": true,
12
+ "sourceMap": true,
13
+ "declaration": false,
14
+ "downlevelIteration": true,
15
+ "experimentalDecorators": true,
16
+ "moduleResolution": "node",
17
+ "importHelpers": true,
18
+ "target": "es2017",
19
+ "module": "es2020",
20
+ "lib": [
21
+ "es2020",
22
+ "dom"
23
+ ]
24
+ },
25
+ "angularCompilerOptions": {
26
+ "enableI18nLegacyMessageIdFormat": false,
27
+ "strictInjectionParameters": true,
28
+ "strictInputAccessModifiers": true,
29
+ "strictTemplates": true
30
+ }
31
+ }