@mckit/schematics 0.0.14 → 0.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mckit/schematics",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "A blank schematics",
5
5
  "scripts": {
6
6
  "build": "tsc -p tsconfig.json",
@@ -7,6 +7,8 @@
7
7
  [columns]="columns"
8
8
  [searchFieldsKey]="searchFieldsKey" >
9
9
 
10
+ <ng-template mcThTemplate="actions"></ng-template>
11
+
10
12
  <ng-template mcTdTemplate="actions" let-row>
11
13
  <mc-actions-column [item]="row" (onEdit)="onClickEdit($event)" (onRemove)="onClickRemove($event)"></mc-actions-column>
12
14
  </ng-template>
@@ -1,6 +1,7 @@
1
1
  import { Tree } from '@angular-devkit/schematics';
2
2
  export interface ClassData {
3
3
  name: string;
4
+ path: string;
4
5
  properties: string[];
5
6
  }
6
- export declare function getPropertiesByClass(tree: Tree, filePath: string): ClassData;
7
+ export declare function getPropertiesByClass(tree: Tree, className: string): ClassData;
@@ -2,29 +2,36 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPropertiesByClass = getPropertiesByClass;
4
4
  const ts = require("typescript");
5
- function getPropertiesByClass(tree, filePath) {
6
- const file = tree.read(filePath);
7
- if (!file) {
8
- throw new Error(`El archivo ${filePath} no existe.`);
9
- }
10
- const fileContent = file.toString('utf-8');
11
- const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest, true);
12
- let firstClass = null;
13
- ts.forEachChild(sourceFile, (node) => {
14
- if (!firstClass && ts.isClassDeclaration(node) && node.name) {
15
- const className = node.name.text;
16
- const properties = [];
17
- node.members.forEach((member) => {
18
- if (ts.isPropertyDeclaration(member) && member.name) {
19
- properties.push(member.name.getText());
20
- }
21
- });
22
- firstClass = { name: className, properties };
23
- }
5
+ function getPropertiesByClass(tree, className) {
6
+ let classFilePath;
7
+ let properties = [];
8
+ tree.visit((filePath) => {
9
+ if (!filePath.endsWith('.ts'))
10
+ return;
11
+ const file = tree.read(filePath);
12
+ if (!file)
13
+ return;
14
+ const fileContent = file.toString('utf-8');
15
+ const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest, true);
16
+ ts.forEachChild(sourceFile, (node) => {
17
+ var _a;
18
+ if (ts.isClassDeclaration(node) && ((_a = node.name) === null || _a === void 0 ? void 0 : _a.text) === className) {
19
+ classFilePath = filePath;
20
+ node.members.forEach((member) => {
21
+ if (ts.isPropertyDeclaration(member) && member.name) {
22
+ properties.push(member.name.getText());
23
+ }
24
+ });
25
+ }
26
+ });
24
27
  });
25
- if (firstClass == undefined || firstClass == null) {
26
- throw new Error(`No se encontró ninguna clase en el archivo ${filePath}`);
28
+ if (classFilePath == undefined) {
29
+ throw new Error(`No se encontró la clase ${className} en ningún archivo.`);
27
30
  }
28
- return firstClass;
31
+ return {
32
+ name: className,
33
+ path: classFilePath,
34
+ properties
35
+ };
29
36
  }
30
37
  //# sourceMappingURL=get-properties-by-class.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-properties-by-class.js","sourceRoot":"","sources":["get-properties-by-class.ts"],"names":[],"mappings":";;AAQA,oDAiCC;AAxCD,iCAAiC;AAOjC,SAAgB,oBAAoB,CAAC,IAAU,EAAE,QAAgB;IAE7D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,aAAa,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE3C,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,C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