@tech4good/angular-schematics 13.0.0 → 13.2.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 +10 -10
- package/package.json +1 -1
- package/src/collection.json +9 -4
- 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 +1 -1
- package/src/component/index.js +85 -94
- package/src/component/index.js.map +1 -1
- package/src/component/schema.json +27 -13
- 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 +1 -1
- package/src/container/index.js +106 -273
- package/src/container/index.js.map +1 -1
- package/src/container/schema.json +28 -9
- 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 +1 -1
- package/src/entity/index.js +105 -506
- package/src/entity/index.js.map +1 -1
- package/src/entity/schema.json +25 -6
- package/src/init/files/.eslintrc.json +120 -0
- package/src/init/files/.gitattributes +11 -0
- package/src/init/files/.github/workflows/angular-github-ci.yml.template +60 -0
- package/src/init/files/angular.json.template +132 -0
- package/src/init/files/package.json.template +60 -0
- package/src/init/files/src/app/app.component.html +3 -0
- package/src/init/files/src/app/app.component.scss +4 -0
- package/src/init/files/src/app/general/e404/e404.component.html +1 -0
- package/src/init/files/src/app/general/e404/e404.component.scss +0 -0
- package/src/init/files/src/app/general/login/login.component.html +11 -0
- package/src/init/files/src/app/general/login/login.component.scss +29 -0
- package/src/init/files/src/index.html.template +19 -0
- package/src/init/files/src/styles/_variables.scss +0 -0
- package/src/init/files/src/styles.scss +13 -0
- package/src/init/index.d.ts +2 -0
- package/src/init/index.js +50 -0
- package/src/init/index.js.map +1 -0
- package/src/init/schema.json +28 -0
- 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 +1 -1
- package/src/module/index.js +87 -78
- package/src/module/index.js.map +1 -1
- package/src/module/schema.json +21 -6
- package/src/shared/statements-adder.d.ts +3 -0
- package/src/shared/statements-adder.js +22 -1
- package/src/shared/statements-adder.js.map +1 -1
|
@@ -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
1
|
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
-
export declare function container(
|
|
2
|
+
export declare function container(options: any): Rule;
|
package/src/container/index.js
CHANGED
|
@@ -1,283 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.container = void 0;
|
|
4
|
-
const
|
|
13
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
|
+
const change_1 = require("@schematics/angular/utility/change");
|
|
15
|
+
const find_module_1 = require("@schematics/angular/utility/find-module");
|
|
16
|
+
const parse_name_1 = require("@schematics/angular/utility/parse-name");
|
|
17
|
+
const validation_1 = require("@schematics/angular/utility/validation");
|
|
18
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
19
|
+
const core_1 = require("@angular-devkit/core");
|
|
5
20
|
const statements_adder_1 = require("../shared/statements-adder");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const loadId = action.payload.containerId;
|
|
67
|
-
|
|
68
|
-
return [
|
|
69
|
-
];
|
|
70
|
-
}),
|
|
71
|
-
),
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
/** Unsubscribe connections from Firebase. */
|
|
75
|
-
cleanup$: Observable<Action> = createEffect(
|
|
76
|
-
() => this.actions$.pipe(
|
|
77
|
-
ofType<Cleanup>(${camelName}ActionTypes.CLEANUP),
|
|
78
|
-
map((action: Cleanup) => new Unsubscribe(action.payload.containerId)),
|
|
79
|
-
),
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
constructor(
|
|
83
|
-
private actions$: Actions,
|
|
84
|
-
private store: Store<fromStore.State>,
|
|
85
|
-
private state: ${camelName}State,
|
|
86
|
-
private db: FirebaseService,
|
|
87
|
-
private eh: EffectsHelpers,
|
|
88
|
-
) {}
|
|
89
|
-
}
|
|
90
|
-
`;
|
|
91
|
-
const SelectorsFile = `import { Injectable } from '@angular/core';
|
|
92
|
-
import { Store, select } from '@ngrx/store';
|
|
93
|
-
import * as fromStore from '../../../core/store/app.reducer';
|
|
94
|
-
import { EntitySelectorService } from '../../../core/store/app.selectors';
|
|
95
|
-
|
|
96
|
-
import { Observable, of, combineLatest } from 'rxjs';
|
|
97
|
-
import { bufferTime, distinctUntilChanged, shareReplay, mergeMap, filter, switchMap, map } from 'rxjs/operators';
|
|
98
|
-
|
|
99
|
-
@Injectable({
|
|
100
|
-
providedIn: 'root',
|
|
101
|
-
})
|
|
102
|
-
export class ${camelName}Selectors {
|
|
103
|
-
|
|
104
|
-
constructor(
|
|
105
|
-
private slRx: EntitySelectorService,
|
|
106
|
-
) { }
|
|
107
|
-
|
|
108
|
-
cleanup(cId: string) {
|
|
109
|
-
this.slRx.release(cId);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
`;
|
|
113
|
-
const StateFile = `import { Injectable } from '@angular/core';
|
|
114
|
-
|
|
115
|
-
import { BehaviorSubject } from 'rxjs';
|
|
116
|
-
|
|
117
|
-
@Injectable({
|
|
118
|
-
providedIn: 'root',
|
|
119
|
-
})
|
|
120
|
-
export class ${camelName}State {
|
|
121
|
-
|
|
122
|
-
// --------------- LOCAL UI STATE ----------------------
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
constructor(
|
|
126
|
-
) { }
|
|
127
|
-
}
|
|
128
|
-
`;
|
|
129
|
-
const AnimationsFile = `import { trigger, group, query, animateChild, state, style, animate, transition } from '@angular/animations';
|
|
130
|
-
|
|
131
|
-
export const ${camelName}Animations = [
|
|
132
|
-
];
|
|
133
|
-
`;
|
|
134
|
-
const HTMLFile = `<div class="${name}-container">
|
|
135
|
-
${name} works!
|
|
136
|
-
</div>`;
|
|
137
|
-
const CSSFile = `.${name}-container {
|
|
138
|
-
}`;
|
|
139
|
-
const SpecFile = `import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
140
|
-
|
|
141
|
-
import { ${camelName}Component } from './${name}.component';
|
|
142
|
-
|
|
143
|
-
describe('${camelName}Component', () => {
|
|
144
|
-
let component: ${camelName}Component;
|
|
145
|
-
let fixture: ComponentFixture<${camelName}Component>;
|
|
146
|
-
|
|
147
|
-
beforeEach(waitForAsync(() => {
|
|
148
|
-
TestBed.configureTestingModule({
|
|
149
|
-
declarations: [ ${camelName}Component ],
|
|
150
|
-
})
|
|
151
|
-
.compileComponents();
|
|
152
|
-
}));
|
|
153
|
-
|
|
154
|
-
beforeEach(() => {
|
|
155
|
-
fixture = TestBed.createComponent(${camelName}Component);
|
|
156
|
-
component = fixture.componentInstance;
|
|
157
|
-
fixture.detectChanges();
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('should create', () => {
|
|
161
|
-
expect(component).toBeTruthy();
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
`;
|
|
165
|
-
const ComponentFile = `import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
|
|
166
|
-
import { ${camelName}Animations } from './${name}.animations';
|
|
167
|
-
import { ParamMap, ActivatedRoute } from '@angular/router';
|
|
168
|
-
import { Store, select } from '@ngrx/store';
|
|
169
|
-
import * as fromStore from '../../core/store/app.reducer';
|
|
170
|
-
import * as fromAuth from '../../core/store/auth/auth.reducer';
|
|
171
|
-
import { FirebaseService } from '../../core/firebase/firebase.service';
|
|
172
|
-
import { Observable, Subject, BehaviorSubject, combineLatest } from 'rxjs';
|
|
173
|
-
import { withLatestFrom, take, takeUntil } from 'rxjs/operators';
|
|
174
|
-
|
|
175
|
-
import { ${camelName}State } from './+state/${name}.state';
|
|
176
|
-
import { ${camelName}Selectors } from './+state/${name}.selectors';
|
|
177
|
-
|
|
178
|
-
import { LoadData, Cleanup } from './+state/${name}.actions';
|
|
179
|
-
import { RouterNavigate } from '../../core/store/app.actions';
|
|
180
|
-
|
|
181
|
-
import { User } from '../../core/store/user/user.model';
|
|
182
|
-
|
|
183
|
-
/** ${description} */
|
|
184
|
-
@Component({
|
|
185
|
-
selector: 'app-${name}',
|
|
186
|
-
templateUrl: './${name}.component.html',
|
|
187
|
-
styleUrls: ['./${name}.component.scss'],
|
|
188
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
189
|
-
animations: ${camelName}Animations,
|
|
190
|
-
})
|
|
191
|
-
export class ${camelName}Component implements OnInit, OnDestroy {
|
|
192
|
-
|
|
193
|
-
// --------------- ROUTE PARAMS & CURRENT USER ---------
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
// --------------- LOCAL UI STATE ----------------------
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
// --------------- DB ENTITY DATA ----------------------
|
|
200
|
-
|
|
201
|
-
/** Container id for selectors and loading. */
|
|
202
|
-
containerId: string = this.db.createId();
|
|
203
|
-
|
|
204
|
-
// --------------- DATA BINDING STREAMS ----------------
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
// --------------- EVENT BINDING STREAMS ---------------
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
// --------------- OTHER -------------------------------
|
|
211
|
-
|
|
212
|
-
/** Unsubscribe observable for subscriptions. */
|
|
213
|
-
unsubscribe$: Subject<void> = new Subject();
|
|
214
|
-
|
|
215
|
-
constructor(
|
|
216
|
-
private state: ${camelName}State,
|
|
217
|
-
private route: ActivatedRoute,
|
|
218
|
-
private selectors: ${camelName}Selectors,
|
|
219
|
-
private store: Store<fromStore.State>,
|
|
220
|
-
private db: FirebaseService,
|
|
221
|
-
) {
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
ngOnInit() {
|
|
225
|
-
|
|
226
|
-
// --------------- EVENT HANDLING ----------------------
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// --------------- LOAD DATA ---------------------------
|
|
230
|
-
|
|
231
|
-
// Once everything is set up, load the data for the role.
|
|
232
|
-
this.store.dispatch( new LoadData({
|
|
233
|
-
containerId: this.containerId,
|
|
234
|
-
}) );
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
ngOnDestroy() {
|
|
238
|
-
// Unsubscribe subscriptions.
|
|
239
|
-
this.unsubscribe$.next();
|
|
240
|
-
this.unsubscribe$.complete();
|
|
241
|
-
|
|
242
|
-
// Unsubscribe from firebase connection from load and free up memoized selector values.
|
|
243
|
-
this.store.dispatch( new Cleanup({
|
|
244
|
-
containerId: this.containerId,
|
|
245
|
-
}) );
|
|
246
|
-
this.selectors.cleanup(this.containerId);
|
|
247
|
-
}
|
|
21
|
+
function addInserts(options) {
|
|
22
|
+
return (host, context) => {
|
|
23
|
+
if (!options.module) {
|
|
24
|
+
return host;
|
|
25
|
+
}
|
|
26
|
+
const classifiedName = core_1.strings.classify(options.name);
|
|
27
|
+
const dasherizedName = core_1.strings.dasherize(options.name);
|
|
28
|
+
const containerPath = `/${options.path}/` +
|
|
29
|
+
core_1.strings.dasherize(options.name) + '/' +
|
|
30
|
+
core_1.strings.dasherize(options.name) + '.component';
|
|
31
|
+
// Add to module
|
|
32
|
+
const modulePath = options.module;
|
|
33
|
+
const moduleText = (0, statements_adder_1.getSourceText)(host, modulePath);
|
|
34
|
+
const moduleToContainerPath = (0, find_module_1.buildRelativePath)(modulePath, containerPath);
|
|
35
|
+
const effectsPath = `/${options.path}/` +
|
|
36
|
+
core_1.strings.dasherize(options.name) + '/+state/' +
|
|
37
|
+
core_1.strings.dasherize(options.name) + '.effects';
|
|
38
|
+
const moduleToEffectsPath = (0, find_module_1.buildRelativePath)(modulePath, effectsPath);
|
|
39
|
+
let insertChangesInModule = (0, statements_adder_1.simpleInsert)(moduleText, modulePath, [
|
|
40
|
+
'// Containers',
|
|
41
|
+
'EffectsModule.forFeature([',
|
|
42
|
+
'// Containers'
|
|
43
|
+
], [
|
|
44
|
+
`import { ${classifiedName}Component } from '${moduleToContainerPath}';\nimport { ${classifiedName}Effects } from '${moduleToEffectsPath}';`,
|
|
45
|
+
` ${classifiedName}Effects,`,
|
|
46
|
+
` ${classifiedName}Component,`
|
|
47
|
+
]);
|
|
48
|
+
// Add routing module changes
|
|
49
|
+
context.logger.info(modulePath);
|
|
50
|
+
const moduleDir = (0, core_1.normalize)(modulePath).split('/').slice(0, -1).join('/');
|
|
51
|
+
const moduleFileName = (0, core_1.normalize)(modulePath).split('/').pop() || '';
|
|
52
|
+
const moduleName = moduleFileName.split('.')[0];
|
|
53
|
+
const moduleRoutingPath = `${moduleDir}/${moduleName}-routing.module.ts`;
|
|
54
|
+
context.logger.info(moduleRoutingPath);
|
|
55
|
+
const moduleRoutingText = (0, statements_adder_1.getSourceText)(host, moduleRoutingPath);
|
|
56
|
+
const moduleRoutingToContainerPath = (0, find_module_1.buildRelativePath)(moduleRoutingPath, containerPath);
|
|
57
|
+
context.logger.info("moduleRoutingPath: " + moduleRoutingPath);
|
|
58
|
+
let insertChangesInRoutingModule = (0, statements_adder_1.simpleInsert)(moduleRoutingText, moduleRoutingPath, [
|
|
59
|
+
'// Containers',
|
|
60
|
+
'const routes: Routes = ['
|
|
61
|
+
], [
|
|
62
|
+
`import { ${classifiedName}Component } from '${moduleRoutingToContainerPath}';`,
|
|
63
|
+
` { path: '${dasherizedName}', component: ${classifiedName}Component },`
|
|
64
|
+
]);
|
|
65
|
+
context.logger.info(`about to start committing`);
|
|
66
|
+
// For each of the files and corresponding set of changes, commit to the tree
|
|
67
|
+
[
|
|
68
|
+
[modulePath, insertChangesInModule],
|
|
69
|
+
[moduleRoutingPath, insertChangesInRoutingModule],
|
|
70
|
+
].map(([filePath, insertChanges]) => {
|
|
71
|
+
const declarationRecorder = host.beginUpdate(filePath);
|
|
72
|
+
for (const change of insertChanges) {
|
|
73
|
+
if (change instanceof change_1.InsertChange) {
|
|
74
|
+
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
host.commitUpdate(declarationRecorder);
|
|
78
|
+
});
|
|
79
|
+
return host;
|
|
80
|
+
};
|
|
248
81
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
(0, statements_adder_1.AddStatements)(filePath, labels, statements, tree);
|
|
256
|
-
const filePath2 = `./src/app/${module}/${ModuleFile}`;
|
|
257
|
-
const labels2 = ['// Containers', 'EffectsModule.forFeature([', '// Containers'];
|
|
258
|
-
const statements2 = [`import { ${camelName}Component } from './${name}/${name}.component';\nimport { ${camelName}Effects } from './${name}/+state/${name}.effects';`, ` ${camelName}Effects,`, ` ${camelName}Component,`];
|
|
259
|
-
(0, statements_adder_1.AddStatements)(filePath2, labels2, statements2, tree);
|
|
260
|
-
// create directories before adding files
|
|
261
|
-
const dir = `./src/app/${module}/${name}`;
|
|
262
|
-
if (!fs.existsSync(dir)) {
|
|
263
|
-
fs.mkdirSync(dir);
|
|
82
|
+
function container(options) {
|
|
83
|
+
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
// Make sure the command is executed in the directory where the container should be generated
|
|
85
|
+
if (!options.inDirectory) {
|
|
86
|
+
context.logger.info("Please navigate to the directory where you want to generate the container.");
|
|
87
|
+
return (0, schematics_1.noop)();
|
|
264
88
|
}
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
89
|
+
const workspace = yield (0, workspace_1.getWorkspace)(tree);
|
|
90
|
+
const project = workspace.projects.get(options.project);
|
|
91
|
+
if (!project) {
|
|
92
|
+
throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`);
|
|
268
93
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
94
|
+
context.logger.info(`options.path: ${options.path}`);
|
|
95
|
+
if (options.path === undefined) {
|
|
96
|
+
options.path = (0, workspace_1.buildDefaultPath)(project);
|
|
97
|
+
}
|
|
98
|
+
context.logger.info(`options.path: ${options.path}`);
|
|
99
|
+
options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
|
|
100
|
+
context.logger.info(`options.module: ${options.module}`);
|
|
101
|
+
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
102
|
+
options.name = parsedPath.name;
|
|
103
|
+
options.path = parsedPath.path;
|
|
104
|
+
(0, validation_1.validateHtmlSelector)(options.selector);
|
|
105
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
106
|
+
(0, schematics_1.applyTemplates)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
107
|
+
(0, schematics_1.move)(parsedPath.path),
|
|
108
|
+
]);
|
|
109
|
+
return (0, schematics_1.chain)([
|
|
110
|
+
addInserts(options),
|
|
111
|
+
(0, schematics_1.mergeWith)(templateSource)
|
|
112
|
+
]);
|
|
113
|
+
});
|
|
281
114
|
}
|
|
282
115
|
exports.container = container;
|
|
283
116
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAIoC;AACpC,+DAA0E;AAC1E,yEAAmG;AACnG,uEAAmE;AACnE,uEAA8E;AAC9E,qEAAuF;AAEvF,+CAAyD;AAEzD,iEAAyE;AAEzE,SAAS,UAAU,CAAC,OAAY;IAC9B,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,OAAO,IAAI,CAAC;SACb;QAED,MAAM,cAAc,GAAG,cAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,cAAc,GAAG,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvD,MAAM,aAAa,GACjB,IAAI,OAAO,CAAC,IAAI,GAAG;YACnB,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG;YACrC,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;QAEjD,gBAAgB;QAChB,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;QAClC,MAAM,UAAU,GAAG,IAAA,gCAAa,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACnD,MAAM,qBAAqB,GAAG,IAAA,+BAAiB,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QAE3E,MAAM,WAAW,GACf,IAAI,OAAO,CAAC,IAAI,GAAG;YACnB,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU;YAC5C,cAAO,CAAC,SAAS,CAAC,O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/schema",
|
|
3
|
-
"$id": "
|
|
4
|
-
"title": "
|
|
3
|
+
"$id": "ContainerSchema",
|
|
4
|
+
"title": "Container Schema",
|
|
5
5
|
"type": "object",
|
|
6
|
+
"description": "Creates a new container in the default project.",
|
|
6
7
|
"properties": {
|
|
7
8
|
"index": {
|
|
8
9
|
"type": "number",
|
|
9
10
|
"default": 1
|
|
10
11
|
},
|
|
12
|
+
"path": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"format": "path",
|
|
15
|
+
"description": "The path at which to create the container 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
|
+
},
|
|
11
25
|
"name": {
|
|
12
26
|
"type": "string",
|
|
13
|
-
"
|
|
27
|
+
"description": "The name of the container.",
|
|
28
|
+
"$default": {
|
|
29
|
+
"$source": "argv",
|
|
30
|
+
"index": 0
|
|
31
|
+
},
|
|
32
|
+
"x-prompt": "What name would you like to use for the container?"
|
|
14
33
|
},
|
|
15
34
|
"module": {
|
|
16
35
|
"type": "string",
|
|
17
|
-
"
|
|
36
|
+
"description": "The declaring NgModule.",
|
|
37
|
+
"alias": "m"
|
|
18
38
|
},
|
|
19
|
-
"
|
|
20
|
-
"type": "
|
|
21
|
-
"x-prompt": "
|
|
39
|
+
"inDirectory": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"x-prompt": "Are you currently in the directory where you want to generate the container? (please organize your container according to the view hierarchy to the extent possible)"
|
|
22
42
|
}
|
|
23
43
|
},
|
|
24
44
|
"required": [
|
|
25
|
-
"name"
|
|
26
|
-
"module"
|
|
45
|
+
"name"
|
|
27
46
|
]
|
|
28
47
|
}
|