@lucca-front/ng 21.1.0-rc.1 → 21.1.0-rc.2

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.
Files changed (256) hide show
  1. package/fesm2022/lucca-front-ng-api.mjs +45 -13
  2. package/fesm2022/lucca-front-ng-api.mjs.map +1 -1
  3. package/fesm2022/lucca-front-ng-app-layout.mjs +2 -2
  4. package/fesm2022/lucca-front-ng-app-layout.mjs.map +1 -1
  5. package/fesm2022/lucca-front-ng-box.mjs +1 -1
  6. package/fesm2022/lucca-front-ng-box.mjs.map +1 -1
  7. package/fesm2022/lucca-front-ng-breadcrumbs.mjs.map +1 -1
  8. package/fesm2022/lucca-front-ng-bubble-icon.mjs +1 -1
  9. package/fesm2022/lucca-front-ng-bubble-icon.mjs.map +1 -1
  10. package/fesm2022/lucca-front-ng-button.mjs +1 -119
  11. package/fesm2022/lucca-front-ng-button.mjs.map +1 -1
  12. package/fesm2022/lucca-front-ng-callout.mjs +13 -39
  13. package/fesm2022/lucca-front-ng-callout.mjs.map +1 -1
  14. package/fesm2022/lucca-front-ng-chip.mjs +3 -33
  15. package/fesm2022/lucca-front-ng-chip.mjs.map +1 -1
  16. package/fesm2022/lucca-front-ng-clear.mjs +2 -17
  17. package/fesm2022/lucca-front-ng-clear.mjs.map +1 -1
  18. package/fesm2022/lucca-front-ng-comment.mjs +18 -20
  19. package/fesm2022/lucca-front-ng-comment.mjs.map +1 -1
  20. package/fesm2022/lucca-front-ng-container.mjs +7 -5
  21. package/fesm2022/lucca-front-ng-container.mjs.map +1 -1
  22. package/fesm2022/lucca-front-ng-core-select-job-qualification.mjs +2 -0
  23. package/fesm2022/lucca-front-ng-core-select-job-qualification.mjs.map +1 -1
  24. package/fesm2022/lucca-front-ng-core-select-user.mjs +2 -2
  25. package/fesm2022/lucca-front-ng-core-select-user.mjs.map +1 -1
  26. package/fesm2022/lucca-front-ng-core-select.mjs +6 -6
  27. package/fesm2022/lucca-front-ng-core-select.mjs.map +1 -1
  28. package/fesm2022/lucca-front-ng-core.mjs +3 -75
  29. package/fesm2022/lucca-front-ng-core.mjs.map +1 -1
  30. package/fesm2022/lucca-front-ng-data-table.mjs +3 -3
  31. package/fesm2022/lucca-front-ng-data-table.mjs.map +1 -1
  32. package/fesm2022/lucca-front-ng-date.mjs +37 -5
  33. package/fesm2022/lucca-front-ng-date.mjs.map +1 -1
  34. package/fesm2022/lucca-front-ng-date2.mjs +20 -32
  35. package/fesm2022/lucca-front-ng-date2.mjs.map +1 -1
  36. package/fesm2022/lucca-front-ng-department.mjs +18 -2
  37. package/fesm2022/lucca-front-ng-department.mjs.map +1 -1
  38. package/fesm2022/lucca-front-ng-dialog.mjs +3 -3
  39. package/fesm2022/lucca-front-ng-dialog.mjs.map +1 -1
  40. package/fesm2022/lucca-front-ng-divider.mjs +1 -10
  41. package/fesm2022/lucca-front-ng-divider.mjs.map +1 -1
  42. package/fesm2022/lucca-front-ng-empty-state.mjs +1 -17
  43. package/fesm2022/lucca-front-ng-empty-state.mjs.map +1 -1
  44. package/fesm2022/lucca-front-ng-establishment.mjs +66 -2
  45. package/fesm2022/lucca-front-ng-establishment.mjs.map +1 -1
  46. package/fesm2022/lucca-front-ng-fancy-box.mjs +0 -12
  47. package/fesm2022/lucca-front-ng-fancy-box.mjs.map +1 -1
  48. package/fesm2022/lucca-front-ng-file-upload.mjs +1 -1
  49. package/fesm2022/lucca-front-ng-file-upload.mjs.map +1 -1
  50. package/fesm2022/lucca-front-ng-filter-pills.mjs +3 -3
  51. package/fesm2022/lucca-front-ng-filter-pills.mjs.map +1 -1
  52. package/fesm2022/lucca-front-ng-footer.mjs +0 -3
  53. package/fesm2022/lucca-front-ng-footer.mjs.map +1 -1
  54. package/fesm2022/lucca-front-ng-form-field.mjs +7 -76
  55. package/fesm2022/lucca-front-ng-form-field.mjs.map +1 -1
  56. package/fesm2022/lucca-front-ng-form-header.mjs +0 -3
  57. package/fesm2022/lucca-front-ng-form-header.mjs.map +1 -1
  58. package/fesm2022/lucca-front-ng-form.mjs +5 -19
  59. package/fesm2022/lucca-front-ng-form.mjs.map +1 -1
  60. package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs +8 -9
  61. package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs.map +1 -1
  62. package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs +34 -51
  63. package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs.map +1 -1
  64. package/fesm2022/lucca-front-ng-forms.mjs +40 -88
  65. package/fesm2022/lucca-front-ng-forms.mjs.map +1 -1
  66. package/fesm2022/lucca-front-ng-gauge.mjs +5 -28
  67. package/fesm2022/lucca-front-ng-gauge.mjs.map +1 -1
  68. package/fesm2022/lucca-front-ng-grid.mjs +3 -3
  69. package/fesm2022/lucca-front-ng-grid.mjs.map +1 -1
  70. package/fesm2022/lucca-front-ng-highlight-data.mjs +26 -31
  71. package/fesm2022/lucca-front-ng-highlight-data.mjs.map +1 -1
  72. package/fesm2022/lucca-front-ng-horizontal-navigation.mjs +0 -3
  73. package/fesm2022/lucca-front-ng-horizontal-navigation.mjs.map +1 -1
  74. package/fesm2022/lucca-front-ng-icon.mjs +1 -42
  75. package/fesm2022/lucca-front-ng-icon.mjs.map +1 -1
  76. package/fesm2022/lucca-front-ng-index-table.mjs +3 -3
  77. package/fesm2022/lucca-front-ng-index-table.mjs.map +1 -1
  78. package/fesm2022/lucca-front-ng-inline-message.mjs +0 -12
  79. package/fesm2022/lucca-front-ng-inline-message.mjs.map +1 -1
  80. package/fesm2022/lucca-front-ng-link.mjs +0 -15
  81. package/fesm2022/lucca-front-ng-link.mjs.map +1 -1
  82. package/fesm2022/lucca-front-ng-listbox.mjs +6 -18
  83. package/fesm2022/lucca-front-ng-listbox.mjs.map +1 -1
  84. package/fesm2022/lucca-front-ng-listing.mjs +8 -37
  85. package/fesm2022/lucca-front-ng-listing.mjs.map +1 -1
  86. package/fesm2022/lucca-front-ng-loading.mjs.map +1 -1
  87. package/fesm2022/lucca-front-ng-main-layout.mjs +2 -8
  88. package/fesm2022/lucca-front-ng-main-layout.mjs.map +1 -1
  89. package/fesm2022/lucca-front-ng-mobile-push.mjs +10 -18
  90. package/fesm2022/lucca-front-ng-mobile-push.mjs.map +1 -1
  91. package/fesm2022/lucca-front-ng-modal.mjs +1 -1
  92. package/fesm2022/lucca-front-ng-modal.mjs.map +1 -1
  93. package/fesm2022/lucca-front-ng-multi-select.mjs +9 -12
  94. package/fesm2022/lucca-front-ng-multi-select.mjs.map +1 -1
  95. package/fesm2022/lucca-front-ng-new-badge.mjs +0 -3
  96. package/fesm2022/lucca-front-ng-new-badge.mjs.map +1 -1
  97. package/fesm2022/lucca-front-ng-numeric-badge.mjs +1 -10
  98. package/fesm2022/lucca-front-ng-numeric-badge.mjs.map +1 -1
  99. package/fesm2022/lucca-front-ng-option.mjs +315 -203
  100. package/fesm2022/lucca-front-ng-option.mjs.map +1 -1
  101. package/fesm2022/lucca-front-ng-page-header.mjs +0 -9
  102. package/fesm2022/lucca-front-ng-page-header.mjs.map +1 -1
  103. package/fesm2022/lucca-front-ng-pagination.mjs +1 -25
  104. package/fesm2022/lucca-front-ng-pagination.mjs.map +1 -1
  105. package/fesm2022/lucca-front-ng-plg-push.mjs +1 -7
  106. package/fesm2022/lucca-front-ng-plg-push.mjs.map +1 -1
  107. package/fesm2022/lucca-front-ng-popover.mjs +33 -1
  108. package/fesm2022/lucca-front-ng-popover.mjs.map +1 -1
  109. package/fesm2022/lucca-front-ng-popover2.mjs +9 -19
  110. package/fesm2022/lucca-front-ng-popover2.mjs.map +1 -1
  111. package/fesm2022/lucca-front-ng-progress-bar.mjs +5 -12
  112. package/fesm2022/lucca-front-ng-progress-bar.mjs.map +1 -1
  113. package/fesm2022/lucca-front-ng-read-more.mjs +1 -16
  114. package/fesm2022/lucca-front-ng-read-more.mjs.map +1 -1
  115. package/fesm2022/lucca-front-ng-resource-card.mjs +7 -7
  116. package/fesm2022/lucca-front-ng-resource-card.mjs.map +1 -1
  117. package/fesm2022/lucca-front-ng-scroll-box.mjs +2 -5
  118. package/fesm2022/lucca-front-ng-scroll-box.mjs.map +1 -1
  119. package/fesm2022/lucca-front-ng-segmented-control-tabs.mjs +3 -9
  120. package/fesm2022/lucca-front-ng-segmented-control-tabs.mjs.map +1 -1
  121. package/fesm2022/lucca-front-ng-segmented-control.mjs +1 -16
  122. package/fesm2022/lucca-front-ng-segmented-control.mjs.map +1 -1
  123. package/fesm2022/lucca-front-ng-simple-select.mjs +6 -21
  124. package/fesm2022/lucca-front-ng-simple-select.mjs.map +1 -1
  125. package/fesm2022/lucca-front-ng-skeleton.mjs +12 -63
  126. package/fesm2022/lucca-front-ng-skeleton.mjs.map +1 -1
  127. package/fesm2022/lucca-front-ng-sortable-list.mjs +1 -25
  128. package/fesm2022/lucca-front-ng-sortable-list.mjs.map +1 -1
  129. package/fesm2022/lucca-front-ng-status-badge.mjs +0 -12
  130. package/fesm2022/lucca-front-ng-status-badge.mjs.map +1 -1
  131. package/fesm2022/lucca-front-ng-tag.mjs +1 -7
  132. package/fesm2022/lucca-front-ng-tag.mjs.map +1 -1
  133. package/fesm2022/lucca-front-ng-time.mjs +16 -55
  134. package/fesm2022/lucca-front-ng-time.mjs.map +1 -1
  135. package/fesm2022/lucca-front-ng-tooltip.mjs +22 -6
  136. package/fesm2022/lucca-front-ng-tooltip.mjs.map +1 -1
  137. package/fesm2022/lucca-front-ng-user-popover.mjs +1 -1
  138. package/fesm2022/lucca-front-ng-user-popover.mjs.map +1 -1
  139. package/fesm2022/lucca-front-ng-user.mjs +25 -9
  140. package/fesm2022/lucca-front-ng-user.mjs.map +1 -1
  141. package/fesm2022/lucca-front-ng-vertical-navigation.mjs +2 -32
  142. package/fesm2022/lucca-front-ng-vertical-navigation.mjs.map +1 -1
  143. package/package.json +5 -7
  144. package/schematics/action-icon/index.js +5 -4
  145. package/schematics/action-icon/migration.js +4 -3
  146. package/schematics/action-icon/migration.spec.js +8 -8
  147. package/schematics/alignment-utilities/index.js +4 -3
  148. package/schematics/alignment-utilities/migration.spec.js +8 -8
  149. package/schematics/cdn-urls/index.js +4 -3
  150. package/schematics/cdn-urls/migration.js +9 -7
  151. package/schematics/cdn-urls/migration.spec.js +8 -8
  152. package/schematics/class-prefix/index.js +4 -3
  153. package/schematics/class-prefix/migration.spec.js +8 -8
  154. package/schematics/collection.json +0 -10
  155. package/schematics/color-text/index.js +4 -3
  156. package/schematics/color-text/migration.spec.js +8 -8
  157. package/schematics/component-path/index.js +4 -3
  158. package/schematics/component-path/migration.spec.js +8 -8
  159. package/schematics/empty-state-title/index.js +7 -5
  160. package/schematics/empty-state-title/migration.spec.js +5 -5
  161. package/schematics/lib/schematic.utils.js +0 -5
  162. package/schematics/lu-button/index.js +4 -3
  163. package/schematics/lu-button/migration.js +11 -5
  164. package/schematics/lu-button/migration.spec.js +5 -5
  165. package/schematics/lu-icon/index.js +4 -3
  166. package/schematics/lu-icon/migration.js +14 -8
  167. package/schematics/lu-icon/migration.spec.js +5 -5
  168. package/schematics/lu-select/index.js +4 -3
  169. package/schematics/lu-select/migration.js +21 -18
  170. package/schematics/lu-select/migration.spec.js +5 -5
  171. package/schematics/lu-select/util.js +19 -17
  172. package/schematics/lu-text-input/index.js +4 -3
  173. package/schematics/lu-text-input/migration.js +28 -22
  174. package/schematics/lu-text-input/migration.spec.js +5 -5
  175. package/schematics/new-icons/index.js +6 -5
  176. package/schematics/new-icons/migration.js +16 -11
  177. package/schematics/new-icons/migration.spec.js +8 -8
  178. package/schematics/palettes/index.js +4 -3
  179. package/schematics/palettes/migration.spec.js +8 -8
  180. package/schematics/tokens-radius/index.js +4 -3
  181. package/schematics/tokens-radius/migration.spec.js +8 -8
  182. package/schematics/tokens-spacing/index.js +4 -3
  183. package/schematics/tokens-spacing/migration.spec.js +8 -8
  184. package/schematics/tokens-typo/index.js +4 -3
  185. package/schematics/tokens-typo/migration.spec.js +8 -8
  186. package/src/components/cdk/_overlay.scss +0 -5
  187. package/src/definitions/option/_option-item.scss +0 -1
  188. package/types/lucca-front-ng-api.d.ts +19 -1
  189. package/types/lucca-front-ng-breadcrumbs.d.ts +1 -1
  190. package/types/lucca-front-ng-button.d.ts +1 -61
  191. package/types/lucca-front-ng-callout.d.ts +2 -32
  192. package/types/lucca-front-ng-chip.d.ts +2 -32
  193. package/types/lucca-front-ng-clear.d.ts +5 -20
  194. package/types/lucca-front-ng-comment.d.ts +11 -19
  195. package/types/lucca-front-ng-container.d.ts +4 -4
  196. package/types/lucca-front-ng-core-select.d.ts +1 -2
  197. package/types/lucca-front-ng-core.d.ts +3 -18
  198. package/types/lucca-front-ng-date.d.ts +19 -1
  199. package/types/lucca-front-ng-date2.d.ts +1 -2
  200. package/types/lucca-front-ng-department.d.ts +10 -1
  201. package/types/lucca-front-ng-divider.d.ts +0 -10
  202. package/types/lucca-front-ng-empty-state.d.ts +0 -16
  203. package/types/lucca-front-ng-establishment.d.ts +37 -1
  204. package/types/lucca-front-ng-fancy-box.d.ts +0 -12
  205. package/types/lucca-front-ng-footer.d.ts +0 -3
  206. package/types/lucca-front-ng-form-field.d.ts +4 -34
  207. package/types/lucca-front-ng-form-header.d.ts +0 -3
  208. package/types/lucca-front-ng-form.d.ts +5 -9
  209. package/types/lucca-front-ng-forms-phone-number-input.d.ts +0 -1
  210. package/types/lucca-front-ng-forms-rich-text-input.d.ts +0 -2
  211. package/types/lucca-front-ng-forms.d.ts +4 -16
  212. package/types/lucca-front-ng-gauge.d.ts +0 -25
  213. package/types/lucca-front-ng-grid.d.ts +1 -1
  214. package/types/lucca-front-ng-highlight-data.d.ts +15 -36
  215. package/types/lucca-front-ng-horizontal-navigation.d.ts +0 -3
  216. package/types/lucca-front-ng-icon.d.ts +1 -32
  217. package/types/lucca-front-ng-inline-message.d.ts +0 -12
  218. package/types/lucca-front-ng-link.d.ts +0 -15
  219. package/types/lucca-front-ng-listbox.d.ts +4 -16
  220. package/types/lucca-front-ng-listing.d.ts +2 -33
  221. package/types/lucca-front-ng-main-layout.d.ts +0 -6
  222. package/types/lucca-front-ng-mobile-push.d.ts +0 -7
  223. package/types/lucca-front-ng-new-badge.d.ts +0 -3
  224. package/types/lucca-front-ng-numeric-badge.d.ts +0 -9
  225. package/types/lucca-front-ng-option.d.ts +141 -78
  226. package/types/lucca-front-ng-page-header.d.ts +0 -9
  227. package/types/lucca-front-ng-pagination.d.ts +0 -24
  228. package/types/lucca-front-ng-plg-push.d.ts +0 -6
  229. package/types/lucca-front-ng-popover.d.ts +20 -1
  230. package/types/lucca-front-ng-popover2.d.ts +3 -5
  231. package/types/lucca-front-ng-progress-bar.d.ts +0 -9
  232. package/types/lucca-front-ng-read-more.d.ts +1 -16
  233. package/types/lucca-front-ng-resource-card.d.ts +0 -6
  234. package/types/lucca-front-ng-scroll-box.d.ts +1 -4
  235. package/types/lucca-front-ng-segmented-control-tabs.d.ts +1 -7
  236. package/types/lucca-front-ng-segmented-control.d.ts +1 -16
  237. package/types/lucca-front-ng-skeleton.d.ts +6 -61
  238. package/types/lucca-front-ng-sortable-list.d.ts +0 -24
  239. package/types/lucca-front-ng-status-badge.d.ts +0 -12
  240. package/types/lucca-front-ng-tag.d.ts +0 -6
  241. package/types/lucca-front-ng-time.d.ts +10 -16
  242. package/types/lucca-front-ng-tooltip.d.ts +11 -2
  243. package/types/lucca-front-ng-user.d.ts +11 -2
  244. package/types/lucca-front-ng-vertical-navigation.d.ts +0 -30
  245. package/fesm2022/lucca-front-ng-text-flow.mjs +0 -20
  246. package/fesm2022/lucca-front-ng-text-flow.mjs.map +0 -1
  247. package/schematics/lib/index.js +0 -29
  248. package/schematics/lu-container/index.js +0 -23
  249. package/schematics/lu-container/migration.js +0 -116
  250. package/schematics/lu-container/migration.spec.js +0 -23
  251. package/schematics/lu-container/schema.json +0 -23
  252. package/schematics/lu-loading/index.js +0 -23
  253. package/schematics/lu-loading/migration.js +0 -136
  254. package/schematics/lu-loading/migration.spec.js +0 -23
  255. package/schematics/lu-loading/schema.json +0 -28
  256. package/types/lucca-front-ng-text-flow.d.ts +0 -8
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrateComponent = migrateComponent;
4
4
  const change_1 = require("@schematics/angular/utility/change");
