@tech4good/angular-schematics 21.2.0 → 21.4.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/.t4g/agent-memory.db +0 -0
- package/CHANGELOG.md +33 -0
- package/package.json +1 -1
- package/src/entity/index.js +42 -9
- package/src/entity/index.js.map +1 -1
- package/src/entity/index_spec.js +42 -8
- package/src/entity/index_spec.js.map +1 -1
- package/src/entity/schema.json +0 -5
- package/src/ng-add/files/.gitignore.template +1 -0
- package/src/ng-add/files/angular.json.template +3 -0
- package/src/ng-add/files/firestore.rules.spec.ts.template +88 -1
- package/src/ng-add/files/firestore.rules.template +9 -0
- package/src/ng-add/files/package.json.template +4 -2
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.spec.ts.template +3 -3
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.spec.ts.template +0 -1
- package/src/ng-add/files/src/app/app.component.html.template +1 -1
- package/src/ng-add/files/src/app/app.component.scss.template +9 -1
- package/src/ng-add/files/src/app/app.component.spec.ts.template +2 -2
- package/src/ng-add/files/src/app/auth-routing.spec.ts.template +1 -1
- package/src/ng-add/files/src/app/core/analytics/log.service.ts.template +1 -1
- package/src/ng-add/files/src/app/core/analytics/time-analytics.service.spec.ts.template +2 -2
- package/src/ng-add/files/src/app/core/firebase/cached-listeners.service.ts.template +53 -51
- package/src/ng-add/files/src/app/core/firebase/firebase.mock.service.ts.template +6 -0
- package/src/ng-add/files/src/app/core/firebase/simulate-load.spec.ts.template +2 -2
- package/src/ng-add/files/src/app/core/firebase/simulate-stream.spec.ts.template +14 -14
- package/src/ng-add/files/src/app/core/firebase/stream-multiplexer.ts.template +50 -48
- package/src/ng-add/files/src/app/core/logging/logging.service.spec.ts.template +118 -0
- package/src/ng-add/files/src/app/core/logging/logging.service.ts.template +168 -0
- package/src/ng-add/files/src/app/core/store/app.model.ts.template +3 -1
- package/src/ng-add/files/src/app/core/store/app.store.ts.template +11 -9
- package/src/ng-add/files/src/app/core/store/auth/auth.mock.ts.template +5 -4
- package/src/ng-add/files/src/app/core/store/auth/auth.store.ts.template +13 -4
- package/src/ng-add/files/src/app/core/store/user/user.mock.ts.template +0 -4
- package/src/ng-add/files/src/app/core/store/user/user.model.ts.template +0 -1
- package/src/ng-add/files/src/app/core/store/user-private/user-private.mock.ts.template +15 -0
- package/src/ng-add/files/src/app/core/store/user-private/user-private.model.ts.template +9 -0
- package/src/ng-add/files/src/app/core/store/user-private/user-private.store.ts.template +41 -0
- package/src/ng-add/files/src/app/first-time/early-access/early-access.component.spec.ts.template +0 -1
- package/src/ng-add/files/src/app/first-time/early-access/early-access.component.ts.template +1 -1
- package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.ts.template +3 -3
- package/src/ng-add/files/src/app/first-time/landing/landing.component.scss.template +1 -1
- package/src/ng-add/files/src/app/first-time/onboarding/onboarding.component.ts.template +3 -3
- package/src/ng-add/files/src/app/main/home/home.component.spec.ts.template +1 -1
- package/src/ng-add/files/src/app/main/home/home.component.ts.template +4 -4
- package/src/ng-add/files/src/app/shared/dev-status-bar/dev-status-bar.component.scss.template +1 -0
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.spec.ts.template +41 -5
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.ts.template +25 -2
- package/src/ng-add/files/src/environments/environment.test.ts.template +1 -1
- package/src/ng-add/files/src/styles/_cdk-overrides.scss.template +50 -0
- package/src/ng-add/files/src/styles.scss.template +1 -0
- package/src/shared/statements-adder.d.ts +1 -0
- package/src/shared/statements-adder.js +8 -0
- package/src/shared/statements-adder.js.map +1 -1
- package/src/ng-add/files/src/app/core/firebase/query-logger.ts.template +0 -11
- package/tech4good-angular-schematics-21.0.0.tgz +0 -0
|
@@ -11,16 +11,16 @@ import { NavbarComponent } from 'src/app/shared/navbar/navbar.component';
|
|
|
11
11
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
12
12
|
imports: [
|
|
13
13
|
NavbarComponent,
|
|
14
|
-
]
|
|
14
|
+
],
|
|
15
15
|
})
|
|
16
16
|
export class HomeComponent implements OnInit {
|
|
17
17
|
authStore = inject(AuthStore);
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
// --------------- INPUTS AND OUTPUTS ------------------
|
|
20
20
|
|
|
21
21
|
/** The currently signed in user. */
|
|
22
22
|
currentUser: Signal<User> = this.authStore.user;
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
// --------------- LOCAL UI STATE ----------------------
|
|
25
25
|
|
|
26
26
|
// --------------- COMPUTED DATA -----------------------
|
|
@@ -46,7 +46,7 @@ export class HomeComponent implements OnInit {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// --------------- LOAD AND CLEANUP --------------------
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
ngOnInit() {
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -58,14 +58,14 @@ describe('DetectRedeploymentService', () => {
|
|
|
58
58
|
it('should gracefully handle network errors without killing the polling interval', async () => {
|
|
59
59
|
// Force a network error for the first fetch
|
|
60
60
|
fetchSpy.mockRejectedValueOnce(new Error('Network error'));
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
// Start the interval
|
|
63
63
|
service.init();
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
// First tick encounters the network error, which is caught and returns null, keeping the interval alive
|
|
66
|
-
jest.advanceTimersByTime(1);
|
|
66
|
+
jest.advanceTimersByTime(1);
|
|
67
67
|
await Promise.resolve();
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
expect(fetchSpy).toHaveBeenCalledTimes(1);
|
|
70
70
|
fetchSpy.mockClear();
|
|
71
71
|
|
|
@@ -79,8 +79,44 @@ describe('DetectRedeploymentService', () => {
|
|
|
79
79
|
// The interval is still alive! Advance time to the next 2-minute mark
|
|
80
80
|
jest.advanceTimersByTime(2 * 60 * 1000);
|
|
81
81
|
await Promise.resolve();
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
// Fetch should be called again, proving the interval survived
|
|
84
84
|
expect(fetchSpy).toHaveBeenCalledTimes(1);
|
|
85
85
|
});
|
|
86
|
+
|
|
87
|
+
it('should detect redeployment immediately on startup if the DOM script hash differs from the fetched index.html', async () => {
|
|
88
|
+
// Inject a script tag into the mock DOM
|
|
89
|
+
const scriptEl = document.createElement('script');
|
|
90
|
+
scriptEl.setAttribute('src', 'main-OLDHASH.js');
|
|
91
|
+
document.body.appendChild(scriptEl);
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
// Mock fetch to return a newer hash
|
|
95
|
+
fetchSpy.mockReturnValue(
|
|
96
|
+
Promise.resolve({
|
|
97
|
+
text: () => Promise.resolve('<script src="main-NEWHASH.js"></script>'),
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
let triggered = false;
|
|
102
|
+
const triggeredPromise = new Promise<void>((resolve) => {
|
|
103
|
+
service.redeployed().subscribe({
|
|
104
|
+
next: () => {
|
|
105
|
+
triggered = true;
|
|
106
|
+
resolve();
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
service.init();
|
|
112
|
+
|
|
113
|
+
// Resolve startup fetch
|
|
114
|
+
jest.advanceTimersByTime(1);
|
|
115
|
+
await triggeredPromise;
|
|
116
|
+
|
|
117
|
+
expect(triggered).toBe(true);
|
|
118
|
+
} finally {
|
|
119
|
+
document.body.removeChild(scriptEl);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
86
122
|
});
|
|
@@ -12,12 +12,31 @@ export class DetectRedeploymentService {
|
|
|
12
12
|
|
|
13
13
|
constructor() {}
|
|
14
14
|
|
|
15
|
+
/** Retrieves the filename of the currently loaded main javascript bundle. */
|
|
16
|
+
private getLoadedMainScript(): string | null {
|
|
17
|
+
if (typeof document === 'undefined') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const scripts = Array.from(document.querySelectorAll('script'));
|
|
21
|
+
for (const script of scripts) {
|
|
22
|
+
const src = script.getAttribute('src');
|
|
23
|
+
if (src) {
|
|
24
|
+
const m = src.match(/main[-a-zA-Z0-9]*\.js/);
|
|
25
|
+
if (m) {
|
|
26
|
+
return m[0];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
15
33
|
/** Sets redeployed$ and returns it. */
|
|
16
34
|
public init() {
|
|
17
35
|
// Matches the filename of the main javascript file, which contains the hash in the name
|
|
18
36
|
const regexp = /main[-a-zA-Z0-9]*\.js/;
|
|
37
|
+
const currentScript = this.getLoadedMainScript();
|
|
19
38
|
|
|
20
|
-
const observable
|
|
39
|
+
const observable = (interval(2 * 60 * 1000) // every 2 minutes
|
|
21
40
|
.pipe(
|
|
22
41
|
startWith(0),
|
|
23
42
|
// Fetch index.html with a timestamp query parameter so it definitely doesn't get cached anywhere.
|
|
@@ -34,6 +53,10 @@ export class DetectRedeploymentService {
|
|
|
34
53
|
}
|
|
35
54
|
}),
|
|
36
55
|
filter((val) => !!val),
|
|
56
|
+
// Prepend the currently loaded script tag if available so that if index.html
|
|
57
|
+
// is updated before loading, we detect it immediately on the first check.
|
|
58
|
+
startWith(currentScript),
|
|
59
|
+
filter((val) => !!val),
|
|
37
60
|
// Only emit when there are unique versions
|
|
38
61
|
distinctUntilChanged(),
|
|
39
62
|
// Skip the first starting version so we only get changes
|
|
@@ -42,7 +65,7 @@ export class DetectRedeploymentService {
|
|
|
42
65
|
map(() => undefined as void),
|
|
43
66
|
// Modeled after example 1 in: https://www.learnrxjs.io/operators/multicasting/multicast.html
|
|
44
67
|
share(),
|
|
45
|
-
);
|
|
68
|
+
) as Observable<void>);
|
|
46
69
|
|
|
47
70
|
observable.subscribe();
|
|
48
71
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// ==========================================================================
|
|
2
|
+
// CDK Overlay Overrides
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
// Styles for content rendered in the CDK overlay container, which lives
|
|
5
|
+
// outside component DOM trees. Component-scoped styles (ViewEncapsulation)
|
|
6
|
+
// cannot reach these elements, so they must be defined globally.
|
|
7
|
+
//
|
|
8
|
+
// This file is generated by the project's ng-add schematics.
|
|
9
|
+
// See angular-material-guide.md MAT-008 for details.
|
|
10
|
+
// ==========================================================================
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// CDK Drag and Drop
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
// The drag preview is rendered in the CDK overlay during a drag operation.
|
|
17
|
+
// Without global styles, it appears as an unstyled clone of the original element.
|
|
18
|
+
.cdk-drag-preview {
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
border-radius: 4px;
|
|
21
|
+
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2),
|
|
22
|
+
0 8px 10px 1px rgba(0, 0, 0, 0.14),
|
|
23
|
+
0 3px 14px 2px rgba(0, 0, 0, 0.12);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// The placeholder is shown in the list where the dragged item was.
|
|
27
|
+
// Setting opacity to 0 hides it, making it look like the item was "picked up".
|
|
28
|
+
.cdk-drag-placeholder {
|
|
29
|
+
opacity: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Smooth animation when an item is dropped into its new position.
|
|
33
|
+
.cdk-drag-animating {
|
|
34
|
+
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// When a cdkDropList is receiving a dragged item, this class is applied.
|
|
38
|
+
// Use it to add a visual indicator (e.g., a subtle background highlight).
|
|
39
|
+
.cdk-drop-list-dragging .cdk-drag:not(.cdk-drag-placeholder) {
|
|
40
|
+
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Add project-specific overlay overrides below
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Examples:
|
|
47
|
+
// - MatDialog custom panel classes
|
|
48
|
+
// - MatMenu custom styling
|
|
49
|
+
// - MatTooltip custom templates
|
|
50
|
+
// - MatSelect / MatAutocomplete dropdown panels
|
|
@@ -5,4 +5,5 @@ export interface IHash {
|
|
|
5
5
|
}
|
|
6
6
|
export declare function getSourceText(host: Tree, filePath: string): string;
|
|
7
7
|
export declare function simpleInsert(sourceText: string, fileToEdit: string, labels: string[], statements: string[]): Change[];
|
|
8
|
+
export declare function insertBefore(sourceText: string, fileToEdit: string, label: string, statement: string): Change;
|
|
8
9
|
export declare function AddStatements(filePath: string, labels: string[], statements: string[], tree: Tree): void;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSourceText = getSourceText;
|
|
4
4
|
exports.simpleInsert = simpleInsert;
|
|
5
|
+
exports.insertBefore = insertBefore;
|
|
5
6
|
exports.AddStatements = AddStatements;
|
|
6
7
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
7
8
|
const change_1 = require("@schematics/angular/utility/change");
|
|
@@ -23,6 +24,13 @@ function simpleInsert(sourceText, fileToEdit, labels, statements) {
|
|
|
23
24
|
return new change_1.InsertChange(fileToEdit, index, `\n${statements[i]}`);
|
|
24
25
|
});
|
|
25
26
|
}
|
|
27
|
+
function insertBefore(sourceText, fileToEdit, label, statement) {
|
|
28
|
+
const index = sourceText.indexOf(label);
|
|
29
|
+
if (index === -1) {
|
|
30
|
+
throw new schematics_1.SchematicsException(`Label "${label}" not found in ${fileToEdit}`);
|
|
31
|
+
}
|
|
32
|
+
return new change_1.InsertChange(fileToEdit, index, statement);
|
|
33
|
+
}
|
|
26
34
|
function AddStatements(filePath, labels, statements, tree) {
|
|
27
35
|
// getSourceText
|
|
28
36
|
let text = tree.read(filePath); // reads the file from the tree
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statements-adder.js","sourceRoot":"","sources":["statements-adder.ts"],"names":[],"mappings":";;AAOA,sCAMC;AAED,oCAWC;AAED,sCAyBG;
|
|
1
|
+
{"version":3,"file":"statements-adder.js","sourceRoot":"","sources":["statements-adder.ts"],"names":[],"mappings":";;AAOA,sCAMC;AAED,oCAWC;AAED,oCAMC;AAED,sCAyBG;AA7DH,2DAAuE;AACvE,+DAA0E;AAM1E,SAAgB,aAAa,CAAC,IAAU,EAAE,QAAgB;IACxD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,gCAAmB,CAAC,QAAQ,QAAQ,kBAAkB,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED,SAAgB,YAAY,CAAC,UAAkB,EAAE,UAAkB,EAAE,MAAgB,EAAE,UAAoB;IAEzG,IAAI,QAAQ,GAAW,EAAE,CAAC;IAC1B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;QAC7B,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,SAAS;YAC/B,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,IAAI,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,KAAK,GAAG,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;QACjE,OAAO,IAAI,qBAAY,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,YAAY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C;QAChC,KAAK,GAAG,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACrE,kBAAkB;QAClB,MAAM,YAAY,GAAG,IAAI,qBAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC7E,cAAc,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;AAEpC,CAAC;AAED,SAAS,WAAW,CAAC,MAAc,EAAE,SAAiB,EAAE,KAAa;IACnE,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;AAC/D,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isDevMode } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
// Flip this to `true` when you want to trace query execution!
|
|
4
|
-
// This will output rich logs for stream multiplexing and load bucketing.
|
|
5
|
-
export const DEBUG_QUERY_SYSTEM = false;
|
|
6
|
-
|
|
7
|
-
export function queryLog(...args: unknown[]) {
|
|
8
|
-
if (isDevMode() && DEBUG_QUERY_SYSTEM) {
|
|
9
|
-
console.log(...args);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
Binary file
|