@o3r/schematics 9.1.0-alpha.20 → 9.1.0-alpha.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. package/index.d.ts +7 -0
  2. package/index.d.ts.map +1 -0
  3. package/index.js +10 -0
  4. package/index.js.map +1 -0
  5. package/interfaces/angular-workspace.d.ts +62 -0
  6. package/interfaces/angular-workspace.d.ts.map +1 -0
  7. package/interfaces/angular-workspace.js +3 -0
  8. package/interfaces/angular-workspace.js.map +1 -0
  9. package/interfaces/index.d.ts +3 -0
  10. package/interfaces/index.d.ts.map +1 -0
  11. package/interfaces/index.js +6 -0
  12. package/interfaces/index.js.map +1 -0
  13. package/interfaces/schematic-option.d.ts +5 -0
  14. package/interfaces/schematic-option.d.ts.map +1 -0
  15. package/interfaces/schematic-option.js +3 -0
  16. package/interfaces/schematic-option.js.map +1 -0
  17. package/modules/index.d.ts +3 -0
  18. package/modules/index.d.ts.map +1 -0
  19. package/modules/index.js +6 -0
  20. package/modules/index.js.map +1 -0
  21. package/modules/modules.constants.d.ts +34 -0
  22. package/modules/modules.constants.d.ts.map +1 -0
  23. package/modules/modules.constants.js +12 -0
  24. package/modules/modules.constants.js.map +1 -0
  25. package/modules/modules.helpers.d.ts +60 -0
  26. package/modules/modules.helpers.d.ts.map +1 -0
  27. package/modules/modules.helpers.js +165 -0
  28. package/modules/modules.helpers.js.map +1 -0
  29. package/package.json +4 -4
  30. package/public_api.d.ts +2 -0
  31. package/public_api.d.ts.map +1 -0
  32. package/public_api.js +5 -0
  33. package/public_api.js.map +1 -0
  34. package/rule-factories/add-imports/index.d.ts +12 -0
  35. package/rule-factories/add-imports/index.d.ts.map +1 -0
  36. package/rule-factories/add-imports/index.js +26 -0
  37. package/rule-factories/add-imports/index.js.map +1 -0
  38. package/rule-factories/check-packages-peers/index.d.ts +8 -0
  39. package/rule-factories/check-packages-peers/index.d.ts.map +1 -0
  40. package/rule-factories/check-packages-peers/index.js +106 -0
  41. package/rule-factories/check-packages-peers/index.js.map +1 -0
  42. package/rule-factories/eslint-fix/index.d.ts +28 -0
  43. package/rule-factories/eslint-fix/index.d.ts.map +1 -0
  44. package/rule-factories/eslint-fix/index.js +71 -0
  45. package/rule-factories/eslint-fix/index.js.map +1 -0
  46. package/rule-factories/index.d.ts +9 -0
  47. package/rule-factories/index.d.ts.map +1 -0
  48. package/rule-factories/index.js +12 -0
  49. package/rule-factories/index.js.map +1 -0
  50. package/rule-factories/interfaces.d.ts +6 -0
  51. package/rule-factories/interfaces.d.ts.map +1 -0
  52. package/rule-factories/interfaces.js +3 -0
  53. package/rule-factories/interfaces.js.map +1 -0
  54. package/rule-factories/ng-add/index.d.ts +38 -0
  55. package/rule-factories/ng-add/index.d.ts.map +1 -0
  56. package/rule-factories/ng-add/index.js +174 -0
  57. package/rule-factories/ng-add/index.js.map +1 -0
  58. package/rule-factories/remove-packages/index.d.ts +9 -0
  59. package/rule-factories/remove-packages/index.d.ts.map +1 -0
  60. package/rule-factories/remove-packages/index.js +29 -0
  61. package/rule-factories/remove-packages/index.js.map +1 -0
  62. package/rule-factories/update-imports/index.d.ts +5 -0
  63. package/rule-factories/update-imports/index.d.ts.map +1 -0
  64. package/rule-factories/update-imports/index.js +8 -0
  65. package/rule-factories/update-imports/index.js.map +1 -0
  66. package/rule-factories/update-imports/list-of-vars.d.ts +15 -0
  67. package/rule-factories/update-imports/list-of-vars.d.ts.map +1 -0
  68. package/rule-factories/update-imports/list-of-vars.js +44 -0
  69. package/rule-factories/update-imports/list-of-vars.js.map +1 -0
  70. package/rule-factories/update-imports/update-imports-with-scope.d.ts +12 -0
  71. package/rule-factories/update-imports/update-imports-with-scope.d.ts.map +1 -0
  72. package/rule-factories/update-imports/update-imports-with-scope.js +34 -0
  73. package/rule-factories/update-imports/update-imports-with-scope.js.map +1 -0
  74. package/rule-factories/update-imports/update-ts-imports.d.ts +11 -0
  75. package/rule-factories/update-imports/update-ts-imports.d.ts.map +1 -0
  76. package/rule-factories/update-imports/update-ts-imports.js +32 -0
  77. package/rule-factories/update-imports/update-ts-imports.js.map +1 -0
  78. package/rule-factories/update-imports/v7-to-v8-map-object.d.ts +8 -0
  79. package/rule-factories/update-imports/v7-to-v8-map-object.d.ts.map +1 -0
  80. package/rule-factories/update-imports/v7-to-v8-map-object.js +2049 -0
  81. package/rule-factories/update-imports/v7-to-v8-map-object.js.map +1 -0
  82. package/rule-factories/vscode-extensions/index.d.ts +8 -0
  83. package/rule-factories/vscode-extensions/index.d.ts.map +1 -0
  84. package/rule-factories/vscode-extensions/index.js +26 -0
  85. package/rule-factories/vscode-extensions/index.js.map +1 -0
  86. package/rules/index.d.ts +2 -0
  87. package/rules/index.d.ts.map +1 -0
  88. package/rules/index.js +5 -0
  89. package/rules/index.js.map +1 -0
  90. package/rules/install.d.ts +9 -0
  91. package/rules/install.d.ts.map +1 -0
  92. package/rules/install.js +21 -0
  93. package/rules/install.js.map +1 -0
  94. package/schematics/ng-add/index.js.map +1 -0
  95. package/schematics/ng-add/schema.js.map +1 -0
  96. package/tasks/eslint/index.d.ts +10 -0
  97. package/tasks/eslint/index.d.ts.map +1 -0
  98. package/tasks/eslint/index.js +29 -0
  99. package/tasks/eslint/index.js.map +1 -0
  100. package/tasks/index.d.ts +5 -0
  101. package/tasks/index.d.ts.map +1 -0
  102. package/tasks/index.js +8 -0
  103. package/tasks/index.js.map +1 -0
  104. package/tasks/link/index.d.ts +10 -0
  105. package/tasks/link/index.d.ts.map +1 -0
  106. package/tasks/link/index.js +26 -0
  107. package/tasks/link/index.js.map +1 -0
  108. package/tasks/ng-add/index.d.ts +30 -0
  109. package/tasks/ng-add/index.d.ts.map +1 -0
  110. package/tasks/ng-add/index.js +30 -0
  111. package/tasks/ng-add/index.js.map +1 -0
  112. package/tasks/package-manager/add-dev-dependency.d.ts +24 -0
  113. package/tasks/package-manager/add-dev-dependency.d.ts.map +1 -0
  114. package/tasks/package-manager/add-dev-dependency.js +34 -0
  115. package/tasks/package-manager/add-dev-dependency.js.map +1 -0
  116. package/tasks/package-manager/index.d.ts +4 -0
  117. package/tasks/package-manager/index.d.ts.map +1 -0
  118. package/tasks/package-manager/index.js +7 -0
  119. package/tasks/package-manager/index.js.map +1 -0
  120. package/tasks/package-manager/interfaces.d.ts +14 -0
  121. package/tasks/package-manager/interfaces.d.ts.map +1 -0
  122. package/tasks/package-manager/interfaces.js +3 -0
  123. package/tasks/package-manager/interfaces.js.map +1 -0
  124. package/tasks/package-manager/npm-install.d.ts +24 -0
  125. package/tasks/package-manager/npm-install.d.ts.map +1 -0
  126. package/tasks/package-manager/npm-install.js +35 -0
  127. package/tasks/package-manager/npm-install.js.map +1 -0
  128. package/utility/ast.d.ts +142 -0
  129. package/utility/ast.d.ts.map +1 -0
  130. package/utility/ast.js +325 -0
  131. package/utility/ast.js.map +1 -0
  132. package/utility/collection.d.ts +10 -0
  133. package/utility/collection.d.ts.map +1 -0
  134. package/utility/collection.js +20 -0
  135. package/utility/collection.js.map +1 -0
  136. package/utility/component.d.ts +46 -0
  137. package/utility/component.d.ts.map +1 -0
  138. package/utility/component.js +104 -0
  139. package/utility/component.js.map +1 -0
  140. package/utility/dependencies.d.ts +18 -0
  141. package/utility/dependencies.d.ts.map +1 -0
  142. package/utility/dependencies.js +31 -0
  143. package/utility/dependencies.js.map +1 -0
  144. package/utility/file-info.d.ts +23 -0
  145. package/utility/file-info.d.ts.map +1 -0
  146. package/utility/file-info.js +36 -0
  147. package/utility/file-info.js.map +1 -0
  148. package/utility/generation.d.ts +22 -0
  149. package/utility/generation.d.ts.map +1 -0
  150. package/utility/generation.js +67 -0
  151. package/utility/generation.js.map +1 -0
  152. package/utility/gitignore.d.ts +12 -0
  153. package/utility/gitignore.d.ts.map +1 -0
  154. package/utility/gitignore.js +28 -0
  155. package/utility/gitignore.js.map +1 -0
  156. package/utility/index.d.ts +18 -0
  157. package/utility/index.d.ts.map +1 -0
  158. package/utility/index.js +21 -0
  159. package/utility/index.js.map +1 -0
  160. package/utility/loaders.d.ts +122 -0
  161. package/utility/loaders.d.ts.map +1 -0
  162. package/utility/loaders.js +222 -0
  163. package/utility/loaders.js.map +1 -0
  164. package/utility/matching-peers.d.ts +24 -0
  165. package/utility/matching-peers.d.ts.map +1 -0
  166. package/utility/matching-peers.js +41 -0
  167. package/utility/matching-peers.js.map +1 -0
  168. package/utility/modules.d.ts +73 -0
  169. package/utility/modules.d.ts.map +1 -0
  170. package/utility/modules.js +201 -0
  171. package/utility/modules.js.map +1 -0
  172. package/utility/monorepo.d.ts +17 -0
  173. package/utility/monorepo.d.ts.map +1 -0
  174. package/utility/monorepo.js +30 -0
  175. package/utility/monorepo.js.map +1 -0
  176. package/utility/package-manager-runner.d.ts +43 -0
  177. package/utility/package-manager-runner.d.ts.map +1 -0
  178. package/utility/package-manager-runner.js +61 -0
  179. package/utility/package-manager-runner.js.map +1 -0
  180. package/utility/package-version.d.ts +17 -0
  181. package/utility/package-version.d.ts.map +1 -0
  182. package/utility/package-version.js +34 -0
  183. package/utility/package-version.js.map +1 -0
  184. package/utility/routes.d.ts +40 -0
  185. package/utility/routes.d.ts.map +1 -0
  186. package/utility/routes.js +103 -0
  187. package/utility/routes.js.map +1 -0
  188. package/utility/sub-entry.d.ts +18 -0
  189. package/utility/sub-entry.d.ts.map +1 -0
  190. package/utility/sub-entry.js +51 -0
  191. package/utility/sub-entry.js.map +1 -0
  192. package/utility/template-property.helper.d.ts +101 -0
  193. package/utility/template-property.helper.d.ts.map +1 -0
  194. package/utility/template-property.helper.js +175 -0
  195. package/utility/template-property.helper.js.map +1 -0
  196. package/utility/update-imports.d.ts +25 -0
  197. package/utility/update-imports.d.ts.map +1 -0
  198. package/utility/update-imports.js +86 -0
  199. package/utility/update-imports.js.map +1 -0
