ngssm-schematics 14.0.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 +111 -0
- package/esm2020/lib/ngssm-schematics.module.mjs +16 -0
- package/esm2020/ngssm-schematics.mjs +5 -0
- package/esm2020/public-api.mjs +5 -0
- package/fesm2015/ngssm-schematics.mjs +27 -0
- package/fesm2015/ngssm-schematics.mjs.map +1 -0
- package/fesm2020/ngssm-schematics.mjs +27 -0
- package/fesm2020/ngssm-schematics.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/ngssm-schematics.module.d.ts +6 -0
- package/package.json +43 -0
- package/public-api.d.ts +1 -0
- package/schematics/action/files/__name@dasherize__.action.ts.template +5 -0
- package/schematics/action/index.d.ts +3 -0
- package/schematics/action/index.js +20 -0
- package/schematics/action/index.js.map +1 -0
- package/schematics/action/schema.json +28 -0
- package/schematics/add-eslint/index.d.ts +2 -0
- package/schematics/add-eslint/index.js +69 -0
- package/schematics/add-eslint/index.js.map +1 -0
- package/schematics/add-eslint/schema.json +11 -0
- package/schematics/add-fontawesome/index.d.ts +3 -0
- package/schematics/add-fontawesome/index.js +59 -0
- package/schematics/add-fontawesome/index.js.map +1 -0
- package/schematics/add-fontawesome/schema.json +11 -0
- package/schematics/add-material/index.d.ts +2 -0
- package/schematics/add-material/index.js +30 -0
- package/schematics/add-material/index.js.map +1 -0
- package/schematics/add-material/schema.json +11 -0
- package/schematics/collection.json +62 -0
- package/schematics/component/component-options.d.ts +19 -0
- package/schematics/component/component-options.js +3 -0
- package/schematics/component/component-options.js.map +1 -0
- package/schematics/component/files/__name@dasherize__.component.ts.template +27 -0
- package/schematics/component/index.d.ts +3 -0
- package/schematics/component/index.js +68 -0
- package/schematics/component/index.js.map +1 -0
- package/schematics/component/schema.json +135 -0
- package/schematics/effect/files/__name@dasherize__.effect.ts.template +16 -0
- package/schematics/effect/index.d.ts +3 -0
- package/schematics/effect/index.js +41 -0
- package/schematics/effect/index.js.map +1 -0
- package/schematics/effect/schema.json +41 -0
- package/schematics/exec-lint/index.d.ts +2 -0
- package/schematics/exec-lint/index.js +12 -0
- package/schematics/exec-lint/index.js.map +1 -0
- package/schematics/exec-lint/schema.json +11 -0
- package/schematics/feature-state/files/__name@dasherize__.state.ts.template +22 -0
- package/schematics/feature-state/index.d.ts +3 -0
- package/schematics/feature-state/index.js +21 -0
- package/schematics/feature-state/index.js.map +1 -0
- package/schematics/feature-state/schema.json +28 -0
- package/schematics/module/files/__name@dasherize__-routing.module.ts.template +10 -0
- package/schematics/module/files/__name@dasherize__.module.ts.template +10 -0
- package/schematics/module/files/actions/__name@dasherize__-action-type.ts.template +1 -0
- package/schematics/module/files/actions/index.ts.template +1 -0
- package/schematics/module/files/components/.gitkeep +0 -0
- package/schematics/module/files/effects/.gitkeep +0 -0
- package/schematics/module/files/guards/.gitkeep +0 -0
- package/schematics/module/files/model/.gitkeep +0 -0
- package/schematics/module/files/public-api.ts.template +1 -0
- package/schematics/module/files/reducers/.gitkeep +0 -0
- package/schematics/module/files/services/.gitkeep +0 -0
- package/schematics/module/files/state/__name@dasherize__.state.ts.template +22 -0
- package/schematics/module/files/state/index.ts.template +1 -0
- package/schematics/module/index.d.ts +3 -0
- package/schematics/module/index.js +30 -0
- package/schematics/module/index.js.map +1 -0
- package/schematics/module/module-options.d.ts +4 -0
- package/schematics/module/module-options.js +3 -0
- package/schematics/module/module-options.js.map +1 -0
- package/schematics/module/schema.json +30 -0
- package/schematics/ng-add/index.d.ts +3 -0
- package/schematics/ng-add/index.js +42 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.d.ts +8 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +29 -0
- package/schematics/reducer/files/__name@dasherize__.reducer.ts.template +18 -0
- package/schematics/reducer/index.d.ts +3 -0
- package/schematics/reducer/index.js +41 -0
- package/schematics/reducer/index.js.map +1 -0
- package/schematics/reducer/schema.json +41 -0
- package/schematics/utilities/base-options.d.ts +4 -0
- package/schematics/utilities/base-options.js +3 -0
- package/schematics/utilities/base-options.js.map +1 -0
- package/schematics/utilities/helpers.d.ts +5 -0
- package/schematics/utilities/helpers.js +39 -0
- package/schematics/utilities/helpers.js.map +1 -0
- package/schematics/utilities/index.d.ts +2 -0
- package/schematics/utilities/index.js +19 -0
- package/schematics/utilities/index.js.map +1 -0
- package/schematics/utilities/with-provider-options.d.ts +6 -0
- package/schematics/utilities/with-provider-options.js +3 -0
- package/schematics/utilities/with-provider-options.js.map +1 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "SchematicsModule",
|
|
4
|
+
"title": "Feature module with state, action and all the folders",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"description": "Creates a new feature module.",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"description": "The name of the feature module.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"path": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"format": "path",
|
|
20
|
+
"description": "The output path.",
|
|
21
|
+
"visible": false,
|
|
22
|
+
"$default": {
|
|
23
|
+
"$source": "workingDirectory"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"required": [
|
|
28
|
+
"name"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
4
|
+
function default_1(options) {
|
|
5
|
+
return (tree, context) => {
|
|
6
|
+
context.logger.info('Starting configuration of the workspace...');
|
|
7
|
+
const taksIds = [];
|
|
8
|
+
if (options.addEslint) {
|
|
9
|
+
context.logger.info('ESLint must be installed and configured');
|
|
10
|
+
const installTaskId = context.addTask(new tasks_1.RunSchematicTask('add-eslint', {}), [...taksIds]);
|
|
11
|
+
taksIds.push(installTaskId);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
context.logger.warn('ESLint will not be installed.');
|
|
15
|
+
}
|
|
16
|
+
if (options.addMaterial) {
|
|
17
|
+
context.logger.info('@angular/material must be installed and configured');
|
|
18
|
+
const installTaskId = context.addTask(new tasks_1.RunSchematicTask('add-material', {}), [...taksIds]);
|
|
19
|
+
taksIds.push(installTaskId);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
context.logger.warn('@angular/material will not be installed.');
|
|
23
|
+
}
|
|
24
|
+
if (options.addFontawesome) {
|
|
25
|
+
context.logger.info('@fortawesome/fontawesome-free must be installed and configured');
|
|
26
|
+
const installTaskId = context.addTask(new tasks_1.RunSchematicTask('add-fontawesome', {}), [...taksIds]);
|
|
27
|
+
taksIds.push(installTaskId);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
context.logger.warn('@fortawesome/fontawesome-free will not be installed.');
|
|
31
|
+
}
|
|
32
|
+
const installTaskId = context.addTask(new tasks_1.RunSchematicTask('add-leono', {}), [...taksIds]);
|
|
33
|
+
taksIds.push(installTaskId);
|
|
34
|
+
// Last task
|
|
35
|
+
if (options.addEslint) {
|
|
36
|
+
context.addTask(new tasks_1.RunSchematicTask('exec-lint', {}), [...taksIds]);
|
|
37
|
+
}
|
|
38
|
+
return tree;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.default = default_1;
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngssm-schematics/schematics/ng-add/index.ts"],"names":[],"mappings":";;AACA,4DAAoE;AAGpE,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DAAsD,CAAC,CAAC;SAC7E;QAED,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,wBAAgB,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;QAC3F,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAE5B,YAAY;QACZ,IAAI,OAAO,CAAC,SAAS,EAAE;YACrB,OAAO,CAAC,OAAO,CAAC,IAAI,wBAAgB,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;SACtE;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAtCD,4BAsCC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface Schema {
|
|
2
|
+
/** Wheter eslint and prettier must be installed and configured */
|
|
3
|
+
addEslint: boolean;
|
|
4
|
+
/** Whether @angular/material and @angular/flex-layout must be installed and configured */
|
|
5
|
+
addMaterial: boolean;
|
|
6
|
+
/** Whether @fortawesome/fontawesome-free must be installed and configured */
|
|
7
|
+
addFontawesome: boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../projects/ngssm-schematics/schematics/ng-add/schema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "SchematicsNgAdd",
|
|
4
|
+
"title": "Initialize workpsace",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"description": "Initialize worspace by installing all the required dependencies",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"addEslint": {
|
|
10
|
+
"type": "boolean",
|
|
11
|
+
"default": true,
|
|
12
|
+
"description": "Whether to set up eslint.",
|
|
13
|
+
"x-prompt": "Install and setup eslint and prettier ?"
|
|
14
|
+
},
|
|
15
|
+
"addMaterial": {
|
|
16
|
+
"type": "boolean",
|
|
17
|
+
"default": true,
|
|
18
|
+
"description": "Whether to add @angular/material.",
|
|
19
|
+
"x-prompt": "Install and setup @angular/material ?"
|
|
20
|
+
},
|
|
21
|
+
"addFontawesome": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"default": true,
|
|
24
|
+
"description": "Whether to add @fortawesome/fontawesome-free.",
|
|
25
|
+
"x-prompt": "Install and setup @fortawesome/fontawesome-free ?"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"required": []
|
|
29
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Injectable, Provider } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { Reducer, State, Action, NGSSM_REDUCER } from 'ngssm-store';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class <%= classify(name) %>Reducer implements Reducer {
|
|
7
|
+
public readonly processedActions: string[] = [];
|
|
8
|
+
|
|
9
|
+
public updateState(state: State, action: Action): State {
|
|
10
|
+
return state;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const <%= providerName %>: Provider = {
|
|
15
|
+
provide: NGSSM_REDUCER,
|
|
16
|
+
useClass: <%= classify(name) %>Reducer,
|
|
17
|
+
multi: true
|
|
18
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.reducer = void 0;
|
|
13
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
|
+
const core_1 = require("@angular-devkit/core");
|
|
15
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
16
|
+
const find_module_1 = require("@schematics/angular/utility/find-module");
|
|
17
|
+
const helpers_1 = require("../utilities/helpers");
|
|
18
|
+
function reducer(options) {
|
|
19
|
+
return (host) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const workspace = yield (0, workspace_1.getWorkspace)(host);
|
|
21
|
+
const project = workspace.projects.get(options.project);
|
|
22
|
+
if (!project) {
|
|
23
|
+
throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`);
|
|
24
|
+
}
|
|
25
|
+
options.module = (0, find_module_1.findModuleFromOptions)(host, options);
|
|
26
|
+
options.providerName = `${core_1.strings.camelize(options.name)}ReducerProvider`;
|
|
27
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
28
|
+
(0, schematics_1.applyTemplates)({
|
|
29
|
+
classify: core_1.strings.classify,
|
|
30
|
+
dasherize: core_1.strings.dasherize,
|
|
31
|
+
camelize: core_1.strings.camelize,
|
|
32
|
+
name: options.name,
|
|
33
|
+
providerName: options.providerName
|
|
34
|
+
}),
|
|
35
|
+
(0, schematics_1.move)((0, core_1.normalize)(options.path))
|
|
36
|
+
]);
|
|
37
|
+
return (0, schematics_1.chain)([(0, helpers_1.addDeclarationToNgModule)(options, 'reducer'), (0, schematics_1.mergeWith)(templateSource)]);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.reducer = reducer;
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngssm-schemat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,0BAuBC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "SchematicsReducer",
|
|
4
|
+
"title": "Reducer schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"description": "The name of the reducer.",
|
|
9
|
+
"type": "string",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"path": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"format": "path",
|
|
18
|
+
"description": "The path to create the simple schematic within.",
|
|
19
|
+
"visible": false,
|
|
20
|
+
"$default": {
|
|
21
|
+
"$source": "workingDirectory"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"module": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "The declaring NgModule.",
|
|
27
|
+
"visible": false
|
|
28
|
+
},
|
|
29
|
+
"project": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "The name of the project.",
|
|
32
|
+
"$default": {
|
|
33
|
+
"$source": "projectName"
|
|
34
|
+
},
|
|
35
|
+
"visible": false
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"required": [
|
|
39
|
+
"name"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-options.js","sourceRoot":"","sources":["../../../../projects/ngssm-schematics/schematics/utilities/base-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Rule, Tree } from '@angular-devkit/schematics';
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
|
+
import { WithProviderOptions } from './with-provider-options';
|
|
4
|
+
export declare function readIntoSourceFile(host: Tree, modulePath: string): ts.SourceFile;
|
|
5
|
+
export declare function addDeclarationToNgModule(options: WithProviderOptions, objectType: string): Rule;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDeclarationToNgModule = exports.readIntoSourceFile = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const core_1 = require("@angular-devkit/core");
|
|
6
|
+
const find_module_1 = require("@schematics/angular/utility/find-module");
|
|
7
|
+
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
|
|
8
|
+
const change_1 = require("@schematics/angular/utility/change");
|
|
9
|
+
const ts = require("typescript");
|
|
10
|
+
function readIntoSourceFile(host, modulePath) {
|
|
11
|
+
const text = host.read(modulePath);
|
|
12
|
+
if (text === null) {
|
|
13
|
+
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
14
|
+
}
|
|
15
|
+
return ts.createSourceFile(modulePath, text.toString('utf-8'), ts.ScriptTarget.Latest, true);
|
|
16
|
+
}
|
|
17
|
+
exports.readIntoSourceFile = readIntoSourceFile;
|
|
18
|
+
function addDeclarationToNgModule(options, objectType) {
|
|
19
|
+
return (host) => {
|
|
20
|
+
const modulePath = options.module;
|
|
21
|
+
if (modulePath === undefined) {
|
|
22
|
+
return host;
|
|
23
|
+
}
|
|
24
|
+
const source = readIntoSourceFile(host, modulePath);
|
|
25
|
+
const providerPath = `/${options.path}/${core_1.strings.dasherize(options.name)}.${objectType}`;
|
|
26
|
+
const relativePath = (0, find_module_1.buildRelativePath)(modulePath, providerPath);
|
|
27
|
+
const providerChanges = (0, ast_utils_1.addProviderToModule)(source, modulePath, options.providerName, relativePath);
|
|
28
|
+
const declarationRecorder = host.beginUpdate(modulePath);
|
|
29
|
+
for (const change of providerChanges) {
|
|
30
|
+
if (change instanceof change_1.InsertChange) {
|
|
31
|
+
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
host.commitUpdate(declarationRecorder);
|
|
35
|
+
return host;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.addDeclarationToNgModule = addDeclarationToNgModule;
|
|
39
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../projects/ngssm-schematics/schematics/utilities/helpers.ts"],"names":[],"mappings":";;;AAAA,2DAA6E;AAC7E,+CAA+C;AAC/C,yEAA4E;AAC5E,qEAA4E;AAC5E,+DAAkE;AAElE,iCAAiC;AAIjC,SAAgB,kBAAkB,CAAC,IAAU,EAAE,UAAkB;IAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACnC,IAAI,IAAI,KAAK,IAAI,EAAE;QACjB,MAAM,IAAI,gCAAmB,CAAC,QAAQ,UAAU,kBAAkB,CAAC,CAAC;KACrE;IAED,OAAO,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC/F,CAAC;AAPD,gDAOC;AAED,SAAgB,wBAAwB,CAAC,OAA4B,EAAE,UAAkB;IACvF,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;QAClC,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,OAAO,IAAI,CAAC;SACb;QAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEpD,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,IAAI,IAAI,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC;QACzF,MAAM,YAAY,GAAG,IAAA,+BAAiB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAEjE,MAAM,eAAe,GAAG,IAAA,+BAAmB,EACzC,MAAM,EACN,UAAoB,EACpB,OAAO,CAAC,YAAsB,EAC9B,YAAY,CACK,CAAC;QAEpB,MAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACzD,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE;YACpC,IAAI,MAAM,YAAY,qBAAY,EAAE;gBAClC,mBAAmB,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;aAC1D;SACF;QACD,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAEvC,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AA7BD,4DA6BC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base-options"), exports);
|
|
18
|
+
__exportStar(require("./with-provider-options"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngssm-schematics/schematics/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,0DAAwC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-provider-options.js","sourceRoot":"","sources":["../../../../projects/ngssm-schematics/schematics/utilities/with-provider-options.ts"],"names":[],"mappings":""}
|