5
- const lib_1 = require("../lib");
5
+ const angular_component_ast_1 = require("../lib/angular-component-ast");
6
+ const angular_template_1 = require("../lib/angular-template");
7
+ const html_ast_js_1 = require("../lib/html-ast.js");
8
+ const lf_schematic_context_1 = require("../lib/lf-schematic-context");
6
9
  function migrateComponent(sourceFile, path, tree) {
7
10
  const cssButtons = findCssButtons(sourceFile, path, tree);
8
11
  if (cssButtons.length > 0) {
@@ -63,7 +66,7 @@ function migrateComponent(sourceFile, path, tree) {
63
66
  }
64
67
  });
65
68
  // Add import if needed
66
- (0, change_1.applyToUpdateRecorder)(tsUpdate, [(0, lib_1.insertTSImportIfNeeded)(sourceFile, path, 'ButtonComponent', '@lucca-front/ng/button'), (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, 'ButtonComponent')]);
69
+ (0, change_1.applyToUpdateRecorder)(tsUpdate, [(0, angular_component_ast_1.insertTSImportIfNeeded)(sourceFile, path, 'ButtonComponent', '@lucca-front/ng/button'), (0, angular_component_ast_1.insertAngularImportIfNeeded)(sourceFile, path, 'ButtonComponent')]);
67
70
  tree.commitUpdate(tsUpdate);