@@ -0,0 +1,142 @@
1
+ import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
2
+ /**
3
+ * Find the first node with the specific syntax kind
4
+ *
5
+ * @param sourceFile Typescript file
6
+ * @param searchKind Kind of syntax to look up
7
+ * @param node current node
8
+ */
9
+ export declare function findFirstNodeOfKind<T extends ts.Node = ts.Node>(sourceFile: ts.SourceFile, searchKind: ts.SyntaxKind, node?: ts.Node): T | null;
10
+ /**
11
+ * Find the last node with the specific syntax kind
12
+ *
13
+ * @param sourceFile Typescript file
14
+ * @param searchKind Kind of syntax to look up
15
+ * @param node current node
16
+ */
17
+ export declare function findLastNodeOfKind<T extends ts.Node = ts.Node>(sourceFile: ts.SourceFile, searchKind: ts.SyntaxKind, node?: ts.Node): T | null;
18
+ /**
19
+ * Reads all the imports of a given SourceFile and returns a parsed list that's easy to consume.
20
+ *
21
+ * @param sourceFile
22
+ */
23
+ export declare function parseImportsFromFile(sourceFile: ts.SourceFile): {
24
+ node: ts.ImportDeclaration;
25
+ symbols: string[];
26
+ module: string;
27
+ }[];
28
+ /**
29
+ * Given a program and a path to a source file, returns all the Symbols exported by the file.
30
+ *
31
+ * @param program
32
+ * @param sourcePath
33
+ */
34
+ export declare function getExportedSymbolsFromFile(program: ts.Program, sourcePath: string): ts.Symbol[];
35
+ /**
36
+ * Decorator with arguments
37
+ *
38
+ * @example `@Decorator({ propName: 'value' })`
39
+ */
40
+ export type DecoratorWithArg = ts.Decorator & {
41
+ expression: ts.CallExpression & {
42
+ expression: ts.Identifier;
43
+ };
44
+ };
45
+ /**
46
+ * Returns true if it is a decorator with arguments
47
+ *
48
+ * @param node decorator node
49
+ */
50
+ export declare const isDecoratorWithArg: (node: ts.Node) => node is DecoratorWithArg;
51
+ /**
52
+ * Returns the value of {@link argName} in the first argument
53
+ *
54
+ * @param decorator
55
+ * @param argName
56
+ */
57
+ export declare const getPropertyFromDecoratorFirstArgument: (decorator: DecoratorWithArg, argName: string) => ts.Expression | undefined;
58
+ /**
59
+ * Returns `ExpressionWithTypeArguments[]` of a class that implements {@link str}
60
+ *
61
+ * @param str
62
+ */
63
+ export declare const generateImplementsExpressionWithTypeArguments: (str: string) => ts.ExpressionWithTypeArguments[];
64
+ /**
65
+ * Returns `ClassElement[]` of a class that have {@link str} has body
66
+ *
67
+ * @param str
68
+ */
69
+ export declare const generateClassElementsFromString: (str: string) => ts.ClassElement[];
70
+ /**
71
+ * Returns `Statement[]` of a function that have {@link str} has body
72
+ *
73
+ * @param str
74
+ */
75
+ export declare const generateBlockStatementsFromString: (str: string) => ts.Statement[];
76
+ /**
77
+ * Returns `ParameterDeclaration[]` of a function that have {@link str} has parameters
78
+ *
79
+ * @param str
80
+ */
81
+ export declare const generateParametersDeclarationFromString: (str: string) => ts.ParameterDeclaration[];
82
+ /**
83
+ * Method to sort ClassElement based on the kind of it
84
+ * order will be PropertyDeclaration, Constructor then MethodDeclaration
85
+ *
86
+ * @param classElement1
87
+ * @param classElement2
88
+ */
89
+ export declare const sortClassElement: (classElement1: ts.ClassElement, classElement2: ts.ClassElement) => 1 | -1;
90
+ /**
91
+ * Returns a TransformerFactory to add an interface to a class
92
+ *
93
+ * @param interfaceToAdd
94
+ * @param classIdentifier
95
+ */
96
+ export declare const addInterfaceToClassTransformerFactory: (interfaceToAdd: string, classIdentifier?: (node: ts.ClassDeclaration) => boolean) => ts.TransformerFactory<ts.Node>;
97
+ /**
98
+ * Add comment on class properties
99
+ *
100
+ * @param classElements
101
+ * @param comments Dictionnary of comment indexed by properties' name
102
+ */
103
+ export declare const addCommentsOnClassProperties: (classElements: ts.ClassElement[], comments: Record<string, string>) => void;
104
+ /**
105
+ * Transformer to be used to fix the string literals generated by creating a new SourceFile (for instance, using #generateClassElementsFromString)
106
+ *
107
+ * @param ctx
108
+ */
109
+ export declare const fixStringLiterals: ts.TransformerFactory<ts.SourceFile>;
110
+ /**
111
+ * Returns a function to match classElement by method name
112
+ *
113
+ * @param methodName
114
+ */
115
+ export declare const findMethodByName: (methodName: string) => (classElement: ts.ClassElement) => classElement is ts.MethodDeclaration;
116
+ /**
117
+ * Add block statements to a method
118
+ *
119
+ * @param node
120
+ * @param factory
121
+ * @param methodName
122
+ * @param blockStatements
123
+ */
124
+ export declare const getSimpleUpdatedMethod: (node: ts.ClassDeclaration, factory: ts.NodeFactory, methodName: string, blockStatements: ts.Statement[]) => ts.MethodDeclaration;
125
+ /**
126
+ * Return true is the node is the ExpressionStatement of the TestBedConfiguration
127
+ *
128
+ * @param node
129
+ */
130
+ export declare const isTestBedConfiguration: (node: ts.Node) => node is ts.ExpressionStatement & {
131
+ expression: ts.CallExpression & {
132
+ expression: ts.PropertyAccessExpression;
133
+ };
134
+ };
135
+ /**
136
+ * TransformerFactory to add imports at spec initialization and code to be run just after
137
+ *
138
+ * @param imports
139
+ * @param code
140
+ */
141
+ export declare const addImportsAndCodeBlockStatementAtSpecInitializationTransformerFactory: (imports: (string | ts.Expression)[], code?: string) => ts.TransformerFactory<ts.Node>;
142
+ //# sourceMappingURL=ast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/utility/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gFAAgF,CAAC;AAGrG;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,CAa/I;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,CAc9I;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU;;;;IAc7D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,UA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WAAW,GAAG,WAAW,cAAc,MAAM,mBAAmB,GAAG,SAAS,EAAE,yBA2B7I,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,SAAU,OAAO;gBAAkD,GAAG,cAAc,GAAG;QAAE,UAAU,EAAE,GAAG,wBAAwB,CAAA;KAAE;CAOzF,CAAC;AAE7E;;;;;GAKG;AACH,eAAO,MAAM,qEAAqE,YACvE,CAAC,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,SAC5B,MAAM,KACZ,GAAG,kBAAkB,CAAC,OAAO,CAmD7B,CAAC"}
package/utility/ast.js ADDED
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addImportsAndCodeBlockStatementAtSpecInitializationTransformerFactory = exports.isTestBedConfiguration = exports.getSimpleUpdatedMethod = exports.findMethodByName = exports.fixStringLiterals = exports.addCommentsOnClassProperties = exports.addInterfaceToClassTransformerFactory = exports.sortClassElement = exports.generateParametersDeclarationFromString = exports.generateBlockStatementsFromString = exports.generateClassElementsFromString = exports.generateImplementsExpressionWithTypeArguments = exports.getPropertyFromDecoratorFirstArgument = exports.isDecoratorWithArg = exports.getExportedSymbolsFromFile = exports.parseImportsFromFile = exports.findLastNodeOfKind = exports.findFirstNodeOfKind = void 0;
4
+ const ts = require("@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript");
5
+ const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
6
+ /**
7
+ * Find the first node with the specific syntax kind
8
+ *
9
+ * @param sourceFile Typescript file
10
+ * @param searchKind Kind of syntax to look up
11
+ * @param node current node
12
+ */
13
+ function findFirstNodeOfKind(sourceFile, searchKind, node) {
14
+ const currentNode = node || sourceFile;
15
+ let ret = null;
16
+ currentNode.forEachChild((n) => {
17
+ if (!ret) {
18
+ if (n.kind === searchKind) {
19
+ ret = n;
20
+ }
21
+ else {
22
+ ret = findFirstNodeOfKind(sourceFile, searchKind, n);
23
+ }
24
+ }
25
+ });
26
+ return ret;
27
+ }
28
+ exports.findFirstNodeOfKind = findFirstNodeOfKind;
29
+ /**
30
+ * Find the last node with the specific syntax kind
31
+ *
32
+ * @param sourceFile Typescript file
33
+ * @param searchKind Kind of syntax to look up
34
+ * @param node current node
35
+ */
36
+ function findLastNodeOfKind(sourceFile, searchKind, node) {
37
+ const currentNode = node || sourceFile;
38
+ let ret = null;
39
+ currentNode.forEachChild((n) => {
40
+ if (n.kind === searchKind) {
41
+ ret = ret && ret.pos > n.pos ? ret : n;
42
+ }
43
+ else {
44
+ const found = findLastNodeOfKind(sourceFile, searchKind, n);
45
+ if (found) {
46
+ ret = !ret ? found : (found.pos > ret.pos ? found : ret);
47
+ }
48
+ }
49
+ });
50
+ return ret;
51
+ }
52
+ exports.findLastNodeOfKind = findLastNodeOfKind;
53
+ /**
54
+ * Reads all the imports of a given SourceFile and returns a parsed list that's easy to consume.
55
+ *
56
+ * @param sourceFile
57
+ */
58
+ function parseImportsFromFile(sourceFile) {
59
+ // First we look for all imports lines targeting an Otter package for which we know a mapping
60
+ return (0, ast_utils_1.findNodes)(sourceFile, ts.SyntaxKind.ImportDeclaration).map((nodeImp) => {
61
+ const imp = nodeImp;
62
+ const importFrom = imp.moduleSpecifier.getText().replace(/['"]/g, '');
63
+ // We retrieve all the symbols listed in the import statement
64
+ const namedImport = imp.importClause && imp.importClause.getChildAt(0);
65
+ const imports = namedImport && ts.isNamedImports(namedImport) ?
66
+ namedImport.elements.map((element) => element.getText()) :
67
+ [];
68
+ return { node: imp, symbols: imports, module: importFrom };
69
+ });
70
+ }
71
+ exports.parseImportsFromFile = parseImportsFromFile;
72
+ /**
73
+ * Given a program and a path to a source file, returns all the Symbols exported by the file.
74
+ *
75
+ * @param program
76
+ * @param sourcePath
77
+ */
78
+ function getExportedSymbolsFromFile(program, sourcePath) {
79
+ const typeChecker = program.getTypeChecker();
80
+ const sourceFile = program.getSourceFiles().find((file) => {
81
+ return file.fileName === sourcePath;
82
+ });
83
+ if (!sourceFile) {
84
+ return [];
85
+ }
86
+ const symbol = typeChecker.getSymbolAtLocation(sourceFile);
87
+ return typeChecker.getExportsOfModule(symbol);
88
+ }
89
+ exports.getExportedSymbolsFromFile = getExportedSymbolsFromFile;
90
+ /**
91
+ * Returns true if it is a decorator with arguments
92
+ *
93
+ * @param node decorator node
94
+ */
95
+ const isDecoratorWithArg = (node) => ts.isDecorator(node)
96
+ && ts.isCallExpression(node.expression)
97
+ && ts.isIdentifier(node.expression.expression);
98
+ exports.isDecoratorWithArg = isDecoratorWithArg;
99
+ /**
100
+ * Returns the value of {@link argName} in the first argument
101
+ *
102
+ * @param decorator
103
+ * @param argName
104
+ */
105
+ const getPropertyFromDecoratorFirstArgument = (decorator, argName) => {
106
+ const ngClassDecoratorArgument = decorator.expression.arguments[0];
107
+ if (ts.isObjectLiteralExpression(ngClassDecoratorArgument)) {
108
+ return ngClassDecoratorArgument.properties.find((prop) => ts.isPropertyAssignment(prop)
109
+ && ts.isIdentifier(prop.name)
110
+ && prop.name.escapedText.toString() === argName)?.initializer;
111
+ }
112
+ };
113
+ exports.getPropertyFromDecoratorFirstArgument = getPropertyFromDecoratorFirstArgument;
114
+ /**
115
+ * Returns `ExpressionWithTypeArguments[]` of a class that implements {@link str}
116
+ *
117
+ * @param str
118
+ */
119
+ const generateImplementsExpressionWithTypeArguments = (str) => {
120
+ const sourceFile = ts.createSourceFile('index.ts', `class A implements ${str} {}`, ts.ScriptTarget.ES2020, true);
121
+ return [...sourceFile.statements[0].heritageClauses[0].types];
122
+ };
123
+ exports.generateImplementsExpressionWithTypeArguments = generateImplementsExpressionWithTypeArguments;
124
+ /**
125
+ * Returns `ClassElement[]` of a class that have {@link str} has body
126
+ *
127
+ * @param str
128
+ */
129
+ const generateClassElementsFromString = (str) => {
130
+ const sourceFile = ts.createSourceFile('index.ts', `class A {
131
+ ${str}
132
+ }`, ts.ScriptTarget.ES2020, true);
133
+ return [...sourceFile.statements[0].members];
134
+ };
135
+ exports.generateClassElementsFromString = generateClassElementsFromString;
136
+ /**
137
+ * Returns `Statement[]` of a function that have {@link str} has body
138
+ *
139
+ * @param str
140
+ */
141
+ const generateBlockStatementsFromString = (str) => {
142
+ const sourceFile = ts.createSourceFile('index.ts', `function func() {
143
+ ${str.replace(/^\s*/g, '')}
144
+ }`, ts.ScriptTarget.ES2020, true);
145
+ return [...sourceFile.statements[0].body.statements];
146
+ };
147
+ exports.generateBlockStatementsFromString = generateBlockStatementsFromString;
148
+ /**
149
+ * Returns `ParameterDeclaration[]` of a function that have {@link str} has parameters
150
+ *
151
+ * @param str
152
+ */
153
+ const generateParametersDeclarationFromString = (str) => {
154
+ const sourceFile = ts.createSourceFile('index.ts', `function func(${str}) {}`, ts.ScriptTarget.ES2020, true);
155
+ return [...sourceFile.statements[0].parameters];
156
+ };
157
+ exports.generateParametersDeclarationFromString = generateParametersDeclarationFromString;
158
+ /**
159
+ * Method to sort ClassElement based on the kind of it
160
+ * order will be PropertyDeclaration, Constructor then MethodDeclaration
161
+ *
162
+ * @param classElement1
163
+ * @param classElement2
164
+ */
165
+ const sortClassElement = (classElement1, classElement2) => {
166
+ switch (classElement1.kind) {
167
+ case ts.SyntaxKind.PropertyDeclaration: {
168
+ return -1;
169
+ }
170
+ case ts.SyntaxKind.Constructor: {
171
+ switch (classElement2.kind) {
172
+ case ts.SyntaxKind.PropertyDeclaration: {
173
+ return 1;
174
+ }
175
+ case ts.SyntaxKind.MethodDeclaration: {
176
+ return -1;
177
+ }
178
+ default: {
179
+ return -1;
180
+ }
181
+ }
182
+ }
183
+ case ts.SyntaxKind.MethodDeclaration: {
184
+ return 1;
185
+ }
186
+ default: {
187
+ return 1;
188
+ }
189
+ }
190
+ };
191
+ exports.sortClassElement = sortClassElement;
192
+ /**
193
+ * Returns a TransformerFactory to add an interface to a class
194
+ *
195
+ * @param interfaceToAdd
196
+ * @param classIdentifier
197
+ */
198
+ const addInterfaceToClassTransformerFactory = (interfaceToAdd, classIdentifier = () => true) => {
199
+ return (ctx) => (rootNode) => {
200
+ const { factory } = ctx;
201
+ const visit = (node) => {
202
+ if (ts.isClassDeclaration(node) && classIdentifier(node)) {
203
+ const implementsClauses = node.heritageClauses?.find((heritageClause) => heritageClause.token === ts.SyntaxKind.ImplementsKeyword);
204
+ const interfaceToImplements = (0, exports.generateImplementsExpressionWithTypeArguments)(interfaceToAdd);
205
+ const newImplementsClauses = implementsClauses
206
+ ? factory.updateHeritageClause(implementsClauses, [...implementsClauses.types, ...interfaceToImplements])
207
+ : factory.createHeritageClause(ts.SyntaxKind.ImplementsKeyword, [...interfaceToImplements]);
208
+ const heritageClauses = [...(node.heritageClauses || [])]
209
+ .filter((h) => h.token !== ts.SyntaxKind.ImplementsKeyword)
210
+ .concat(newImplementsClauses);
211
+ const newModifiers = []
212
+ .concat(ts.getDecorators(node) || [])
213
+ .concat(ts.getModifiers(node) || []);
214
+ return factory.updateClassDeclaration(node, newModifiers, node.name, node.typeParameters, heritageClauses, node.members);
215
+ }
216
+ return ts.visitEachChild(node, visit, ctx);
217
+ };
218
+ return ts.visitNode(rootNode, visit);
219
+ };
220
+ };
221
+ exports.addInterfaceToClassTransformerFactory = addInterfaceToClassTransformerFactory;
222
+ /**
223
+ * Add comment on class properties
224
+ *
225
+ * @param classElements
226
+ * @param comments Dictionnary of comment indexed by properties' name
227
+ */
228
+ const addCommentsOnClassProperties = (classElements, comments) => {
229
+ classElements.filter((classElement) => ts.isPropertyDeclaration(classElement)
230
+ && ts.isIdentifier(classElement.name)).forEach((classElement) => {
231
+ const comment = comments[classElement.name.escapedText.toString()];
232
+ if (!comment) {
233
+ return;
234
+ }
235
+ ts.addSyntheticLeadingComment(classElement, ts.SyntaxKind.MultiLineCommentTrivia, `* ${comment}`, true);
236
+ });
237
+ };
238
+ exports.addCommentsOnClassProperties = addCommentsOnClassProperties;
239
+ /**
240
+ * Transformer to be used to fix the string literals generated by creating a new SourceFile (for instance, using #generateClassElementsFromString)
241
+ *
242
+ * @param ctx
243
+ */
244
+ const fixStringLiterals = (ctx) => (rootNode) => {
245
+ const { factory } = ctx;
246
+ const visit = (node) => {
247
+ if (node.kind === ts.SyntaxKind.StringLiteral) {
248
+ return factory.createStringLiteral(node.getText().replace(/^["'](.*)["']$/, '$1'), true);
249
+ }
250
+ return ts.visitEachChild(node, visit, ctx);
251
+ };
252
+ return ts.visitNode(rootNode, visit);
253
+ };
254
+ exports.fixStringLiterals = fixStringLiterals;
255
+ /**
256
+ * Returns a function to match classElement by method name
257
+ *
258
+ * @param methodName
259
+ */
260
+ const findMethodByName = (methodName) => (classElement) => ts.isMethodDeclaration(classElement)
261
+ && ts.isIdentifier(classElement.name)
262
+ && classElement.name.escapedText.toString() === methodName;
263
+ exports.findMethodByName = findMethodByName;
264
+ /**
265
+ * Add block statements to a method
266
+ *
267
+ * @param node
268
+ * @param factory
269
+ * @param methodName
270
+ * @param blockStatements
271
+ */
272
+ const getSimpleUpdatedMethod = (node, factory, methodName, blockStatements) => {
273
+ const originalMethod = node.members.find((0, exports.findMethodByName)(methodName));
274
+ return originalMethod
275
+ ? factory.updateMethodDeclaration(originalMethod, ts.getModifiers(originalMethod), originalMethod.asteriskToken, originalMethod.name, originalMethod.questionToken, originalMethod.typeParameters, originalMethod.parameters, originalMethod.type, originalMethod.body
276
+ ? factory.updateBlock(originalMethod.body, originalMethod.body.statements.concat(blockStatements)) : factory.createBlock(blockStatements, true)) : factory.createMethodDeclaration([factory.createToken(ts.SyntaxKind.PublicKeyword)], undefined, factory.createIdentifier(methodName), undefined, undefined, [], undefined, factory.createBlock(blockStatements, true));
277
+ };
278
+ exports.getSimpleUpdatedMethod = getSimpleUpdatedMethod;
279
+ /**
280
+ * Return true is the node is the ExpressionStatement of the TestBedConfiguration
281
+ *
282
+ * @param node
283
+ */
284
+ const isTestBedConfiguration = (node) => (ts.isExpressionStatement(node)
285
+ && ts.isCallExpression(node.expression)
286
+ && ts.isPropertyAccessExpression(node.expression.expression)
287
+ && ts.isIdentifier(node.expression.expression.expression)
288
+ && node.expression.expression.expression.escapedText.toString() === 'TestBed'
289
+ && node.expression.expression.name.escapedText.toString() === 'configureTestingModule')
290
+ || (ts.isAwaitExpression(node) && (0, exports.isTestBedConfiguration)(node.expression));
291
+ exports.isTestBedConfiguration = isTestBedConfiguration;
292
+ /**
293
+ * TransformerFactory to add imports at spec initialization and code to be run just after
294
+ *
295
+ * @param imports
296
+ * @param code
297
+ */
298
+ const addImportsAndCodeBlockStatementAtSpecInitializationTransformerFactory = (imports, code) => (ctx) => (rootNode) => {
299
+ const { factory } = ctx;
300
+ const visit = (node) => {
301
+ if (ts.isBlock(node) && !!node.statements.find(exports.isTestBedConfiguration)) {
302
+ return factory.updateBlock(node, node.statements
303
+ .reduce((acc, statement) => {
304
+ if ((0, exports.isTestBedConfiguration)(statement)) {
305
+ const firstArgProps = statement.expression.arguments[0].properties;
306
+ const importsProp = firstArgProps.find((prop) => prop.name?.getText() === 'imports');
307
+ return acc.concat(factory.updateExpressionStatement(statement, factory.updateCallExpression(statement.expression, statement.expression.expression, statement.expression.typeArguments, [
308
+ factory.createObjectLiteralExpression([
309
+ ...firstArgProps.filter((prop) => prop.name?.getText() !== 'imports'),
310
+ factory.createPropertyAssignment('imports', factory.createArrayLiteralExpression((importsProp
311
+ ? [...importsProp.initializer.elements]
312
+ : []).concat(imports.map((importName) => typeof importName === 'string' ? factory.createIdentifier(importName) : importName)), true))
313
+ ], true)
314
+ ])));
315
+ }
316
+ return acc.concat(statement);
317
+ }, [])
318
+ .concat(code ? (0, exports.generateBlockStatementsFromString)(code) : []));
319
+ }
320
+ return ts.visitEachChild(node, visit, ctx);
321
+ };
322
+ return ts.visitNode(rootNode, visit);
323
+ };
324
+ exports.addImportsAndCodeBlockStatementAtSpecInitializationTransformerFactory = addImportsAndCodeBlockStatementAtSpecInitializationTransformerFactory;
325
+ //# sourceMappingURL=ast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/utility/ast.ts"],"names":[],"mappings":";;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,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC,CAAC;IACF,OAAO,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC,CAAC;AAtDS,QAAA,qEAAqE,yEAsD9E"}
@@ -0,0 +1,10 @@
1
+ import type { WorkspaceSchema } from '../interfaces';
2
+ /**
3
+ * Register the collection schematic to the workspace
4
+ *
5
+ * @param workspace Workspace to add the collection to
6
+ * @param collection Collection to add to the workspace schematic collection
7
+ * @returns the updated workspace
8
+ */
9
+ export declare function registerCollectionSchematics(workspace: WorkspaceSchema, collection: string): WorkspaceSchema;
10
+ //# sourceMappingURL=collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/utility/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe,CAO5G"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerCollectionSchematics = void 0;
4
+ /**
5
+ * Register the collection schematic to the workspace
6
+ *
7
+ * @param workspace Workspace to add the collection to
8
+ * @param collection Collection to add to the workspace schematic collection
9
+ * @returns the updated workspace
10
+ */
11
+ function registerCollectionSchematics(workspace, collection) {
12
+ workspace.cli ||= {};
13
+ workspace.cli.schematicCollections ||= ['@schematics/angular'];
14
+ if (!workspace.cli.schematicCollections.includes(collection)) {
15
+ workspace.cli.schematicCollections.unshift(collection);
16
+ }
17
+ return workspace;
18
+ }
19
+ exports.registerCollectionSchematics = registerCollectionSchematics;
20
+ //# sourceMappingURL=collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/utility/collection.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAAC,SAA0B,EAAE,UAAkB;IACzF,SAAS,CAAC,GAAG,KAAK,EAAE,CAAC;IACrB,SAAS,CAAC,GAAG,CAAC,oBAAoB,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC/D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QAC5D,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;KACxD;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAPD,oEAOC"}
@@ -0,0 +1,46 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ import * as ts from 'typescript';
3
+ import { DecoratorWithArg } from './ast';
4
+ /**
5
+ * Returns true if `node` is the decorator of an Angular component
6
+ *
7
+ * @param node
8
+ */
9
+ export declare const isNgClassDecorator: (node: ts.Node) => node is DecoratorWithArg;
10
+ /**
11
+ * Returns true if `node` is the decorator of an Otter component
12
+ *
13
+ * @param node
14
+ */
15
+ export declare const isO3rClassDecorator: (node: ts.Node) => node is DecoratorWithArg;
16
+ /**
17
+ * Returns true if `classDeclaration` is an Otter component
18
+ *
19
+ * @param classDeclaration
20
+ */
21
+ export declare const isNgClassComponent: (classDeclaration: ts.ClassDeclaration) => boolean;
22
+ /**
23
+ * Returns true if `classDeclaration` is an Otter component
24
+ *
25
+ * @param classDeclaration
26
+ */
27
+ export declare const isO3rClassComponent: (classDeclaration: ts.ClassDeclaration) => boolean;
28
+ /**
29
+ * Returns Otter component information
30
+ *
31
+ * @param tree
32
+ * @param componentPath
33
+ */
34
+ export declare const getO3rComponentInfoOrThrowIfNotFound: (tree: Tree, componentPath: string) => {
35
+ name: string;
36
+ selector: string;
37
+ standalone: boolean;
38
+ templateRelativePath: string | undefined;
39
+ };
40
+ /**
41
+ * Transformer factory to add imports into the angular component decorator
42
+ *
43
+ * @param imports
44
+ */
45
+ export declare const addImportsIntoComponentDecoratorTransformerFactory: (imports: string[]) => ts.TransformerFactory<ts.Node>;
46
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/utility/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAA6D,MAAM,OAAO,CAAC;AAEpG;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,SAAU,OAAO,6BAEsB,CAAC;AAEvE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,SAAU,OAAO,6BAEwB,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,qBAAsB,GAAG,gBAAgB,YAAwE,CAAC;AAEjJ;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,qBAAsB,GAAG,gBAAgB,YAEA,CAAC;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,SAAU,IAAI,iBAAiB,MAAM;;;;;CAgErF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kDAAkD,YACpD,MAAM,EAAE,KAChB,GAAG,kBAAkB,CAAC,OAAO,CA4B/B,CAAC"}