@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
package/README.md
CHANGED
|
@@ -4,13 +4,10 @@ This repository is used to generate modules, containers, components, and entitie
|
|
|
4
4
|
|
|
5
5
|
### Usage
|
|
6
6
|
|
|
7
|
-
1. Run `npm
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
7
|
+
1. Run `npm install @tech4good/angular-schematics`.
|
|
8
|
+
2. Set the schematics to be the default using: `ng config cli.defaultCollection @tech4good/angular-schematics`
|
|
9
|
+
3. Change directories to the directory you want to generate the files and run `ng generate <schematic> <name>`, where `schematic` = module, container, component, or entity (or if you did not make it the default, use `ng generate @tech4good/angular-schematics:<schematic> <name>`)
|
|
10
10
|
|
|
11
|
-
### Important Notes
|
|
12
|
-
|
|
13
|
-
When generating **components** or **containers**: If the project has an import error for `waitForAsync` in `<component-name>.component.spec.ts`, update all instances to `async`.
|
|
14
11
|
### Developing
|
|
15
12
|
|
|
16
13
|
1. Clone this repository.
|
|
@@ -22,11 +19,12 @@ When generating **components** or **containers**: If the project has an import e
|
|
|
22
19
|
|
|
23
20
|
### Testing
|
|
24
21
|
|
|
25
|
-
To test
|
|
22
|
+
To test, install the repo directly from github into another local repo to test your schematic.
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
schematics
|
|
24
|
+
```
|
|
25
|
+
npm install https://github.com/tech4good-lab/angular-schematics.git#your-branch-name
|
|
26
|
+
npm link @tech4good/angular-schematics
|
|
27
|
+
ng generate @tech4good/angular-schematics:<schematic>
|
|
30
28
|
```
|
|
31
29
|
|
|
32
30
|
### Unit Testing
|
|
@@ -43,4 +41,6 @@ npm publish
|
|
|
43
41
|
```
|
|
44
42
|
|
|
45
43
|
That's it!
|
|
44
|
+
|
|
45
|
+
You can also use `npm version <version>` to update the version before publishing.
|
|
46
46
|
|
package/package.json
CHANGED
package/src/collection.json
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
3
|
"schematics": {
|
|
4
|
+
"init": {
|
|
5
|
+
"description": "Setup initial lab infrastructure files.",
|
|
6
|
+
"factory": "./init/index#init",
|
|
7
|
+
"schema": "./init/schema.json"
|
|
8
|
+
},
|
|
4
9
|
"module": {
|
|
5
|
-
"description": "
|
|
10
|
+
"description": "Generate a new module.",
|
|
6
11
|
"factory": "./module/index#module",
|
|
7
12
|
"schema": "./module/schema.json"
|
|
8
13
|
},
|
|
9
14
|
"container": {
|
|
10
|
-
"description": "
|
|
15
|
+
"description": "Generate a new container.",
|
|
11
16
|
"factory": "./container/index#container",
|
|
12
17
|
"schema": "./container/schema.json"
|
|
13
18
|
},
|
|
14
19
|
"component": {
|
|
15
|
-
"description": "
|
|
20
|
+
"description": "Generate a new component.",
|
|
16
21
|
"factory": "./component/index#component",
|
|
17
22
|
"schema": "./component/schema.json"
|
|
18
23
|
},
|
|
19
24
|
"entity": {
|
|
20
|
-
"description": "
|
|
25
|
+
"description": "Generate a new entity.",
|
|
21
26
|
"factory": "./entity/index#entity",
|
|
22
27
|
"schema": "./entity/schema.json"
|
|
23
28
|
}
|
|
@@ -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,30 @@
|
|
|
1
|
+
import { Component, OnInit, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core';
|
|
2
|
+
import { <%= classify(name) %>Animations } from './<%= dasherize(name) %>.animations';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'app-<%= dasherize(name) %>',
|
|
6
|
+
templateUrl: './<%= dasherize(name) %>.component.html',
|
|
7
|
+
styleUrls: ['./<%= dasherize(name) %>.component.scss'],
|
|
8
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
9
|
+
animations: <%= classify(name) %>Animations,
|
|
10
|
+
})
|
|
11
|
+
export class <%= classify(name) %>Component implements OnInit {
|
|
12
|
+
// --------------- INPUTS AND OUTPUTS ---------
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// --------------- LOCAL UI STATE ----------------------
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
constructor() { }
|
|
19
|
+
|
|
20
|
+
ngOnInit(): void {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// --------------- DATA BINDING FUNCTIONS ----------------
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// --------------- EVENT BINDING FUNCTIONS ---------------
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// --------------- OTHER -------------------------------
|
|
30
|
+
}
|
package/src/component/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
-
export declare function component(
|
|
2
|
+
export declare function component(options: any): Rule;
|
package/src/component/index.js
CHANGED
|
@@ -1,103 +1,94 @@
|
|
|
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.component = 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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// --------------- LOCAL UI STATE ----------------------
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
constructor() { }
|
|
45
|
-
|
|
46
|
-
ngOnInit() {
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// --------------- DATA BINDING FUNCTIONS ----------------
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// --------------- EVENT BINDING FUNCTIONS ---------------
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// --------------- OTHER -------------------------------
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
59
|
-
const SpecFile = `import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
60
|
-
|
|
61
|
-
import { ${camelName}Component } from './${name}.component';
|
|
62
|
-
|
|
63
|
-
describe('${camelName}Component', () => {
|
|
64
|
-
let component: ${camelName}Component;
|
|
65
|
-
let fixture: ComponentFixture<${camelName}Component>;
|
|
66
|
-
|
|
67
|
-
beforeEach(waitForAsync(() => {
|
|
68
|
-
TestBed.configureTestingModule({
|
|
69
|
-
declarations: [ ${camelName}Component ],
|
|
70
|
-
})
|
|
71
|
-
.compileComponents();
|
|
72
|
-
}));
|
|
73
|
-
|
|
74
|
-
beforeEach(() => {
|
|
75
|
-
fixture = TestBed.createComponent(${camelName}Component);
|
|
76
|
-
component = fixture.componentInstance;
|
|
77
|
-
fixture.detectChanges();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should create', () => {
|
|
81
|
-
expect(component).toBeTruthy();
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
`;
|
|
85
|
-
const filePath = `./src/app/${module}/${module}.module.ts`;
|
|
86
|
-
const labels = ['// Components', '// Components'];
|
|
87
|
-
const statements = [`import { ${camelName}Component } from './${container}/${name}/${name}.component';`, ` ${camelName}Component,`];
|
|
88
|
-
(0, statements_adder_1.AddStatements)(filePath, labels, statements, tree);
|
|
89
|
-
// create directories before adding files
|
|
90
|
-
const dir = `./src/app/${module}/${container}/${name}`;
|
|
91
|
-
if (!fs.existsSync(dir)) {
|
|
92
|
-
fs.mkdirSync(dir);
|
|
21
|
+
function addInserts(options) {
|
|
22
|
+
return (host, context) => {
|
|
23
|
+
if (!options.module) {
|
|
24
|
+
return host;
|
|
25
|
+
}
|
|
26
|
+
const modulePath = options.module;
|
|
27
|
+
const sourceText = (0, statements_adder_1.getSourceText)(host, modulePath);
|
|
28
|
+
context.logger.info(`modulePath: ${modulePath}`);
|
|
29
|
+
// Get parameters for adding declaration to module (including import)
|
|
30
|
+
context.logger.info(`options.path: ${options.path}`);
|
|
31
|
+
const componentPath = `/${options.path}/` +
|
|
32
|
+
core_1.strings.dasherize(options.name) + '/' +
|
|
33
|
+
core_1.strings.dasherize(options.name) + '.component';
|
|
34
|
+
context.logger.info(`componentPath: ${componentPath}`);
|
|
35
|
+
const relativePath = (0, find_module_1.buildRelativePath)(modulePath, componentPath);
|
|
36
|
+
context.logger.info(`relativePath: ${relativePath}`);
|
|
37
|
+
const classifiedName = core_1.strings.classify(options.name) + 'Component';
|
|
38
|
+
context.logger.info(`classifiedName: ${classifiedName}`);
|
|
39
|
+
const isSharedModule = options.module.startsWith('/src/app/shared');
|
|
40
|
+
let insertChanges = (0, statements_adder_1.simpleInsert)(sourceText, modulePath, [
|
|
41
|
+
'// Components',
|
|
42
|
+
'// Components',
|
|
43
|
+
// If the module is shared, then add an export too
|
|
44
|
+
...isSharedModule ? ['// Components'] : [],
|
|
45
|
+
], [
|
|
46
|
+
`import { ${classifiedName} } from '${relativePath}';`,
|
|
47
|
+
` ${classifiedName},`,
|
|
48
|
+
...isSharedModule ? [` ${classifiedName},`] : [],
|
|
49
|
+
]);
|
|
50
|
+
const declarationRecorder = host.beginUpdate(modulePath);
|
|
51
|
+
for (const change of insertChanges) {
|
|
52
|
+
if (change instanceof change_1.InsertChange) {
|
|
53
|
+
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
54
|
+
}
|
|
93
55
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
tree.create(`${dir}/${name}.component.scss`, CSSFile);
|
|
97
|
-
tree.create(`${dir}/${name}.component.spec.ts`, SpecFile);
|
|
98
|
-
tree.create(`${dir}/${name}.component.ts`, ComponentFile);
|
|
99
|
-
return tree;
|
|
56
|
+
host.commitUpdate(declarationRecorder);
|
|
57
|
+
return host;
|
|
100
58
|
};
|
|
101
59
|
}
|
|
60
|
+
function component(options) {
|
|
61
|
+
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
// Make sure the command is executed in the directory where the component should be generated
|
|
63
|
+
if (!options.inDirectory) {
|
|
64
|
+
context.logger.info("Please navigate to the directory where you want to generate the component.");
|
|
65
|
+
return (0, schematics_1.noop)();
|
|
66
|
+
}
|
|
67
|
+
const workspace = yield (0, workspace_1.getWorkspace)(tree);
|
|
68
|
+
const project = workspace.projects.get(options.project);
|
|
69
|
+
if (!project) {
|
|
70
|
+
throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`);
|
|
71
|
+
}
|
|
72
|
+
context.logger.info(`options.path: ${options.path}`);
|
|
73
|
+
if (options.path === undefined) {
|
|
74
|
+
options.path = (0, workspace_1.buildDefaultPath)(project);
|
|
75
|
+
}
|
|
76
|
+
context.logger.info(`options.path: ${options.path}`);
|
|
77
|
+
options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
|
|
78
|
+
context.logger.info(`options.module: ${options.module}`);
|
|
79
|
+
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
80
|
+
options.name = parsedPath.name;
|
|
81
|
+
options.path = parsedPath.path;
|
|
82
|
+
(0, validation_1.validateHtmlSelector)(options.selector);
|
|
83
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
84
|
+
(0, schematics_1.applyTemplates)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
85
|
+
(0, schematics_1.move)(parsedPath.path),
|
|
86
|
+
]);
|
|
87
|
+
return (0, schematics_1.chain)([
|
|
88
|
+
addInserts(options),
|
|
89
|
+
(0, schematics_1.mergeWith)(templateSource)
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
102
93
|
exports.component = component;
|
|
103
94
|
//# 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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4
|
-
"title": "
|
|
3
|
+
"$id": "ComponentSchema",
|
|
4
|
+
"title": "Component Schema",
|
|
5
5
|
"type": "object",
|
|
6
|
+
"description": "Creates a new component in the default project.",
|
|
6
7
|
"properties": {
|
|
7
8
|
"index": {
|
|
8
9
|
"type": "number",
|
|
9
10
|
"default": 1
|
|
10
11
|
},
|
|
11
|
-
"
|
|
12
|
+
"path": {
|
|
12
13
|
"type": "string",
|
|
13
|
-
"
|
|
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
|
|
14
17
|
},
|
|
15
|
-
"
|
|
18
|
+
"project": {
|
|
16
19
|
"type": "string",
|
|
17
|
-
"
|
|
20
|
+
"description": "The name of the project.",
|
|
21
|
+
"$default": {
|
|
22
|
+
"$source": "projectName"
|
|
23
|
+
}
|
|
18
24
|
},
|
|
19
|
-
"
|
|
25
|
+
"name": {
|
|
20
26
|
"type": "string",
|
|
21
|
-
"
|
|
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?"
|
|
22
33
|
},
|
|
23
|
-
"
|
|
34
|
+
"module": {
|
|
24
35
|
"type": "string",
|
|
25
|
-
"
|
|
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)"
|
|
26
42
|
}
|
|
27
43
|
},
|
|
28
44
|
"required": [
|
|
29
|
-
"name"
|
|
30
|
-
"module",
|
|
31
|
-
"container"
|
|
45
|
+
"name"
|
|
32
46
|
]
|
|
33
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
|
+
});
|