@tech4good/angular-schematics 0.0.2 → 13.1.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/README.md +46 -46
- package/package.json +27 -27
- package/src/collection.json +25 -25
- package/src/component/files/__name@dasherize__/__name@dasherize__.animations.ts.template +4 -0
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.html.template +3 -0
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.scss.template +7 -0
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +25 -0
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +30 -0
- package/src/component/index.d.ts +2 -2
- package/src/component/index.js +93 -102
- package/src/component/index.js.map +1 -1
- package/src/component/index_spec.d.ts +1 -1
- package/src/component/index_spec.js +22 -22
- package/src/component/schema.json +47 -29
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +27 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +47 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.model.ts.template +0 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +20 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.state.ts.template +13 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.animations.ts.template +4 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.html.template +3 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.scss.template +5 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +25 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +81 -0
- package/src/container/index.d.ts +2 -2
- package/src/container/index.js +115 -282
- package/src/container/index.js.map +1 -1
- package/src/container/index_spec.d.ts +1 -1
- package/src/container/index_spec.js +22 -22
- package/src/container/schema.json +47 -24
- package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +270 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +131 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +7 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +13 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +51 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.service.ts.template +50 -0
- package/src/entity/index.d.ts +2 -2
- package/src/entity/index.js +123 -524
- package/src/entity/index.js.map +1 -1
- package/src/entity/index_spec.d.ts +1 -1
- package/src/entity/index_spec.js +22 -22
- package/src/entity/schema.json +42 -19
- package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +13 -0
- package/src/module/files/__name@dasherize__/__name@dasherize__.module.spec.ts.template +13 -0
- package/src/module/files/__name@dasherize__/__name@dasherize__.module.ts.template +24 -0
- package/src/module/index.d.ts +2 -2
- package/src/module/index.js +96 -87
- package/src/module/index.js.map +1 -1
- package/src/module/index_spec.d.ts +1 -1
- package/src/module/index_spec.js +22 -22
- package/src/module/schema.json +38 -19
- package/src/shared/camelcase-formatter.d.ts +1 -1
- package/src/shared/camelcase-formatter.js +18 -18
- package/src/shared/statements-adder.d.ts +8 -5
- package/src/shared/statements-adder.js +52 -31
- package/src/shared/statements-adder.js.map +1 -1
- package/tsconfig.json +34 -34
|
@@ -1,29 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"id": "
|
|
4
|
-
"title": "
|
|
5
|
-
"type": "object",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"name"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "ComponentSchema",
|
|
4
|
+
"title": "Component Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"description": "Creates a new component in the default project.",
|
|
7
|
+
"properties": {
|
|
8
|
+
"index": {
|
|
9
|
+
"type": "number",
|
|
10
|
+
"default": 1
|
|
11
|
+
},
|
|
12
|
+
"path": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"format": "path",
|
|
15
|
+
"description": "The path at which to create the component file, relative to the current workspace. Should be organized according to the view hierarchy to the extent possible.",
|
|
16
|
+
"visible": false
|
|
17
|
+
},
|
|
18
|
+
"project": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The name of the project.",
|
|
21
|
+
"$default": {
|
|
22
|
+
"$source": "projectName"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"name": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "The name of the component.",
|
|
28
|
+
"$default": {
|
|
29
|
+
"$source": "argv",
|
|
30
|
+
"index": 0
|
|
31
|
+
},
|
|
32
|
+
"x-prompt": "What name would you like to use for the component?"
|
|
33
|
+
},
|
|
34
|
+
"module": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "The declaring NgModule.",
|
|
37
|
+
"alias": "m"
|
|
38
|
+
},
|
|
39
|
+
"inDirectory": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"x-prompt": "Are you currently in the directory where you want to generate the component? (please organize your components according to the view hierarchy to the extent possible)"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"required": [
|
|
45
|
+
"name"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Action } from '@ngrx/store';
|
|
2
|
+
|
|
3
|
+
export enum <%= classify(name) %>ActionTypes {
|
|
4
|
+
LOAD_DATA = '[<%= classify(name) %>] load data',
|
|
5
|
+
CLEANUP = '[<%= classify(name) %>] cleanup',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Action for loading required DB data. */
|
|
9
|
+
export class LoadData implements Action {
|
|
10
|
+
readonly type = <%= classify(name) %>ActionTypes.LOAD_DATA;
|
|
11
|
+
|
|
12
|
+
constructor(public payload: {
|
|
13
|
+
containerId: string,
|
|
14
|
+
}) { }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Action for cleaning up loading subscriptions. */
|
|
18
|
+
export class Cleanup implements Action {
|
|
19
|
+
readonly type = <%= classify(name) %>ActionTypes.CLEANUP;
|
|
20
|
+
constructor(public payload: {
|
|
21
|
+
containerId: string,
|
|
22
|
+
}) { }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type <%= classify(name) %>Actions =
|
|
26
|
+
LoadData |
|
|
27
|
+
Cleanup;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Action } from '@ngrx/store';
|
|
3
|
+
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
|
4
|
+
|
|
5
|
+
import { of, Observable } from 'rxjs';
|
|
6
|
+
import { mergeMap, tap, map } from 'rxjs/operators';
|
|
7
|
+
|
|
8
|
+
import { select, Store } from '@ngrx/store';
|
|
9
|
+
import * as fromStore from '../../../core/store/app.reducer';
|
|
10
|
+
import { FirebaseService } from '../../../core/firebase/firebase.service';
|
|
11
|
+
import { EffectsHelpers } from '../../../core/store/effects.helpers';
|
|
12
|
+
import { <%= classify(name) %>State } from './<%= dasherize(name) %>.state';
|
|
13
|
+
|
|
14
|
+
import { ActionFlow, RouterNavigate, LoadAction, Unsubscribe } from '../../../core/store/app.actions';
|
|
15
|
+
import { <%= classify(name) %>ActionTypes, Cleanup, LoadData } from './<%= dasherize(name) %>.actions';
|
|
16
|
+
|
|
17
|
+
@Injectable()
|
|
18
|
+
export class <%= classify(name) %>Effects {
|
|
19
|
+
/** Load data from Firebase. */
|
|
20
|
+
loadData$: Observable<Action> = createEffect(
|
|
21
|
+
() => this.actions$.pipe(
|
|
22
|
+
ofType<LoadData>(<%= classify(name) %>ActionTypes.LOAD_DATA),
|
|
23
|
+
mergeMap((action: LoadData) => {
|
|
24
|
+
const loadId = action.payload.containerId;
|
|
25
|
+
|
|
26
|
+
return [
|
|
27
|
+
];
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
/** Unsubscribe connections from Firebase. */
|
|
33
|
+
cleanup$: Observable<Action> = createEffect(
|
|
34
|
+
() => this.actions$.pipe(
|
|
35
|
+
ofType<Cleanup>(<%= classify(name) %>ActionTypes.CLEANUP),
|
|
36
|
+
map((action: Cleanup) => new Unsubscribe(action.payload.containerId)),
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
constructor(
|
|
41
|
+
private actions$: Actions,
|
|
42
|
+
private store: Store<fromStore.State>,
|
|
43
|
+
private state: <%= classify(name) %>State,
|
|
44
|
+
private db: FirebaseService,
|
|
45
|
+
private eh: EffectsHelpers,
|
|
46
|
+
) {}
|
|
47
|
+
}
|
|
File without changes
|
package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Store, select } from '@ngrx/store';
|
|
3
|
+
import * as fromStore from '../../../core/store/app.reducer';
|
|
4
|
+
import { EntitySelectorService } from '../../../core/store/app.selectors';
|
|
5
|
+
|
|
6
|
+
import { Observable, of, combineLatest } from 'rxjs';
|
|
7
|
+
import { bufferTime, distinctUntilChanged, shareReplay, mergeMap, filter, switchMap, map } from 'rxjs/operators';
|
|
8
|
+
|
|
9
|
+
@Injectable({
|
|
10
|
+
providedIn: 'root',
|
|
11
|
+
})
|
|
12
|
+
export class <%= classify(name) %>Selectors {
|
|
13
|
+
constructor(
|
|
14
|
+
private slRx: EntitySelectorService,
|
|
15
|
+
) { }
|
|
16
|
+
|
|
17
|
+
cleanup(cId: string) {
|
|
18
|
+
this.slRx.release(cId);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { BehaviorSubject } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: 'root',
|
|
7
|
+
})
|
|
8
|
+
export class <%= classify(name) %>State {
|
|
9
|
+
// --------------- LOCAL UI STATE ----------------------
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
) { }
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.component';
|
|
4
|
+
|
|
5
|
+
describe('<%= classify(name) %>Component', () => {
|
|
6
|
+
let component: <%= classify(name) %>Component;
|
|
7
|
+
let fixture: ComponentFixture<<%= classify(name) %>Component>;
|
|
8
|
+
|
|
9
|
+
beforeEach(waitForAsync(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [<%= classify(name) %>Component],
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(<%= classify(name) %>Component);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
|
|
2
|
+
import { <%= classify(name) %>Animations } from './<%= dasherize(name) %>.animations';
|
|
3
|
+
import { ParamMap, ActivatedRoute } from '@angular/router';
|
|
4
|
+
import { Store, select } from '@ngrx/store';
|
|
5
|
+
import * as fromStore from '../../core/store/app.reducer';
|
|
6
|
+
import * as fromAuth from '../../core/store/auth/auth.reducer';
|
|
7
|
+
import { FirebaseService } from '../../core/firebase/firebase.service';
|
|
8
|
+
import { Observable, Subject, BehaviorSubject, combineLatest } from 'rxjs';
|
|
9
|
+
import { withLatestFrom, take, takeUntil } from 'rxjs/operators';
|
|
10
|
+
|
|
11
|
+
import { <%= classify(name) %>State } from './+state/<%= dasherize(name) %>.state';
|
|
12
|
+
import { <%= classify(name) %>Selectors } from './+state/<%= dasherize(name) %>.selectors';
|
|
13
|
+
|
|
14
|
+
import { LoadData, Cleanup } from './+state/<%= dasherize(name) %>.actions';
|
|
15
|
+
import { RouterNavigate } from '../../core/store/app.actions';
|
|
16
|
+
|
|
17
|
+
import { User } from '../../core/store/user/user.model';
|
|
18
|
+
|
|
19
|
+
@Component({
|
|
20
|
+
selector: 'app-<%= dasherize(name) %>',
|
|
21
|
+
templateUrl: './<%= dasherize(name) %>.component.html',
|
|
22
|
+
styleUrls: ['./<%= dasherize(name) %>.component.scss'],
|
|
23
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
24
|
+
animations: <%= classify(name) %>Animations,
|
|
25
|
+
})
|
|
26
|
+
export class <%= classify(name) %>Component implements OnInit, OnDestroy {
|
|
27
|
+
// --------------- ROUTE PARAMS & CURRENT USER ---------
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// --------------- LOCAL UI STATE ----------------------
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// --------------- DB ENTITY DATA ----------------------
|
|
34
|
+
|
|
35
|
+
/** Container id for selectors and loading. */
|
|
36
|
+
containerId: string = this.db.createId();
|
|
37
|
+
|
|
38
|
+
// --------------- DATA BINDING STREAMS ----------------
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// --------------- EVENT BINDING STREAMS ---------------
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// --------------- OTHER -------------------------------
|
|
45
|
+
|
|
46
|
+
/** Unsubscribe observable for subscriptions. */
|
|
47
|
+
unsubscribe$: Subject<void> = new Subject();
|
|
48
|
+
|
|
49
|
+
constructor(
|
|
50
|
+
private state: <%= classify(name) %>State,
|
|
51
|
+
private route: ActivatedRoute,
|
|
52
|
+
private selectors: <%= classify(name) %>Selectors,
|
|
53
|
+
private store: Store<fromStore.State>,
|
|
54
|
+
private db: FirebaseService,
|
|
55
|
+
) {
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
ngOnInit() {
|
|
59
|
+
// --------------- EVENT HANDLING ----------------------
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
// --------------- LOAD DATA ---------------------------
|
|
63
|
+
|
|
64
|
+
// Once everything is set up, load the data for the role.
|
|
65
|
+
this.store.dispatch( new LoadData({
|
|
66
|
+
containerId: this.containerId,
|
|
67
|
+
}) );
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
ngOnDestroy() {
|
|
71
|
+
// Unsubscribe subscriptions.
|
|
72
|
+
this.unsubscribe$.next();
|
|
73
|
+
this.unsubscribe$.complete();
|
|
74
|
+
|
|
75
|
+
// Unsubscribe from firebase connection from load and free up memoized selector values.
|
|
76
|
+
this.store.dispatch( new Cleanup({
|
|
77
|
+
containerId: this.containerId,
|
|
78
|
+
}) );
|
|
79
|
+
this.selectors.cleanup(this.containerId);
|
|
80
|
+
}
|
|
81
|
+
}
|
package/src/container/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
-
export declare function container(
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
+
export declare function container(options: any): Rule;
|