68
71
  if (!isInlineTemplate) {
69
72
  tree.commitUpdate(templateUpdate);
@@ -73,11 +76,11 @@ function migrateComponent(sourceFile, path, tree) {
73
76
  }
74
77
  function findCssButtons(sourceFile, basePath, tree) {
75
78
  const buttons = [];
76
- const ngTemplates = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
79
+ const ngTemplates = (0, angular_template_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
77
80
  ngTemplates.forEach((template) => {
78
- const htmlAst = new lib_1.HtmlAst(template.content);
81
+ const htmlAst = new html_ast_js_1.HtmlAst(template.content);
79
82
  htmlAst.visitNodes((node) => {
80
- if ((0, lib_1.isInterestingNode)(node) && ["button", "a"].includes(node.name)) {
83
+ if (isInterestingNode(node) && ["button", "a"].includes(node.name)) {
81
84
  const classes = node.attributes.find(attr => attr.name === 'class')?.value || "";
82
85
  if (classes.split(" ").includes("button")) {
83
86
  const inputs = {
@@ -118,3 +121,6 @@ function getButtonType(classes) {
118
121
  }
119
122
  return '';
120
123
  }
124
+ function isInterestingNode(node) {
125
+ return node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement;
126
+ }
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path = require("path");
4
- const lib_1 = require("../lib");
4
+ const migration_test_js_1 = require("../lib/migration-test.js");
5
5
  const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
6
6
  const testsRoot = path.join(__dirname, 'tests');
7
7
  describe('luButton Migration', () => {
8
8
  it('should handle basic case files', async () => {
9
9
  // Arrange
10
- const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
11
- const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
10
+ const tree = (0, migration_test_js_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
11
+ const expectedTree = (0, migration_test_js_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
12
12
  // Act
13
13
  try {
14
- await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-button', { skipInstallation: true }, tree);
14
+ await (0, migration_test_js_1.runSchematic)('collection', collectionPath, 'lu-button', { skipInstallation: true }, tree);
15
15
  }
16
16
  catch (error) {
17
17
  // eslint-disable-next-line no-console
18
18
  console.log(error);
19
19
  }
20
20
  // Assert
21
- (0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
21
+ (0, migration_test_js_1.expectTree)(tree).toMatchTree(expectedTree);
22
22
  });
23
23
  });
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const typescript_1 = require("typescript");
4
- const lib_1 = require("../lib");
4
+ const lf_schematic_context_1 = require("../lib/lf-schematic-context");
5
+ const schematics_1 = require("../lib/schematics");
5
6
  const migration_1 = require("./migration");
6
7
  // Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
7
8
  require('@angular-devkit/schematics');
8
9
  exports.default = (options) => {
9
10
  return async (tree, context) => {
10
- await lib_1.currentSchematicContext.init(context, options);
11
+ await lf_schematic_context_1.currentSchematicContext.init(context, options);
11
12
  tree.visit((path, entry) => {
12
13
  if (path.includes('node_modules') || !entry) {
13
14
  return;
14
15
  }
15
16
  if (path.endsWith('.ts')) {
16
- (0, lib_1.migrateFile)(path, entry, tree, (content) => {
17
+ (0, schematics_1.migrateFile)(path, entry, tree, (content) => {
17
18
  const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
18
19
  return (0, migration_1.migrateComponent)(sourceFile, path, tree);
19
20
  });
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrateComponent = migrateComponent;
4
4
  const change_1 = require("@schematics/angular/utility/change");
5
- const lib_1 = require("../lib");
5
+ const angular_component_ast_1 = require("../lib/angular-component-ast");
6
+ const angular_template_1 = require("../lib/angular-template");
7
+ const html_ast_js_1 = require("../lib/html-ast.js");
8
+ const lf_schematic_context_1 = require("../lib/lf-schematic-context");
6
9
  function migrateComponent(sourceFile, path, tree) {
7
10
  const htmlIcons = findHTMLIcons(sourceFile, path, tree);
8
11
  if (htmlIcons.length > 0) {
@@ -66,7 +69,7 @@ function migrateComponent(sourceFile, path, tree) {
66
69
  }
67
70
  });
68
71
  // Add import if needed
69
- (0, change_1.applyToUpdateRecorder)(tsUpdate, [(0, lib_1.insertTSImportIfNeeded)(sourceFile, path, 'IconComponent', '@lucca-front/ng/icon'), (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, 'IconComponent')]);
72
+ (0, change_1.applyToUpdateRecorder)(tsUpdate, [(0, angular_component_ast_1.insertTSImportIfNeeded)(sourceFile, path, 'IconComponent', '@lucca-front/ng/icon'), (0, angular_component_ast_1.insertAngularImportIfNeeded)(sourceFile, path, 'IconComponent')]);
70
73
  tree.commitUpdate(tsUpdate);
71
74
  if (!isInlineTemplate) {
72
75
  tree.commitUpdate(templateUpdate);
@@ -76,11 +79,11 @@ function migrateComponent(sourceFile, path, tree) {
76
79
  }
77
80
  function findHTMLIcons(sourceFile, basePath, tree) {
78
81
  const htmlIcons = [];
79
- const ngTemplates = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
82
+ const ngTemplates = (0, angular_template_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
80
83
  ngTemplates.forEach((template) => {
81
- const htmlAst = new lib_1.HtmlAst(template.content);
84
+ const htmlAst = new html_ast_js_1.HtmlAst(template.content);
82
85
  htmlAst.visitNodes((node, parent) => {
83
- if ((0, lib_1.isInterestingNode)(node)) {
86
+ if (isInterestingNode(node)) {
84
87
  const classes = node.attributes.find(attr => attr.name === 'class')?.value;
85
88
  if (classes?.includes("lucca-icon")) {
86
89
  const iconClass = classes.split(' ').find(c => c.startsWith('icon-'));
@@ -95,12 +98,12 @@ function findHTMLIcons(sourceFile, basePath, tree) {
95
98
  filePath: template.filePath,
96
99
  componentTS: sourceFile
97
100
  };
98
- const siblings = (0, lib_1.isInterestingNode)(parent) ? parent?.children : htmlAst.nodes;
101
+ const siblings = isInterestingNode(parent) ? parent?.children : htmlAst.nodes;
99
102
  if (siblings.length > 0) {
100
103
  const possibleAltSpan = siblings.find(child => {
101
- return (0, lib_1.isInterestingNode)(child) && child !== node;
104
+ return isInterestingNode(child) && child !== node;
102
105
  });
103
- if (possibleAltSpan && (0, lib_1.isInterestingNode)(possibleAltSpan)) {
106
+ if (possibleAltSpan && isInterestingNode(possibleAltSpan)) {
104
107
  const childClasses = possibleAltSpan.attributes.find(attr => attr.name === 'class')?.value;
105
108
  // We know it's one of these types but TS doesn't find that info from the above call so here we go again
106
109
  if (childClasses === 'pr-u-mask') {
@@ -117,3 +120,6 @@ function findHTMLIcons(sourceFile, basePath, tree) {
117
120
  });
118
121
  return htmlIcons;
119
122
  }
123
+ function isInterestingNode(node) {
124
+ return node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement;
125
+ }
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path = require("path");
4
- const lib_1 = require("../lib");
4
+ const migration_test_js_1 = require("../lib/migration-test.js");
5
5
  const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
6
6
  const testsRoot = path.join(__dirname, 'tests');
7
7
  describe('lu-icon Migration', () => {
8
8
  it('should handle basic case files', async () => {
9
9
  // Arrange
10
- const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
11
- const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
10
+ const tree = (0, migration_test_js_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
11
+ const expectedTree = (0, migration_test_js_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
12
12
  // Act
13
13
  try {
14
- await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-icon', { skipInstallation: true }, tree);
14
+ await (0, migration_test_js_1.runSchematic)('collection', collectionPath, 'lu-icon', { skipInstallation: true }, tree);
15
15
  }
16
16
  catch (error) {
17
17
  // eslint-disable-next-line no-console
18
18
  console.log(error);
19
19
  }
20
20
  // Assert
21
- (0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
21
+ (0, migration_test_js_1.expectTree)(tree).toMatchTree(expectedTree);
22
22
  });
23
23
  });
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const typescript_1 = require("typescript");
4
- const lib_1 = require("../lib");
4
+ const lf_schematic_context_1 = require("../lib/lf-schematic-context");
5
+ const schematics_1 = require("../lib/schematics");
5
6
  const migration_1 = require("./migration");
6
7
  // Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
7
8
  require('@angular-devkit/schematics');
8
9
  exports.default = (options) => {
9
10
  return async (tree, context) => {
10
- await lib_1.currentSchematicContext.init(context, options);
11
+ await lf_schematic_context_1.currentSchematicContext.init(context, options);
11
12
  tree.visit((path, entry) => {
12
13
  if (path.includes('node_modules') || !entry) {
13
14
  return;
14
15
  }
15
16
  if (path.endsWith('.ts')) {
16
- (0, lib_1.migrateFile)(path, entry, tree, (content) => {
17
+ (0, schematics_1.migrateFile)(path, entry, tree, (content) => {
17
18
  const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
18
19
  return (0, migration_1.migrateComponent)(sourceFile, path, tree, options?.noComments);
19
20
  });
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrateComponent = migrateComponent;
4
- const change_1 = require("@schematics/angular/utility/change");
5
- const eol_1 = require("@schematics/angular/utility/eol");
4
+ const html_ast_js_1 = require("../lib/html-ast.js");
6
5
  const typescript_1 = require("typescript");
7
- const lib_1 = require("../lib");
8
- const select_context_1 = require("./model/select-context");
6
+ const angular_component_ast_1 = require("../lib/angular-component-ast");
7
+ const angular_template_1 = require("../lib/angular-template");
9
8
  const util_1 = require("./util");
9
+ const select_context_1 = require("./model/select-context");
10
+ const change_1 = require("@schematics/angular/utility/change");
11
+ const eol_1 = require("@schematics/angular/utility/eol");
12
+ const lf_schematic_context_1 = require("../lib/lf-schematic-context");
10
13
  const importSource = {
11
14
  LuSimpleSelectInputComponent: '@lucca-front/ng/simple-select',
12
15
  LuMultiSelectInputComponent: '@lucca-front/ng/multi-select',
@@ -52,13 +55,13 @@ function migrateComponent(sourceFile, path, tree, noComments = false) {
52
55
  // We're not checking using else here because handle** methods can also add a rejection reason
53
56
  // We want to handle both cases (before handling and after) here
54
57
  if (select.rejection) {
55
- lib_1.currentSchematicContext.logFailure(`Couldn't migrate ${select.component} in ${path}: ${util_1.RejectionReason[select.rejection.reason]}`);
58
+ lf_schematic_context_1.currentSchematicContext.logFailure(`Couldn't migrate ${select.component} in ${path}: ${util_1.RejectionReason[select.rejection.reason]}`);
56
59
  if (!noComments) {
57
60
  insertRejectionComment(templateUpdate, select);
58
61
  }
59
62
  }
60
63
  else {
61
- lib_1.currentSchematicContext.logSuccess(`Migrated ${select.component} in ${path}`);
64
+ lf_schematic_context_1.currentSchematicContext.logSuccess(`Migrated ${select.component} in ${path}`);
62
65
  }
63
66
  });
64
67
  tree.commitUpdate(tsUpdate);
@@ -96,18 +99,18 @@ function insertRejectionComment(update, select) {
96
99
  update.insertLeft(select.nodeOffset + select.node.startSourceSpan.start.offset, `<!-- [lu-select migration] REJECTED: ${detailedReason || util_1.RejectionReason[select.rejection.reason]} -->\n${indentBefore}`);
97
100
  }
98
101
  function findSelectContexts(sourceFile, basePath, tree) {
99
- const imports = (0, lib_1.extractComponentImports)(sourceFile);
102
+ const imports = (0, angular_component_ast_1.extractComponentImports)(sourceFile);
100
103
  if (possibleSelectComponents.some((c) => imports.includes(c))) {
101
104
  const selects = [];
102
- const template = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath)[0];
103
- const htmlAst = new lib_1.HtmlAst(template.content);
105
+ const template = (0, angular_template_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath)[0];
106
+ const htmlAst = new html_ast_js_1.HtmlAst(template.content);
104
107
  htmlAst.visitNodes((node) => {
105
- if (node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstElement) {
108
+ if (node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement) {
106
109
  const selectComponentClass = selectorToComponentNameRecord[node.name];
107
110
  const multipleInput = node.inputs.find((attr) => attr.name === 'multiple');
108
- const unsupportedMultiple = multipleInput?.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource && multipleInput.value.source !== 'true';
111
+ const unsupportedMultiple = multipleInput?.value instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.ASTWithSource && multipleInput.value.source !== 'true';
109
112
  const multipleAttr = node.attributes.find((attr) => attr.name === 'multiple');
110
- const multipleFromInput = multipleInput?.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource && multipleInput.value.source === 'true'
113
+ const multipleFromInput = multipleInput?.value instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.ASTWithSource && multipleInput.value.source === 'true'
111
114
  ? { start: multipleInput?.sourceSpan?.start?.offset, end: multipleInput?.sourceSpan?.end?.offset + 1 }
112
115
  : null;
113
116
  const multipleFromAttr = multipleAttr && (multipleAttr.value === 'true' || multipleAttr.value === '') ? { start: multipleAttr?.sourceSpan?.start?.offset, end: multipleAttr?.sourceSpan?.end?.offset + 1 } : null;
@@ -142,7 +145,7 @@ function updateImports(sourceFile, selects, path, tree) {
142
145
  const imports = new Set(selects.filter((s) => !s.rejection).flatMap((select) => select.requiredImports || []));
143
146
  imports.forEach((importToAdd) => {
144
147
  if (importSource[importToAdd]) {
145
- (0, change_1.applyToUpdateRecorder)(update, [(0, lib_1.insertTSImportIfNeeded)(sourceFile, path, importToAdd, importSource[importToAdd]), (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, importToAdd)]);
148
+ (0, change_1.applyToUpdateRecorder)(update, [(0, angular_component_ast_1.insertTSImportIfNeeded)(sourceFile, path, importToAdd, importSource[importToAdd]), (0, angular_component_ast_1.insertAngularImportIfNeeded)(sourceFile, path, importToAdd)]);
146
149
  }
147
150
  else {
148
151
  console.error(`Can't add import for ${importToAdd} because source is unknown`);
@@ -152,11 +155,11 @@ function updateImports(sourceFile, selects, path, tree) {
152
155
  const componentsCleanupUpdate = tree.beginUpdate(path);
153
156
  // Cleanup unused select component imports
154
157
  const updatedSourceFile = (0, typescript_1.createSourceFile)(path, tree.readText(path), typescript_1.ScriptTarget.ESNext);
155
- const templatesAfterUpdate = (0, lib_1.extractNgTemplatesIncludingHtml)(updatedSourceFile, tree, path);
158
+ const templatesAfterUpdate = (0, angular_template_1.extractNgTemplatesIncludingHtml)(updatedSourceFile, tree, path);
156
159
  templatesAfterUpdate.forEach((template) => {
157
160
  Object.entries(select_context_1.selectorToComponentName).forEach(([selector, className]) => {
158
161
  if (!template.content.includes(selector)) {
159
- (0, change_1.applyToUpdateRecorder)(componentsCleanupUpdate, [(0, lib_1.removeTSImport)(updatedSourceFile, path, className), (0, lib_1.removeAngularImport)(updatedSourceFile, path, className)]);
162
+ (0, change_1.applyToUpdateRecorder)(componentsCleanupUpdate, [(0, angular_component_ast_1.removeTSImport)(updatedSourceFile, path, className), (0, angular_component_ast_1.removeAngularImport)(updatedSourceFile, path, className)]);
160
163
  }
161
164
  });
162
165
  });
@@ -175,7 +178,7 @@ function updateImports(sourceFile, selects, path, tree) {
175
178
  function handleLuSelectInputComponent(select, update) {
176
179
  const dataSource = (0, util_1.getDataSource)(select);
177
180
  let hasClearer = false;
178
- new lib_1.HtmlAstVisitor(select.node).visitElements(/lu-input-clearer/, (node) => {
181
+ new html_ast_js_1.HtmlAstVisitor(select.node).visitElements(/lu-input-clearer/, (node) => {
179
182
  // Doing the check just in case
180
183
  if (node.name === 'lu-input-clearer') {
181
184
  hasClearer = true;
@@ -272,14 +275,14 @@ function handleApiSelectInputComponent(select, update) {
272
275
  }
273
276
  });
274
277
  select.node.inputs.forEach((input) => {
275
- if (input.name === 'api' && input.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
278
+ if (input.name === 'api' && input.value instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.ASTWithSource) {
276
279
  apiEndpoint = input.value?.source || '';
277
280
  oldApiInput = {
278
281
  pos: input.sourceSpan.start.offset,
279
282
  length: input.sourceSpan.end.offset - input.sourceSpan.start.offset
280
283
  };
281
284
  }
282
- if (input.name === 'standard' && input.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
285
+ if (input.name === 'standard' && input.value instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.ASTWithSource) {
283
286
  apiStandard = (input.value?.source || 'v3');
284
287
  oldApiStandard = {
285
288
  pos: input.sourceSpan.start.offset,
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path = require("path");
4
- const lib_1 = require("../lib");
4
+ const migration_test_js_1 = require("../lib/migration-test.js");
5
5
  const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
6
6
  const testsRoot = path.join(__dirname, 'tests');
7
7
  describe('lu-select Migration', () => {
8
8
  it('should handle basic case files', async () => {
9
9
  // Arrange
10
- const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
11
- const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
10
+ const tree = (0, migration_test_js_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
11
+ const expectedTree = (0, migration_test_js_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
12
12
  // Act
13
13
  try {
14
- await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-select', { skipInstallation: true }, tree);
14
+ await (0, migration_test_js_1.runSchematic)('collection', collectionPath, 'lu-select', { skipInstallation: true }, tree);
15
15
  }
16
16
  catch (error) {
17
17
  // eslint-disable-next-line no-console
18
18
  console.log(error);
19
19
  }
20
20
  // Assert
21
- (0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
21
+ (0, migration_test_js_1.expectTree)(tree).toMatchTree(expectedTree);
22
22
  });
23
23
  });
@@ -5,7 +5,9 @@ exports.isRejection = isRejection;
5
5
  exports.getCommonMigrationRejectionReason = getCommonMigrationRejectionReason;
6
6
  exports.getDataSource = getDataSource;
7
7
  exports.getDisplayer = getDisplayer;
8
- const lib_1 = require("../lib");
8
+ const html_ast_1 = require("../lib/html-ast");
9
+ const angular_component_ast_1 = require("../lib/angular-component-ast");
10
+ const lf_schematic_context_1 = require("../lib/lf-schematic-context");
9
11
  var RejectionReason;
10
12
  (function (RejectionReason) {
11
13
  RejectionReason[RejectionReason["UNSUPPORTED_ATTRIBUTE"] = 0] = "UNSUPPORTED_ATTRIBUTE";
@@ -26,7 +28,7 @@ function isRejection(value) {
26
28
  return value?.reason !== undefined && RejectionReason[value.reason] != undefined;
27
29
  }
28
30
  function getCommonMigrationRejectionReason(node, sourceFile) {
29
- if (node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstElement) {
31
+ if (node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement) {
30
32
  const unsupportedAttr = node.attributes.find((attr) => !allowedAttributes.some((rxp) => rxp.test(attr.name)));
31
33
  if (unsupportedAttr) {
32
34
  return {
@@ -41,7 +43,7 @@ function getCommonMigrationRejectionReason(node, sourceFile) {
41
43
  details: unsupportedInput.name
42
44
  };
43
45
  }
44
- const providers = (0, lib_1.extractProviders)(sourceFile);
46
+ const providers = (0, angular_component_ast_1.extractProviders)(sourceFile);
45
47
  if (providers.length > 0) {
46
48
  switch (node.name) {
47
49
  case 'lu-establishment-select':
@@ -97,7 +99,7 @@ function getDataSource(select) {
97
99
  let result = {
98
100
  reason: RejectionReason.NO_DATA_SOURCE
99
101
  };
100
- const htmlAstVisitor = new lib_1.HtmlAstVisitor(select.node);
102
+ const htmlAstVisitor = new html_ast_1.HtmlAstVisitor(select.node);
101
103
  let rejected = false;
102
104
  // First of all, check that there's no lu-option-select-all, because this is a rejection reason
103
105
  htmlAstVisitor.visitElements(/(lu-option-select-all)|(lu-tree-.*)/, (node) => {
@@ -119,7 +121,7 @@ function getDataSource(select) {
119
121
  }
120
122
  htmlAstVisitor.visitElements(/lu-option-picker(-advanced)?/, (node) => {
121
123
  // If picker doesn't have option as direct child, reject, we can't migrate this kind of custom stuff
122
- const luOption = node.children.find((c) => c instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstTemplate && c.tagName === 'lu-option');
124
+ const luOption = node.children.find((c) => c instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstTemplate && c.tagName === 'lu-option');
123
125
  if (luOption === undefined) {
124
126
  result = {
125
127
  reason: RejectionReason.CUSTOM_PICKER_CONTENT
@@ -127,20 +129,20 @@ function getDataSource(select) {
127
129
  }
128
130
  else {
129
131
  // TODO Handle advanced option picker
130
- if (luOption instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstTemplate && node.name === 'lu-option-picker') {
132
+ if (luOption instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstTemplate && node.name === 'lu-option-picker') {
131
133
  let valueName = '';
132
134
  let ngForOfName = '';
133
135
  let ngForImplicitVarName = '';
134
136
  // If that's a simple option picker, lu-option should have dataSource in its ngFor
135
137
  luOption.templateAttrs.forEach((attr) => {
136
- if (attr.name === 'ngForOf' && attr.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
138
+ if (attr.name === 'ngForOf' && attr.value instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.ASTWithSource) {
137
139
  ngForOfName = attr.value.source || '';
138
140
  ngForImplicitVarName = luOption.variables.find((v) => v.value === '$implicit')?.name || '';
139
141
  }
140
142
  });
141
143
  // Grab assigned value to make sure it's a supported one
142
144
  luOption.inputs.forEach((attr) => {
143
- if (attr.name === 'value' && attr.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
145
+ if (attr.name === 'value' && attr.value instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.ASTWithSource) {
144
146
  valueName = attr.value.source || '';
145
147
  }
146
148
  });
@@ -155,10 +157,10 @@ function getDataSource(select) {
155
157
  // We have found value and it matches, now let's check how it's rendered
156
158
  // Idk why but AST has two levels for a single node in this case
157
159
  const contentHost = luOption.children[0];
158
- if (contentHost instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstElement) {
159
- const templateNodes = contentHost.children.filter(c => c instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstBoundText);
160
+ if (contentHost instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement) {
161
+ const templateNodes = contentHost.children.filter(c => c instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstBoundText);
160
162
  const firstValue = templateNodes[0];
161
- if (firstValue instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstBoundText && firstValue.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
163
+ if (firstValue instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstBoundText && firstValue.value instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.ASTWithSource) {
162
164
  const firstTemplateSource = firstValue.value.source?.trim();
163
165
  // First of all, check if it's a basic ?.name approach, in which case we can remove it
164
166
  if ((templateNodes.length === 1 && firstTemplateSource === `{{ ${valueName} }}`) ||
@@ -188,7 +190,7 @@ function getDataSource(select) {
188
190
  }
189
191
  }
190
192
  const comparerAST = node.inputs.find(attr => attr.name === 'option-comparer')?.value;
191
- if (comparerAST instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource && comparerAST?.source && !isRejection(result)) {
193
+ if (comparerAST instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.ASTWithSource && comparerAST?.source && !isRejection(result)) {
192
194
  result.comparer = comparerAST?.source;
193
195
  }
194
196
  }
@@ -197,23 +199,23 @@ function getDataSource(select) {
197
199
  return result;
198
200
  }
199
201
  function getDisplayer(select) {
200
- const displayerHostNode = select.node.children.find((node) => node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstTemplate && node.templateAttrs.some((attr) => attr.name === 'luDisplayer'));
202
+ const displayerHostNode = select.node.children.find((node) => node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstTemplate && node.templateAttrs.some((attr) => attr.name === 'luDisplayer'));
201
203
  if (!displayerHostNode) {
202
204
  return {
203
205
  canBeRemoved: true
204
206
  };
205
207
  }
206
- if (displayerHostNode instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstTemplate) {
208
+ if (displayerHostNode instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstTemplate) {
207
209
  const displayerVarName = displayerHostNode.variables.find((v) => v.value === '$implicit')?.name;
208
210
  const templateNodes = [];
209
- new lib_1.HtmlAstVisitor(displayerHostNode.children).visitNodes((c) => {
210
- if (c instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstBoundText) {
211
+ new html_ast_1.HtmlAstVisitor(displayerHostNode.children).visitNodes((c) => {
212
+ if (c instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstBoundText) {
211
213
  templateNodes.push(c);
212
214
  }
213
215
  });
214
216
  if (templateNodes?.length > 0) {
215
217
  const firstValue = templateNodes[0];
216
- if (firstValue instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstBoundText && firstValue.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
218
+ if (firstValue instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstBoundText && firstValue.value instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.ASTWithSource) {
217
219
  const firstTemplateSource = firstValue.value.source?.trim();
218
220
  if ((templateNodes.length === 1 && firstTemplateSource === `{{ ${displayerVarName} }}`) ||
219
221
  firstTemplateSource === `{{ ${displayerVarName}?.name }}` ||
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const typescript_1 = require("typescript");
4
- const lib_1 = require("../lib");
4
+ const lf_schematic_context_1 = require("../lib/lf-schematic-context");
5
+ const schematics_1 = require("../lib/schematics");
5
6
  const migration_1 = require("./migration");
6
7
  // Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
7
8
  require('@angular-devkit/schematics');
8
9
  exports.default = (options) => {
9
10
  return async (tree, context) => {
10
- await lib_1.currentSchematicContext.init(context, options);
11
+ await lf_schematic_context_1.currentSchematicContext.init(context, options);
11
12
  tree.visit((path, entry) => {
12
13
  if (path.includes('node_modules') || !entry) {
13
14
  return;
14
15
  }
15
16
  if (path.endsWith('.ts')) {
16
- (0, lib_1.migrateFile)(path, entry, tree, (content) => {
17
+ (0, schematics_1.migrateFile)(path, entry, tree, (content) => {
17
18
  const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
18
19
  return (0, migration_1.migrateComponent)(sourceFile, path, tree);
19
20
  });
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrateComponent = migrateComponent;
4
+ const angular_template_1 = require("../lib/angular-template");
5
+ const html_ast_js_1 = require("../lib/html-ast.js");
6
+ const lf_schematic_context_1 = require("../lib/lf-schematic-context");
7
+ const angular_component_ast_1 = require("../lib/angular-component-ast");
4
8
  const change_1 = require("@schematics/angular/utility/change");
5
- const lib_1 = require("../lib");
6
9
  function migrateComponent(sourceFile, path, tree) {
7
10
  const textfields = findTextfields(sourceFile, path, tree);
8
11
  if (textfields.length > 0) {
@@ -21,7 +24,7 @@ function migrateComponent(sourceFile, path, tree) {
21
24
  // Let's remove everything first
22
25
  templateUpdate.remove(field.nodeOffset + field.node.startSourceSpan.start.offset, field.node.sourceSpan.toString().length);
23
26
  // Then forge the new input
24
- const textInput = `<lu-text-input ${(0, lib_1.inputValueToHTML)('placeholder', field.inputs.placeholder)} ${(0, lib_1.inputValueToHTML)('formControlName', field.inputs.formControlName)} ${(0, lib_1.inputValueToHTML)('ngModel', field.inputs.ngModel)} />`.replace(/\s{2,}/, " ");
27
+ const textInput = `<lu-text-input ${(0, angular_component_ast_1.inputValueToHTML)('placeholder', field.inputs.placeholder)} ${(0, angular_component_ast_1.inputValueToHTML)('formControlName', field.inputs.formControlName)} ${(0, angular_component_ast_1.inputValueToHTML)('ngModel', field.inputs.ngModel)} />`.replace(/\s{2,}/, " ");
25
28
  const fieldOpeningTag = `lu-form-field [label]="labelTpl"`.replace(/\s{2,}/, " ").trim();
26
29
  // TODO handle required migration from template-driven to form-driven???
27
30
  const newInput = `<${fieldOpeningTag}>
@@ -35,10 +38,10 @@ function migrateComponent(sourceFile, path, tree) {
35
38
  if (updatedStuff) {
36
39
  // Add import if needed
37
40
  (0, change_1.applyToUpdateRecorder)(tsUpdate, [
38
- (0, lib_1.insertTSImportIfNeeded)(sourceFile, path, 'FormFieldComponent', '@lucca-front/ng/form-field'),
39
- (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, 'FormFieldComponent'),
40
- (0, lib_1.insertTSImportIfNeeded)(sourceFile, path, 'TextInputComponent', '@lucca-front/ng/forms'),
41
- (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, 'TextInputComponent')
41
+ (0, angular_component_ast_1.insertTSImportIfNeeded)(sourceFile, path, 'FormFieldComponent', '@lucca-front/ng/form-field'),
42
+ (0, angular_component_ast_1.insertAngularImportIfNeeded)(sourceFile, path, 'FormFieldComponent'),
43
+ (0, angular_component_ast_1.insertTSImportIfNeeded)(sourceFile, path, 'TextInputComponent', '@lucca-front/ng/forms'),
44
+ (0, angular_component_ast_1.insertAngularImportIfNeeded)(sourceFile, path, 'TextInputComponent')
42
45
  ]);
43
46
  tree.commitUpdate(tsUpdate);
44
47
  if (!isInlineTemplate) {
@@ -50,11 +53,11 @@ function migrateComponent(sourceFile, path, tree) {
50
53
  }
51
54
  function findTextfields(sourceFile, basePath, tree) {
52
55
  const fields = [];
53
- const ngTemplates = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
56
+ const ngTemplates = (0, angular_template_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
54
57
  ngTemplates.forEach((template) => {
55
- const htmlAst = new lib_1.HtmlAst(template.content);
58
+ const htmlAst = new html_ast_js_1.HtmlAst(template.content);
56
59
  htmlAst.visitNodes((node) => {
57
- if ((0, lib_1.isInterestingNode)(node) && node.name === "label") {
60
+ if (isInterestingNode(node) && node.name === "label") {
58
61
  const classes = getNodeClasses(node);
59
62
  const inputs = {
60
63
  size: classes.find(c => /mod-(XS|S|M|L|XL|XXL)/.test(c))?.replace('mod-', '')
@@ -68,24 +71,24 @@ function findTextfields(sourceFile, basePath, tree) {
68
71
  classes: classes
69
72
  };
70
73
  if (classes.includes("textfield")) {
71
- if (node.children.filter(el => (0, lib_1.isInterestingNode)(el) || isControlFlowNode(el)).length > 2) {
74
+ if (node.children.filter(el => isInterestingNode(el) || isControlFlowNode(el)).length > 2) {
72
75
  field.rejection = "Field contains more than an input + label";
73
76
  }
74
77
  // Find native input and grab params from it
75
- const nativeInput = node.children.find(el => (0, lib_1.isInterestingNode)(el) && el.name === "input");
78
+ const nativeInput = node.children.find(el => isInterestingNode(el) && el.name === "input");
76
79
  if (!nativeInput) {
77
80
  field.rejection = "Field doesn't contain a native input[type=text]";
78
81
  }
79
- else if ((0, lib_1.isInterestingNode)(nativeInput)) {
80
- inputs.placeholder = (0, lib_1.getInputValue)(nativeInput, "placeholder");
81
- inputs.formControlName = (0, lib_1.getInputValue)(nativeInput, "formControlName");
82
- inputs.ngModel = (0, lib_1.getInputValue)(nativeInput, "ngModel");
83
- inputs.forceRequired = (0, lib_1.getInputValue)(nativeInput, "aria-required");
82
+ else if (isInterestingNode(nativeInput)) {
83
+ inputs.placeholder = (0, angular_component_ast_1.getInputValue)(nativeInput, "placeholder");
84
+ inputs.formControlName = (0, angular_component_ast_1.getInputValue)(nativeInput, "formControlName");
85
+ inputs.ngModel = (0, angular_component_ast_1.getInputValue)(nativeInput, "ngModel");
86
+ inputs.forceRequired = (0, angular_component_ast_1.getInputValue)(nativeInput, "aria-required");
84
87
  }
85
88
  // This is a textfield, now let's find if it has everything required for migration
86
- const visitor = new lib_1.HtmlAstVisitor(node);
89
+ const visitor = new html_ast_js_1.HtmlAstVisitor(node);
87
90
  visitor.visitElements(/span/, (el) => {
88
- if ((0, lib_1.isInterestingNode)(el) && getNodeClasses(el).includes("textfield-label")) {
91
+ if (isInterestingNode(el) && getNodeClasses(el).includes("textfield-label")) {
89
92
  field.label = template.content.slice(el.startSourceSpan.end.offset, el.endSourceSpan?.start?.offset);
90
93
  }
91
94
  });
@@ -102,9 +105,12 @@ function findTextfields(sourceFile, basePath, tree) {
102
105
  function getNodeClasses(node) {
103
106
  return (node.attributes.find(attr => attr.name === 'class')?.value || "").split(" ");
104
107
  }
108
+ function isInterestingNode(node) {
109
+ return node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement;
110
+ }
105
111
  function isControlFlowNode(node) {
106
- return node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstIfBlock ||
107
- node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstForLoopBlock ||
108
- node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstSwitchBlock ||
109
- node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstDeferredBlock;
112
+ return node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstIfBlock ||
113
+ node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstForLoopBlock ||
114
+ node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstSwitchBlock ||
115
+ node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstDeferredBlock;
110
116
  }