@o3r/schematics 9.1.0-alpha.21 → 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,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLibraryNameFromPath = exports.getComponentConfigKey = exports.getComponentFixtureName = exports.getComponentContextName = exports.getComponentTranslationName = exports.getComponentConfigName = exports.getKebabCaseBlockName = exports.getComponentBlockName = exports.getComponentName = exports.getComponentAnalyticsName = exports.getComponentModuleName = exports.getComponentSelectorWithoutSuffix = exports.getComponentFileName = exports.getComponentFolderName = exports.getInputComponentName = void 0;
4
+ const core_1 = require("@angular-devkit/core");
5
+ /**
6
+ * Returns all elements from the provided component name path
7
+ *
8
+ * @param componentName
9
+ */
10
+ function getComponentModuleItems(componentName) {
11
+ return (componentName || '').split('\\/');
12
+ }
13
+ /**
14
+ * Returns the component name as the last element of the provided component name path
15
+ *
16
+ * @param componentName
17
+ */
18
+ function getInputComponentName(componentName) {
19
+ const componentModuleItems = getComponentModuleItems(componentName);
20
+ return componentModuleItems[componentModuleItems.length - 1];
21
+ }
22
+ exports.getInputComponentName = getInputComponentName;
23
+ /**
24
+ * returns the component folder name
25
+ *
26
+ * @param componentName
27
+ */
28
+ function getComponentFolderName(componentName) {
29
+ const inputComponentName = getInputComponentName(componentName);
30
+ return core_1.strings.dasherize(inputComponentName).replace(/\s/g, '');
31
+ }
32
+ exports.getComponentFolderName = getComponentFolderName;
33
+ /**
34
+ * Returns the component file name
35
+ *
36
+ * @param componentName
37
+ * @param componentStructureDef
38
+ */
39
+ function getComponentFileName(componentName, componentStructureDef) {
40
+ const componentFolderName = getComponentFolderName(componentName);
41
+ return componentStructureDef ? `${componentFolderName}-${core_1.strings.camelize(componentStructureDef)}` : componentFolderName;
42
+ }
43
+ exports.getComponentFileName = getComponentFileName;
44
+ /**
45
+ * Returns the component selector without suffix
46
+ *
47
+ * @param componentName
48
+ * @param prefix
49
+ */
50
+ function getComponentSelectorWithoutSuffix(componentName, prefix) {
51
+ const selector = getComponentFolderName(componentName);
52
+ return prefix ? `${prefix.toLowerCase()}-${selector}` : selector; // o3r-air-offer : air-offer
53
+ }
54
+ exports.getComponentSelectorWithoutSuffix = getComponentSelectorWithoutSuffix;
55
+ /**
56
+ * Returns the component module name (e.g. AirOfferModule)
57
+ *
58
+ * @param componentName
59
+ * @param componentStructureDef
60
+ */
61
+ function getComponentModuleName(componentName, componentStructureDef) {
62
+ const inputComponentName = getInputComponentName(componentName);
63
+ return `${core_1.strings.classify(inputComponentName)}${core_1.strings.classify(componentStructureDef)}Module`;
64
+ }
65
+ exports.getComponentModuleName = getComponentModuleName;
66
+ /**
67
+ * Returns the component analytics name (e.g. AirOfferAnalytics)
68
+ *
69
+ * @param componentName
70
+ * @param componentStructureDef
71
+ */
72
+ function getComponentAnalyticsName(componentName, componentStructureDef) {
73
+ const inputComponentName = getInputComponentName(componentName);
74
+ return `${core_1.strings.classify(inputComponentName)}${core_1.strings.classify(componentStructureDef)}Analytics`;
75
+ }
76
+ exports.getComponentAnalyticsName = getComponentAnalyticsName;
77
+ /**
78
+ * Returns the component name (e.g. AirOfferComponent)
79
+ *
80
+ * @param componentName
81
+ * @param componentStructureDef
82
+ */
83
+ function getComponentName(componentName, componentStructureDef) {
84
+ const inputComponentName = getInputComponentName(componentName);
85
+ return `${core_1.strings.classify(inputComponentName)}${core_1.strings.classify(componentStructureDef)}Component`;
86
+ }
87
+ exports.getComponentName = getComponentName;
88
+ /**
89
+ * Returns the component block name (e.g. AirOffer)
90
+ *
91
+ * @param componentName
92
+ */
93
+ function getComponentBlockName(componentName) {
94
+ const inputComponentName = getInputComponentName(componentName);
95
+ return core_1.strings.classify(inputComponentName);
96
+ }
97
+ exports.getComponentBlockName = getComponentBlockName;
98
+ /**
99
+ * Return the component in kebab-case (e.g. air-offer)
100
+ *
101
+ * @param blockName
102
+ */
103
+ function getKebabCaseBlockName(blockName) {
104
+ return core_1.strings.dasherize(blockName);
105
+ }
106
+ exports.getKebabCaseBlockName = getKebabCaseBlockName;
107
+ /**
108
+ * Returns the component config name (e.g. AirOfferConfig)
109
+ *
110
+ * @param componentName
111
+ * @param componentStructureDef
112
+ */
113
+ function getComponentConfigName(componentName, componentStructureDef) {
114
+ const inputComponentName = getInputComponentName(componentName);
115
+ return `${core_1.strings.classify(inputComponentName)}${core_1.strings.classify(componentStructureDef)}Config`;
116
+ }
117
+ exports.getComponentConfigName = getComponentConfigName;
118
+ /**
119
+ * Returns the component translation name (e.g. AirOfferTranslation)
120
+ *
121
+ * @param componentName
122
+ * @param componentStructureDef
123
+ */
124
+ function getComponentTranslationName(componentName, componentStructureDef) {
125
+ const inputComponentName = getInputComponentName(componentName);
126
+ return `${core_1.strings.classify(inputComponentName)}${core_1.strings.classify(componentStructureDef)}Translation`;
127
+ }
128
+ exports.getComponentTranslationName = getComponentTranslationName;
129
+ /**
130
+ * Returns the component context name (e.g. AirOfferContext)
131
+ *
132
+ * @param componentName
133
+ * @param componentStructureDef
134
+ */
135
+ function getComponentContextName(componentName, componentStructureDef) {
136
+ const inputComponentName = getInputComponentName(componentName);
137
+ return `${core_1.strings.classify(inputComponentName)}${core_1.strings.classify(componentStructureDef)}Context`;
138
+ }
139
+ exports.getComponentContextName = getComponentContextName;
140
+ /**
141
+ * Returns the component fixture name (e.g. AirOfferFixture)
142
+ *
143
+ * @param componentName
144
+ * @param componentStructureDef
145
+ */
146
+ function getComponentFixtureName(componentName, componentStructureDef) {
147
+ const inputComponentName = getInputComponentName(componentName);
148
+ return `${core_1.strings.classify(inputComponentName)}${core_1.strings.classify(componentStructureDef)}Fixture`;
149
+ }
150
+ exports.getComponentFixtureName = getComponentFixtureName;
151
+ /**
152
+ * Returns the component config key name (e.g. AIR_OFFER_CONT or AIR_OFFER_PRES)
153
+ *
154
+ * @param componentName
155
+ * @param componentStructureDef
156
+ */
157
+ function getComponentConfigKey(componentName, componentStructureDef) {
158
+ const componentFileName = getComponentFileName(componentName, componentStructureDef);
159
+ return `${core_1.strings.underscore(componentFileName).toUpperCase()}`;
160
+ }
161
+ exports.getComponentConfigKey = getComponentConfigKey;
162
+ /**
163
+ * Return the library name from path in a monorepos
164
+ *
165
+ * @param path
166
+ */
167
+ function getLibraryNameFromPath(path) {
168
+ if (!path) {
169
+ return null;
170
+ }
171
+ const libNameRes = /@[^@/]+\/[^/]+/.exec(path.replace(/\\/g, '/'));
172
+ return libNameRes && libNameRes[0];
173
+ }
174
+ exports.getLibraryNameFromPath = getLibraryNameFromPath;
175
+ //# sourceMappingURL=template-property.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-property.helper.js","sourceRoot":"","sources":["../../src/utility/template-property.helper.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAE7C;;;;GAIG;AACH,SAAS,uBAAuB,CAAC,aAAqB;IACpD,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,aAAqB;IACzD,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,aAAa,CAAC,CAAC;IACpE,OAAO,oBAAoB,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC/D,CAAC;AAHD,sDAGC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,aAAqB;IAC1D,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAChE,OAAO,cAAO,CAAC,SAAS,CAAC,kBAAkB,CAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC;AAHD,wDAGC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,aAAqB,EAAE,qBAA6B;IACvF,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;IAClE,OAAO,qBAAqB,CAAC,CAAC,CAAC,GAAG,mBAAmB,IAAI,cAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC;AAC3H,CAAC;AAHD,oDAGC;AAED;;;;;GAKG;AACH,SAAgB,iCAAiC,CAAC,aAAqB,EAAE,MAAqB;IAC5F,MAAM,QAAQ,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI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AE,EAAE,CAAC;AAClE,CAAC;AAHD,sDAGC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,IAA+B;IACpE,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IACD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IACnE,OAAO,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAND,wDAMC"}
@@ -0,0 +1,25 @@
1
+ import * as ts from 'typescript';
2
+ import { logging } from '@angular-devkit/core';
3
+ import type { Tree } from '@angular-devkit/schematics';
4
+ /** Map containing all import changes in otter packages */
5
+ export interface ImportsMapping {
6
+ [packageName: string]: {
7
+ [importName: string]: {
8
+ newPackage: string;
9
+ newValue?: string;
10
+ };
11
+ };
12
+ }
13
+ /**
14
+ * Update the imports of a given file according to replace mapping
15
+ *
16
+ * @param logger Logger to report messages
17
+ * @param tree File System tree
18
+ * @param sourceFile Source file to analyze
19
+ * @param importsRegexp Regexp of the imports to replace
20
+ * @param renamePackagesRegexp Regexp of the packages to replace
21
+ * @param mapImports Map of the import to replace
22
+ * @param renamedPackages Map of the import package to replace
23
+ */
24
+ export declare function updateImportsInFile(logger: logging.LoggerApi, tree: Tree, sourceFile: ts.SourceFile, importsRegexp: RegExp, renamePackagesRegexp: RegExp, mapImports?: ImportsMapping, renamedPackages?: Record<string, string>): number;
25
+ //# sourceMappingURL=update-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-imports.d.ts","sourceRoot":"","sources":["../../src/utility/update-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAavD,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,CAAC,WAAW,EAAE,MAAM,GAAG;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC5F;AAGD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,CAAC,SAAS,EACzB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,MAAM,EAC5B,UAAU,GAAE,cAAmB,EAC/B,eAAe,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,UAkF7C"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateImportsInFile = void 0;
4
+ const ts = require("typescript");
5
+ const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
6
+ /**
7
+ * Update the imports of a given file according to replace mapping
8
+ *
9
+ * @param logger Logger to report messages
10
+ * @param tree File System tree
11
+ * @param sourceFile Source file to analyze
12
+ * @param importsRegexp Regexp of the imports to replace
13
+ * @param renamePackagesRegexp Regexp of the packages to replace
14
+ * @param mapImports Map of the import to replace
15
+ * @param renamedPackages Map of the import package to replace
16
+ */
17
+ function updateImportsInFile(logger, tree, sourceFile, importsRegexp, renamePackagesRegexp, mapImports = {}, renamedPackages = {}) {
18
+ const oldImportedSymbolsPerPackage = {};
19
+ const unResolvedImports = [];
20
+ const importNodes = [];
21
+ // First we look for all imports lines targeting an Otter package for which we know a mapping
22
+ (0, ast_utils_1.findNodes)(sourceFile, ts.SyntaxKind.ImportDeclaration).map((nodeImp) => {
23
+ const imp = nodeImp;
24
+ const importFrom = imp.moduleSpecifier.getText().replace(/['"]/g, '');
25
+ const renamePackageMatch = importFrom.match(renamePackagesRegexp);
26
+ const otterPackage = renamePackageMatch ? renamePackageMatch[0] : importFrom.match(importsRegexp)?.[0];
27
+ // If the import matched an Otter package
28
+ if (otterPackage) {
29
+ if (!oldImportedSymbolsPerPackage[otterPackage]) {
30
+ oldImportedSymbolsPerPackage[otterPackage] = [];
31
+ }
32
+ // We store the import line to be able to remove it afterwards
33
+ importNodes.push(imp);
34
+ // We retrieve all the symbols listed in the import statement
35
+ const namedImport = imp.importClause && imp.importClause.getChildAt(0);
36
+ const imports = namedImport && ts.isNamedImports(namedImport) ?
37
+ namedImport.elements.map((element) => ({ symbol: element.getText(), location: importFrom })) :
38
+ [];
39
+ // And associate them to the Otter package
40
+ oldImportedSymbolsPerPackage[otterPackage].push(...imports);
41
+ }
42
+ });
43
+ // If did not capture any interesting import line, do nothing
44
+ if (importNodes.length === 0) {
45
+ return 0;
46
+ }
47
+ // Iterate over the imports and look into the renamed packages and into the map to see the import new module
48
+ // If no mapping is found, we keep the original import location
49
+ const resolvedImports = Object.entries(oldImportedSymbolsPerPackage).reduce((acc, [oldPackageName, importsFromOldPackage]) => {
50
+ importsFromOldPackage.forEach((importSymbol) => {
51
+ let newPackageNameImport;
52
+ if (Object.keys(renamedPackages).indexOf(oldPackageName) > 0) {
53
+ newPackageNameImport = importSymbol.location.replace(oldPackageName, renamedPackages[oldPackageName]);
54
+ }
55
+ else {
56
+ newPackageNameImport = mapImports[oldPackageName]?.[importSymbol.symbol]?.newPackage;
57
+ }
58
+ const importFrom = newPackageNameImport || importSymbol.location;
59
+ if (!newPackageNameImport) {
60
+ unResolvedImports.push(importSymbol);
61
+ }
62
+ if (!acc[importFrom]) {
63
+ acc[importFrom] = [];
64
+ }
65
+ const newNameForExportedValue = mapImports[oldPackageName]?.[importSymbol.symbol]?.newValue;
66
+ acc[importFrom].push(newNameForExportedValue || importSymbol.symbol);
67
+ });
68
+ return acc;
69
+ }, {});
70
+ // Remove captured imports
71
+ const fileWithoutImports = tree.read(sourceFile.fileName).toString()
72
+ .replace(new RegExp(`(${importNodes.map((node) => node.getText()).join('|')})[\\n\\r]*`, 'g'), '');
73
+ // Add the computed imports at the top of the file
74
+ const fileWithNewImports = Object.entries(resolvedImports)
75
+ .map(([importFrom, imports]) => `import {${imports.join(', ')}} from '${importFrom}';`)
76
+ .join('\n') + '\n' + fileWithoutImports;
77
+ tree.overwrite(sourceFile.fileName, fileWithNewImports);
78
+ // Log details about imports for which we could not find an associated sub-entry
79
+ if (unResolvedImports.length > 0) {
80
+ logger.warn(`Some imports in file ${sourceFile.fileName} could not be resolved:`);
81
+ unResolvedImports.forEach((unResolvedImport) => logger.warn(` |-- symbol "${unResolvedImport.symbol}" from module "${unResolvedImport.location}"`));
82
+ }
83
+ return unResolvedImports.length;
84
+ }
85
+ exports.updateImportsInFile = updateImportsInFile;
86
+ //# sourceMappingURL=update-imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-imports.js","sourceRoot":"","sources":["../../src/utility/update-imports.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,qEAAkE;AAoBlE;;;;;;;;;;GAUG;AACH,SAAgB,mBAAmB,CACjC,MAAyB,EACzB,IAAU,EACV,UAAyB,EACzB,aAAqB,EACrB,oBAA4B,EAC5B,aAA6B,EAAE,EAC/B,kBAA0C,EAAE;IAE5C,MAAM,4BAA4B,GAAsC,EAAE,CAAC;IAC3E,MAAM,iBAAiB,GAAsB,EAAE,CAAC;IAChD,MAAM,WAAW,GAA2B,EAAE,CAAC;IAE/C,6FAA6F;IAC7F,IAAA,qBAAS,EAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACrE,MAAM,GAAG,GAAG,OAA+B,CAAC;QAC5C,MAAM,UAAU,GAAG,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAEtE,MAAM,kBAAkB,GAAG,UAAU,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAElE,MA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