@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,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "InitSchema",
|
|
4
|
+
"title": "Init Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"description": "Adds initial project files to a newly created repo.",
|
|
7
|
+
"properties": {
|
|
8
|
+
"index": {
|
|
9
|
+
"type": "number",
|
|
10
|
+
"default": 1
|
|
11
|
+
},
|
|
12
|
+
"project": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The name of the project.",
|
|
15
|
+
"$default": {
|
|
16
|
+
"$source": "projectName"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"proceed": {
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"x-prompt": "This schematic is only designed for generating initial files on a FRESH repo created from ng new. If you use this outside of that context, YOU WILL OVERWRITE parts of your existing code. Are you sure you want to proceed?"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
},
|
|
25
|
+
"required": [
|
|
26
|
+
"project"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { Routes, RouterModule } from '@angular/router';
|
|
3
|
+
|
|
4
|
+
// Containers
|
|
5
|
+
|
|
6
|
+
const routes: Routes = [
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
@NgModule({
|
|
10
|
+
imports: [RouterModule.forChild(routes)],
|
|
11
|
+
exports: [RouterModule],
|
|
12
|
+
})
|
|
13
|
+
export class <%= classify(name) %>RoutingModule { }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { <%= classify(name) %>Module } from './<%= dasherize(name) %>.module';
|
|
2
|
+
|
|
3
|
+
describe('<%= classify(name) %>Module', () => {
|
|
4
|
+
let <%= camelize(name) %>Module: <%= classify(name) %>Module;
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
<%= camelize(name) %>Module = new <%= classify(name) %>Module();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should create an instance', () => {
|
|
11
|
+
expect(<%= camelize(name) %>Module).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { EffectsModule } from '@ngrx/effects';
|
|
4
|
+
import { SharedModule } from '../shared/shared.module';
|
|
5
|
+
import { <%= classify(name) %>RoutingModule } from './<%= dasherize(name) %>-routing.module';
|
|
6
|
+
|
|
7
|
+
// Containers
|
|
8
|
+
|
|
9
|
+
// Components
|
|
10
|
+
|
|
11
|
+
@NgModule({
|
|
12
|
+
imports: [
|
|
13
|
+
CommonModule,
|
|
14
|
+
SharedModule,
|
|
15
|
+
<%= classify(name) %>RoutingModule,
|
|
16
|
+
EffectsModule.forFeature([
|
|
17
|
+
]),
|
|
18
|
+
],
|
|
19
|
+
declarations: [
|
|
20
|
+
// Containers
|
|
21
|
+
// Components
|
|
22
|
+
],
|
|
23
|
+
})
|
|
24
|
+
export class <%= classify(name) %>Module { }
|
package/src/module/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
-
export declare function module(
|
|
2
|
+
export declare function module(options: any): Rule;
|
package/src/module/index.js
CHANGED
|
@@ -1,88 +1,97 @@
|
|
|
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.module = void 0;
|
|
4
13
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const
|
|
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 workspace_1 = require("@schematics/angular/utility/workspace");
|
|
18
|
+
const core_1 = require("@angular-devkit/core");
|
|
6
19
|
const statements_adder_1 = require("../shared/statements-adder");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
describe('${camelName}Module', () => {
|
|
36
|
-
let ${lowerCamelName}Module: ${camelName}Module;
|
|
37
|
-
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
${lowerCamelName}Module = new ${camelName}Module();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should create an instance', () => {
|
|
43
|
-
expect(${lowerCamelName}Module).toBeTruthy();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
`;
|
|
47
|
-
const ModuleFile = `import { NgModule } from '@angular/core';
|
|
48
|
-
import { CommonModule } from '@angular/common';
|
|
49
|
-
import { EffectsModule } from '@ngrx/effects';
|
|
50
|
-
import { SharedModule } from '../shared/shared.module';
|
|
51
|
-
import { ${camelName}RoutingModule } from './${name}-routing.module';
|
|
52
|
-
|
|
53
|
-
// Containers
|
|
54
|
-
|
|
55
|
-
// Components
|
|
56
|
-
|
|
57
|
-
/** ${description} */
|
|
58
|
-
@NgModule({
|
|
59
|
-
imports: [
|
|
60
|
-
CommonModule,
|
|
61
|
-
SharedModule,
|
|
62
|
-
${camelName}RoutingModule,
|
|
63
|
-
EffectsModule.forFeature([
|
|
64
|
-
]),
|
|
65
|
-
],
|
|
66
|
-
declarations: [
|
|
67
|
-
// Containers
|
|
68
|
-
// Components
|
|
69
|
-
],
|
|
70
|
-
})
|
|
71
|
-
export class ${camelName}Module { }`;
|
|
72
|
-
const filePath = 'src/app/app.module.ts';
|
|
73
|
-
const labels = ['// Feature Modules', '// Feature Modules'];
|
|
74
|
-
const statements = [`import { ${camelName}Module } from './${name}/${name}.module';`, ` ${camelName}Module,`];
|
|
75
|
-
(0, statements_adder_1.AddStatements)(filePath, labels, statements, tree);
|
|
76
|
-
// create directory before adding files
|
|
77
|
-
const dir = `./src/app/${name}`;
|
|
78
|
-
if (!fs.existsSync(dir)) {
|
|
79
|
-
fs.mkdirSync(dir);
|
|
20
|
+
function addInserts(options) {
|
|
21
|
+
return (host, context) => {
|
|
22
|
+
const classifiedName = core_1.strings.classify(options.name);
|
|
23
|
+
const dasherizedName = core_1.strings.dasherize(options.name);
|
|
24
|
+
const modulePath = '//src/app/' +
|
|
25
|
+
core_1.strings.dasherize(options.name) + '/' +
|
|
26
|
+
core_1.strings.dasherize(options.name) + '.module';
|
|
27
|
+
context.logger.info(`modulePath: ${modulePath}`);
|
|
28
|
+
if (!options.lazyLoading) {
|
|
29
|
+
// Add app module changes if not lazy loaded
|
|
30
|
+
const appModulePath = '//src/app/app.module.ts';
|
|
31
|
+
const appModuleText = (0, statements_adder_1.getSourceText)(host, appModulePath);
|
|
32
|
+
context.logger.info(`appModulePath: ${appModulePath}`);
|
|
33
|
+
const appModuleToModulePath = (0, find_module_1.buildRelativePath)(appModulePath, modulePath);
|
|
34
|
+
let insertChanges = (0, statements_adder_1.simpleInsert)(appModuleText, appModulePath, [
|
|
35
|
+
'// Feature Modules',
|
|
36
|
+
'// Feature Modules'
|
|
37
|
+
], [
|
|
38
|
+
`import { ${classifiedName}Module } from '${appModuleToModulePath}';`,
|
|
39
|
+
` ${classifiedName}Module,`
|
|
40
|
+
]);
|
|
41
|
+
const declarationRecorder = host.beginUpdate(appModulePath);
|
|
42
|
+
for (const change of insertChanges) {
|
|
43
|
+
if (change instanceof change_1.InsertChange) {
|
|
44
|
+
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
host.commitUpdate(declarationRecorder);
|
|
80
48
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
49
|
+
else {
|
|
50
|
+
// Add app-routing module changes if lazy loaded
|
|
51
|
+
const appRoutingModulePath = '//src/app/app-routing.module.ts';
|
|
52
|
+
const appRoutingModuleText = (0, statements_adder_1.getSourceText)(host, appRoutingModulePath);
|
|
53
|
+
const appRoutingModuleToModulePath = (0, find_module_1.buildRelativePath)(appRoutingModulePath, modulePath);
|
|
54
|
+
context.logger.info(`appRoutingModuleToModulePath: ${appRoutingModuleToModulePath}`);
|
|
55
|
+
let insertChanges = (0, statements_adder_1.simpleInsert)(appRoutingModuleText, appRoutingModulePath, [
|
|
56
|
+
'const appRoutes: Routes = ['
|
|
57
|
+
], [
|
|
58
|
+
` { path: '${dasherizedName}', loadChildren: () => import('${appRoutingModuleToModulePath}').then((mod) => mod.${classifiedName}Module) },`
|
|
59
|
+
]);
|
|
60
|
+
context.logger.info(`insertChanges: ${insertChanges}`);
|
|
61
|
+
const declarationRecorder = host.beginUpdate(appRoutingModulePath);
|
|
62
|
+
for (const change of insertChanges) {
|
|
63
|
+
if (change instanceof change_1.InsertChange) {
|
|
64
|
+
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
host.commitUpdate(declarationRecorder);
|
|
68
|
+
}
|
|
69
|
+
return host;
|
|
85
70
|
};
|
|
86
71
|
}
|
|
72
|
+
function module(options) {
|
|
73
|
+
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
context.logger.info("Starting module generation");
|
|
75
|
+
const workspace = yield (0, workspace_1.getWorkspace)(tree);
|
|
76
|
+
const project = workspace.projects.get(options.project);
|
|
77
|
+
if (!project) {
|
|
78
|
+
throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`);
|
|
79
|
+
}
|
|
80
|
+
if (options.path === undefined) {
|
|
81
|
+
options.path = (0, workspace_1.buildDefaultPath)(project);
|
|
82
|
+
}
|
|
83
|
+
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
84
|
+
options.name = parsedPath.name;
|
|
85
|
+
options.path = parsedPath.path;
|
|
86
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
87
|
+
(0, schematics_1.applyTemplates)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
88
|
+
(0, schematics_1.move)(parsedPath.path),
|
|
89
|
+
]);
|
|
90
|
+
return (0, schematics_1.chain)([
|
|
91
|
+
addInserts(options),
|
|
92
|
+
(0, schematics_1.mergeWith)(templateSource)
|
|
93
|
+
]);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
87
96
|
exports.module = module;
|
|
88
97
|
//# sourceMappingURL=index.js.map
|
package/src/module/index.js.map
CHANGED
|
@@ -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;AAEpC,+DAAkE;AAClE,yEAA4E;AAC5E,uEAAmE;AACnE,qEAAuF;AACvF,+CAA+C;AAE/C,iEAAyE;AAEzE,SAAS,UAAU,CAAC,OAAY;IAC9B,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,cAAc,GAAG,cAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,cAAc,GAAG,cAAO,CAAC,SAAS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EAAE;YAC9B,OAAO,CAAC,IAAI,GAAG,IAAA,4BAAgB,EAAC,OAAO,CAAC,CAAC;SAC1C;QAED,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,OAAO,CAAC,IAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC/B,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAE/B,MAAM,cAAc,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YAC3C,IAAA,2BAAc,kCACT,cAAO,GACP,OAAO,EACV;YACF,IAAA,iBAAI,EAAC,UAAU,CAAC,IAAI,CAAC;SACtB,CAAC,CAAC;QAEH,OAAO,IAAA,kBAAK,EAAC;YACX,UAAU,CAAC,OAAO,CAAC;YACnB,IAAA,sBAAS,EAAC,cAAc,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;AACJ,CAAC;AAhCD,wBAgCC"}
|
package/src/module/schema.json
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "
|
|
4
|
-
"title": "
|
|
3
|
+
"$id": "ModuleSchema",
|
|
4
|
+
"title": "Module Schema",
|
|
5
5
|
"type": "object",
|
|
6
|
+
"description": "Creates a new module in the default project.",
|
|
6
7
|
"properties": {
|
|
7
8
|
"index": {
|
|
8
9
|
"type": "number",
|
|
9
10
|
"default": 1
|
|
10
11
|
},
|
|
11
|
-
"
|
|
12
|
+
"project": {
|
|
12
13
|
"type": "string",
|
|
13
|
-
"
|
|
14
|
+
"description": "The name of the project.",
|
|
15
|
+
"$default": {
|
|
16
|
+
"$source": "projectName"
|
|
17
|
+
}
|
|
14
18
|
},
|
|
15
|
-
"
|
|
19
|
+
"name": {
|
|
16
20
|
"type": "string",
|
|
17
|
-
"
|
|
21
|
+
"description": "The name of the module.",
|
|
22
|
+
"$default": {
|
|
23
|
+
"$source": "argv",
|
|
24
|
+
"index": 0
|
|
25
|
+
},
|
|
26
|
+
"x-prompt": "What name would you like to use for the module?"
|
|
27
|
+
},
|
|
28
|
+
"lazyLoading": {
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"description": "Have it lazy loaded.",
|
|
31
|
+
"default": false,
|
|
32
|
+
"x-prompt": "Would you like the module to be lazy loaded?"
|
|
18
33
|
}
|
|
19
34
|
},
|
|
20
35
|
"required": [
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
+
import { Change } from '@schematics/angular/utility/change';
|
|
2
3
|
export interface IHash {
|
|
3
4
|
[details: string]: number;
|
|
4
5
|
}
|
|
6
|
+
export declare function getSourceText(host: Tree, filePath: string): string;
|
|
7
|
+
export declare function simpleInsert(sourceText: string, fileToEdit: string, labels: string[], statements: string[]): Change[];
|
|
5
8
|
export declare function AddStatements(filePath: string, labels: string[], statements: string[], tree: Tree): void;
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AddStatements = void 0;
|
|
3
|
+
exports.AddStatements = exports.simpleInsert = exports.getSourceText = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
5
|
const change_1 = require("@schematics/angular/utility/change");
|
|
6
|
+
function getSourceText(host, filePath) {
|
|
7
|
+
const text = host.read(filePath);
|
|
8
|
+
if (text === null) {
|
|
9
|
+
throw new schematics_1.SchematicsException(`File ${filePath} does not exist.`);
|
|
10
|
+
}
|
|
11
|
+
return text.toString('utf-8');
|
|
12
|
+
}
|
|
13
|
+
exports.getSourceText = getSourceText;
|
|
14
|
+
function simpleInsert(sourceText, fileToEdit, labels, statements) {
|
|
15
|
+
let labelMap = {};
|
|
16
|
+
return labels.map((label, i) => {
|
|
17
|
+
if (labelMap[label] === undefined)
|
|
18
|
+
labelMap[label] = 0;
|
|
19
|
+
labelMap[label]++;
|
|
20
|
+
let count = labelMap[label];
|
|
21
|
+
let index = getPosition(sourceText, label, count) + label.length;
|
|
22
|
+
return new change_1.InsertChange(fileToEdit, index, `\n${statements[i]}`);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.simpleInsert = simpleInsert;
|
|
6
26
|
function AddStatements(filePath, labels, statements, tree) {
|
|
27
|
+
// getSourceText
|
|
7
28
|
let text = tree.read(filePath); // reads the file from the tree
|
|
8
29
|
if (!text) {
|
|
9
30
|
throw new schematics_1.SchematicsException(`${filePath} does not exist.`); // throw an error if the file doesn't exist
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statements-adder.js","sourceRoot":"","sources":["statements-adder.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AACvE,+
|
|
1
|
+
{"version":3,"file":"statements-adder.js","sourceRoot":"","sources":["statements-adder.ts"],"names":[],"mappings":";;;AAAA,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;QACjB,MAAM,IAAI,gCAAmB,CAAC,QAAQ,QAAQ,kBAAkB,CAAC,CAAC;KACnE;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAND,sCAMC;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,CA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