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

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