@magic-xpa/cli 4.1100.0-dev4110.99 → 4.1101.0-dev4111.271

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 (305) hide show
  1. package/README.md +28 -28
  2. package/index.d.ts +1 -1
  3. package/index.js +4 -4
  4. package/index.js.map +1 -1
  5. package/index.ts +1 -1
  6. package/package.json +2 -2
  7. package/src/collection.json +75 -75
  8. package/src/public_api.d.ts +3 -3
  9. package/src/public_api.js +6 -6
  10. package/src/public_api.js.map +1 -1
  11. package/src/public_api.ts +5 -5
  12. package/src/schematics/magic-utils/Util.d.ts +6 -6
  13. package/src/schematics/magic-utils/Util.js +26 -26
  14. package/src/schematics/magic-utils/Util.js.map +1 -1
  15. package/src/schematics/magic-utils/config.d.ts +12 -12
  16. package/src/schematics/magic-utils/config.js +56 -56
  17. package/src/schematics/magic-utils/config.js.map +1 -1
  18. package/src/schematics/magic-utils/config.ts +68 -68
  19. package/src/schematics/magic-utils/env.d.ts +23 -23
  20. package/src/schematics/magic-utils/env.js +39 -39
  21. package/src/schematics/magic-utils/env.js.map +1 -1
  22. package/src/schematics/magic-utils/env.ts +50 -50
  23. package/src/schematics/magic-utils/manifest.d.ts +11 -11
  24. package/src/schematics/magic-utils/manifest.js +40 -40
  25. package/src/schematics/magic-utils/manifest.js.map +1 -1
  26. package/src/schematics/magic-utils/manifest.ts +46 -46
  27. package/src/schematics/magic-utils/metadata.class.d.ts +51 -51
  28. package/src/schematics/magic-utils/metadata.class.js +124 -124
  29. package/src/schematics/magic-utils/metadata.class.js.map +1 -1
  30. package/src/schematics/magic-utils/metadata.class.ts +159 -159
  31. package/src/schematics/magic-utils/process-json.d.ts +2 -2
  32. package/src/schematics/magic-utils/process-json.js +157 -158
  33. package/src/schematics/magic-utils/process-json.js.map +1 -1
  34. package/src/schematics/magic-utils/rules/build-control.rule.d.ts +5 -5
  35. package/src/schematics/magic-utils/rules/build-control.rule.js +73 -74
  36. package/src/schematics/magic-utils/rules/build-control.rule.js.map +1 -1
  37. package/src/schematics/magic-utils/rules/build-view.rule.d.ts +3 -3
  38. package/src/schematics/magic-utils/rules/build-view.rule.js +82 -83
  39. package/src/schematics/magic-utils/rules/build-view.rule.js.map +1 -1
  40. package/src/schematics/magic-utils/rules/component-list.rule.d.ts +3 -3
  41. package/src/schematics/magic-utils/rules/component-list.rule.js +316 -317
  42. package/src/schematics/magic-utils/rules/component-list.rule.js.map +1 -1
  43. package/src/schematics/magic-utils/rules/generate.rule.d.ts +5 -5
  44. package/src/schematics/magic-utils/rules/generate.rule.js +53 -54
  45. package/src/schematics/magic-utils/rules/generate.rule.js.map +1 -1
  46. package/src/schematics/magic-utils/rules/generate.rule.ts +61 -61
  47. package/src/schematics/magic-utils/rules/init-add-modules.rule.d.ts +12 -12
  48. package/src/schematics/magic-utils/rules/init-add-modules.rule.js +295 -296
  49. package/src/schematics/magic-utils/rules/init-add-modules.rule.js.map +1 -1
  50. package/src/schematics/magic-utils/rules/init-add-modules.rule.ts +360 -360
  51. package/src/schematics/magic-utils/rules/init-gen-components.rule.d.ts +4 -4
  52. package/src/schematics/magic-utils/rules/init-gen-components.rule.js +65 -66
  53. package/src/schematics/magic-utils/rules/init-gen-components.rule.js.map +1 -1
  54. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.d.ts +3 -3
  55. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js +17 -18
  56. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js.map +1 -1
  57. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.ts +19 -19
  58. package/src/schematics/magic-utils/rules/load-views-gen.rule.d.ts +3 -3
  59. package/src/schematics/magic-utils/rules/load-views-gen.rule.js +28 -29
  60. package/src/schematics/magic-utils/rules/load-views-gen.rule.js.map +1 -1
  61. package/src/schematics/magic-utils/rules/magic-option.scheme.d.ts +22 -22
  62. package/src/schematics/magic-utils/rules/magic-option.scheme.js +2 -2
  63. package/src/schematics/magic-utils/rules/magic-option.scheme.js.map +1 -1
  64. package/src/schematics/magic-utils/rules/magic-option.scheme.ts +24 -24
  65. package/src/schematics/magic-utils/utils.d.ts +12 -12
  66. package/src/schematics/magic-utils/utils.js +116 -117
  67. package/src/schematics/magic-utils/utils.js.map +1 -1
  68. package/src/schematics/magic-utils/utils.ts +134 -134
  69. package/src/schematics/mg-Install-prerequisites/index.d.ts +3 -3
  70. package/src/schematics/mg-Install-prerequisites/index.js +24 -25
  71. package/src/schematics/mg-Install-prerequisites/index.js.map +1 -1
  72. package/src/schematics/mg-Install-prerequisites/index.ts +30 -30
  73. package/src/schematics/mg-Install-prerequisites/schema.json +14 -14
  74. package/src/schematics/mg-add/files/src/app/app.component.html +17 -17
  75. package/src/schematics/mg-add/files/src/app/app.routes.ts +14 -14
  76. package/src/schematics/mg-add/files/src/app/magic/component-list.g.ts +9 -9
  77. package/src/schematics/mg-add/files/src/app/magic/lazy-loader.service.ts +2 -1
  78. package/src/schematics/mg-add/files/src/app/magic/magic.gen.lib.module.ts +19 -19
  79. package/src/schematics/mg-add/files/src/magic-styles.css +131 -131
  80. package/src/schematics/mg-add/index.d.ts +3 -3
  81. package/src/schematics/mg-add/index.js +150 -151
  82. package/src/schematics/mg-add/index.js.map +1 -1
  83. package/src/schematics/mg-add/schema.json +29 -29
  84. package/src/schematics/mg-add/utils/add-declaration-to-root-module.d.ts +2 -2
  85. package/src/schematics/mg-add/utils/add-declaration-to-root-module.js +10 -11
  86. package/src/schematics/mg-add/utils/add-declaration-to-root-module.js.map +1 -1
  87. package/src/schematics/mg-add/utils/add-declaration-to-root-module.ts +12 -12
  88. package/src/schematics/mg-add/webModule/app.routes.ts +14 -14
  89. package/src/schematics/mg-add-tasks/index.d.ts +3 -3
  90. package/src/schematics/mg-add-tasks/index.js +29 -30
  91. package/src/schematics/mg-add-tasks/index.js.map +1 -1
  92. package/src/schematics/mg-add-tasks/index.ts +53 -53
  93. package/src/schematics/mg-add-tasks/schema.json +41 -41
  94. package/src/schematics/mg-delete-files/index.d.ts +3 -3
  95. package/src/schematics/mg-delete-files/index.js +12 -13
  96. package/src/schematics/mg-delete-files/index.js.map +1 -1
  97. package/src/schematics/mg-delete-files/index.ts +12 -12
  98. package/src/schematics/mg-delete-files/schema.json +14 -14
  99. package/src/schematics/mg-gen-module/index.d.ts +3 -3
  100. package/src/schematics/mg-gen-module/index.js +14 -15
  101. package/src/schematics/mg-gen-module/index.js.map +1 -1
  102. package/src/schematics/mg-gen-module/index.ts +14 -14
  103. package/src/schematics/mg-gen-module/schema.json +24 -24
  104. package/src/schematics/mg-generate/index.d.ts +3 -3
  105. package/src/schematics/mg-generate/index.js +12 -13
  106. package/src/schematics/mg-generate/index.js.map +1 -1
  107. package/src/schematics/mg-generate/index.ts +12 -12
  108. package/src/schematics/mg-generate/schema.json +34 -34
  109. package/src/schematics/mg-generate-component/index.d.ts +3 -3
  110. package/src/schematics/mg-generate-component/index.js +34 -35
  111. package/src/schematics/mg-generate-component/index.js.map +1 -1
  112. package/src/schematics/mg-install/index.d.ts +3 -3
  113. package/src/schematics/mg-install/index.js +29 -30
  114. package/src/schematics/mg-install/index.js.map +1 -1
  115. package/src/schematics/mg-install/index.ts +37 -37
  116. package/src/schematics/mg-install/schema.json +24 -24
  117. package/src/schematics/mg-routes/index.d.ts +6 -6
  118. package/src/schematics/mg-routes/index.js +62 -63
  119. package/src/schematics/mg-routes/index.js.map +1 -1
  120. package/src/schematics/mg-routes/schema.json +14 -14
  121. package/src/schematics/mg-single-control/index.d.ts +3 -3
  122. package/src/schematics/mg-single-control/index.js +28 -29
  123. package/src/schematics/mg-single-control/index.js.map +1 -1
  124. package/src/schematics/mg-single-control/schema.json +24 -24
  125. package/src/schematics/utils/ast.d.ts +21 -21
  126. package/src/schematics/utils/ast.js +90 -91
  127. package/src/schematics/utils/ast.js.map +1 -1
  128. package/src/schematics/utils/ast.ts +103 -103
  129. package/src/schematics/utils/devkit-utils/README.md +1 -1
  130. package/src/schematics/utils/devkit-utils/ast-utils.d.ts +87 -87
  131. package/src/schematics/utils/devkit-utils/ast-utils.js +489 -490
  132. package/src/schematics/utils/devkit-utils/ast-utils.js.map +1 -1
  133. package/src/schematics/utils/devkit-utils/ast-utils.ts +570 -570
  134. package/src/schematics/utils/devkit-utils/ast-utils_old.d.ts +68 -68
  135. package/src/schematics/utils/devkit-utils/ast-utils_old.js +419 -420
  136. package/src/schematics/utils/devkit-utils/ast-utils_old.js.map +1 -1
  137. package/src/schematics/utils/devkit-utils/ast-utils_old.ts +478 -478
  138. package/src/schematics/utils/devkit-utils/change.d.ts +66 -66
  139. package/src/schematics/utils/devkit-utils/change.js +94 -94
  140. package/src/schematics/utils/devkit-utils/change.js.map +1 -1
  141. package/src/schematics/utils/devkit-utils/change.ts +127 -127
  142. package/src/schematics/utils/devkit-utils/component.d.ts +2 -2
  143. package/src/schematics/utils/devkit-utils/component.js +96 -97
  144. package/src/schematics/utils/devkit-utils/component.js.map +1 -1
  145. package/src/schematics/utils/devkit-utils/component.ts +136 -136
  146. package/src/schematics/utils/devkit-utils/config.d.ts +78 -78
  147. package/src/schematics/utils/devkit-utils/config.js +52 -52
  148. package/src/schematics/utils/devkit-utils/config.js.map +1 -1
  149. package/src/schematics/utils/devkit-utils/config.ts +120 -120
  150. package/src/schematics/utils/devkit-utils/find-module.d.ts +28 -28
  151. package/src/schematics/utils/devkit-utils/find-module.js +92 -93
  152. package/src/schematics/utils/devkit-utils/find-module.js.map +1 -1
  153. package/src/schematics/utils/devkit-utils/find-module.ts +108 -108
  154. package/src/schematics/utils/devkit-utils/ng-ast-utils.d.ts +5 -5
  155. package/src/schematics/utils/devkit-utils/ng-ast-utils.js +73 -74
  156. package/src/schematics/utils/devkit-utils/ng-ast-utils.js.map +1 -1
  157. package/src/schematics/utils/devkit-utils/ng-ast-utils.ts +84 -84
  158. package/src/schematics/utils/devkit-utils/parse-name.d.ts +13 -13
  159. package/src/schematics/utils/devkit-utils/parse-name.js +19 -20
  160. package/src/schematics/utils/devkit-utils/parse-name.js.map +1 -1
  161. package/src/schematics/utils/devkit-utils/parse-name.ts +24 -24
  162. package/src/schematics/utils/devkit-utils/route-utils.d.ts +20 -20
  163. package/src/schematics/utils/devkit-utils/route-utils.js +133 -134
  164. package/src/schematics/utils/devkit-utils/route-utils.js.map +1 -1
  165. package/src/schematics/utils/devkit-utils/route-utils.ts +180 -180
  166. package/src/schematics/utils/devkit-utils/validation.d.ts +1 -1
  167. package/src/schematics/utils/devkit-utils/validation.js +18 -19
  168. package/src/schematics/utils/devkit-utils/validation.js.map +1 -1
  169. package/src/schematics/utils/devkit-utils/validation.ts +16 -16
  170. package/src/schematics/utils/html.d.ts +18 -18
  171. package/src/schematics/utils/html.js +59 -60
  172. package/src/schematics/utils/html.js.map +1 -1
  173. package/src/schematics/utils/html.ts +63 -63
  174. package/src/schematics/utils/lib-versions.d.ts +3 -3
  175. package/src/schematics/utils/lib-versions.js +6 -6
  176. package/src/schematics/utils/lib-versions.js.map +1 -1
  177. package/src/schematics/utils/lib-versions.ts +3 -3
  178. package/src/schematics/utils/package.d.ts +5 -5
  179. package/src/schematics/utils/package.js +20 -21
  180. package/src/schematics/utils/package.js.map +1 -1
  181. package/src/schematics/utils/package.ts +22 -22
  182. package/src/schematics/utils/testing.d.ts +5 -5
  183. package/src/schematics/utils/testing.js +26 -27
  184. package/src/schematics/utils/testing.js.map +1 -1
  185. package/src/schematics/utils/testing.ts +25 -25
  186. package/src/types/enums/Enums.d.ts +1646 -1646
  187. package/src/types/enums/Enums.js +1862 -1862
  188. package/src/types/enums/Enums.js.map +1 -1
  189. package/src/types/enums/Enums.ts +2063 -2063
  190. package/src/types/enums/generated-file-types.enum.d.ts +6 -6
  191. package/src/types/enums/generated-file-types.enum.js +10 -10
  192. package/src/types/enums/generated-file-types.enum.js.map +1 -1
  193. package/src/types/enums/generated-file-types.enum.ts +6 -6
  194. package/src/types/enums/horizontal-alignments.enum.d.ts +5 -5
  195. package/src/types/enums/horizontal-alignments.enum.js +9 -9
  196. package/src/types/enums/horizontal-alignments.enum.js.map +1 -1
  197. package/src/types/enums/horizontal-alignments.enum.ts +6 -6
  198. package/src/types/enums/themes.enum.d.ts +6 -6
  199. package/src/types/enums/themes.enum.js +10 -10
  200. package/src/types/enums/themes.enum.js.map +1 -1
  201. package/src/types/enums/themes.enum.ts +6 -6
  202. package/src/types/index.d.ts +7 -7
  203. package/src/types/index.js +10 -10
  204. package/src/types/index.js.map +1 -1
  205. package/src/types/index.ts +8 -8
  206. package/src/types/interfaces/app.d.ts +53 -53
  207. package/src/types/interfaces/app.js +9 -9
  208. package/src/types/interfaces/app.js.map +1 -1
  209. package/src/types/interfaces/app.ts +89 -89
  210. package/src/types/interfaces/control.d.ts +82 -82
  211. package/src/types/interfaces/control.js +2 -2
  212. package/src/types/interfaces/control.js.map +1 -1
  213. package/src/types/interfaces/control.ts +106 -106
  214. package/src/types/interfaces/env.interface.d.ts +19 -19
  215. package/src/types/interfaces/env.interface.js +10 -10
  216. package/src/types/interfaces/template.config.d.ts +8 -8
  217. package/src/types/interfaces/template.config.js +2 -2
  218. package/src/types/interfaces/template.config.js.map +1 -1
  219. package/src/types/interfaces/template.config.ts +11 -11
  220. package/templates/angular/src/app/app.component.html.ejs +17 -17
  221. package/templates/angular/src/app/cmp-array.ejs +3 -3
  222. package/templates/angular/src/app/cmp-hash.ejs +3 -3
  223. package/templates/angular/src/app/component-list.g.ts +21 -21
  224. package/templates/angular/src/app.component.ts +14 -14
  225. package/templates/angular/src/app.module.ts +70 -70
  226. package/templates/angular/src/app.routes.ts +73 -73
  227. package/templates/angular/src/styles/app.css +5 -5
  228. package/templates/attributes/button_attributes.ejs +2 -2
  229. package/templates/attributes/common/base/class.ejs +6 -6
  230. package/templates/attributes/common/base/control_type.ejs +53 -53
  231. package/templates/attributes/common/base/enabled.ejs +9 -9
  232. package/templates/attributes/common/base/imageFileName.ejs +3 -3
  233. package/templates/attributes/common/base/no_control_class.ejs +3 -3
  234. package/templates/attributes/common/base/rtol.ejs +3 -3
  235. package/templates/attributes/common/base/tabindex.ejs +11 -11
  236. package/templates/attributes/common/base/testingId.ejs +8 -8
  237. package/templates/attributes/common/base/tooltip.ejs +7 -7
  238. package/templates/attributes/common/base/visible.ejs +6 -6
  239. package/templates/attributes/common/base/wallpaper.ejs +3 -3
  240. package/templates/attributes/common/base_attributes.ejs +10 -10
  241. package/templates/attributes/common/container_attributes.ejs +6 -6
  242. package/templates/attributes/common/control_attributes.ejs +3 -3
  243. package/templates/attributes/common/format.ejs +5 -5
  244. package/templates/attributes/common/input/hint.ejs +13 -13
  245. package/templates/attributes/common/input/multiline_edit.ejs +3 -3
  246. package/templates/attributes/common/input/must_input.ejs +8 -8
  247. package/templates/attributes/common/input/password_edit.ejs +7 -7
  248. package/templates/attributes/common/input/row_editing_input_attributes.ejs +6 -6
  249. package/templates/attributes/common/input/validation.ejs +5 -5
  250. package/templates/attributes/common/input_attributes.ejs +4 -4
  251. package/templates/attributes/common/no_control_base_attributes.ejs +4 -4
  252. package/templates/attributes/common/row_editing_button_attributes.ejs +10 -10
  253. package/templates/component/view.component.html +14 -14
  254. package/templates/component/view.component.ts +123 -122
  255. package/templates/themes/basicHTML/Code/theme.module.ts +10 -10
  256. package/templates/themes/basicHTML/checkbox.ejs +1 -1
  257. package/templates/themes/basicHTML/combobox.ejs +37 -37
  258. package/templates/themes/basicHTML/edit.ejs +169 -169
  259. package/templates/themes/basicHTML/form.ejs +4 -4
  260. package/templates/themes/basicHTML/group.ejs +4 -4
  261. package/templates/themes/basicHTML/image.ejs +6 -6
  262. package/templates/themes/basicHTML/label.ejs +11 -11
  263. package/templates/themes/basicHTML/listbox.ejs +21 -21
  264. package/templates/themes/basicHTML/push-button.ejs +28 -28
  265. package/templates/themes/basicHTML/radio.ejs +20 -20
  266. package/templates/themes/basicHTML/subform.ejs +6 -6
  267. package/templates/themes/basicHTML/tab.ejs +31 -31
  268. package/templates/themes/basicHTML/tabpage.ejs +5 -5
  269. package/templates/themes/basicHiddenHTML/Code/theme.module.ts +10 -10
  270. package/templates/themes/basicHiddenHTML/combobox.ejs +5 -5
  271. package/templates/themes/basicHiddenHTML/form.ejs +3 -3
  272. package/templates/themes/basicHiddenHTML/group.ejs +2 -2
  273. package/templates/themes/basicHiddenHTML/image.ejs +4 -4
  274. package/templates/themes/basicHiddenHTML/label.ejs +1 -1
  275. package/templates/themes/basicHiddenHTML/listbox.ejs +8 -8
  276. package/templates/themes/basicHiddenHTML/push-button.ejs +26 -26
  277. package/templates/themes/basicHiddenHTML/radio.ejs +17 -17
  278. package/templates/themes/basicHiddenHTML/tab.ejs +13 -13
  279. package/templates/themes/basicHiddenHTML/table.ejs +18 -18
  280. package/templates/themes/basicHiddenHTML/tabpage.ejs +2 -2
  281. package/templates/themes/container.ejs +26 -26
  282. package/templates/themes/control.ejs +52 -52
  283. package/templates/themes/editTypeSelector.ejs +1 -1
  284. package/templates/themes/material/Code/theme.module.ts +68 -68
  285. package/templates/themes/material/base_attributes_date.ejs +8 -8
  286. package/templates/themes/material/checkbox.ejs +1 -1
  287. package/templates/themes/material/combobox.ejs +43 -43
  288. package/templates/themes/material/edit.ejs +204 -204
  289. package/templates/themes/material/group.ejs +3 -3
  290. package/templates/themes/material/listbox.ejs +22 -23
  291. package/templates/themes/material/push-button.ejs +28 -28
  292. package/templates/themes/material/radio.ejs +22 -22
  293. package/templates/themes/material/subform.ejs +8 -8
  294. package/templates/themes/material/tab.ejs +19 -19
  295. package/templates/themes/router_outlet.ejs +5 -5
  296. package/templates/themes/table/HTMLTable/columnHeader.ejs +3 -1
  297. package/templates/themes/table/HTMLTable/table.ejs +37 -37
  298. package/templates/themes/table/grid/additionalComponentCode.ejs +26 -26
  299. package/templates/themes/table/grid/additionalIncludes.ejs +1 -1
  300. package/templates/themes/table/grid/column.ejs +3 -1
  301. package/templates/themes/table/grid/table.ejs +37 -37
  302. package/templates/themes/table/repeatable/column.ejs +11 -11
  303. package/templates/themes/table/repeatable/table.ejs +28 -28
  304. package/templates/themes/tableTypeSelector.ejs +21 -21
  305. package/tsconfig.json +36 -36
@@ -1,152 +1,151 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mgAdd = void 0;
4
- const schematics_1 = require("@angular-devkit/schematics");
5
- const tasks_1 = require("@angular-devkit/schematics/tasks");
6
- const package_1 = require("./../utils/package");
7
- const env_1 = require("../magic-utils/env");
8
- const utils_1 = require("../magic-utils/utils");
9
- const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
10
- const ast_1 = require("../utils/ast");
11
- const Util_1 = require("../magic-utils/Util");
12
- const generate_rule_1 = require("../magic-utils/rules/generate.rule");
13
- const generated_file_types_enum_1 = require("../../types/enums/generated-file-types.enum");
14
- const ast_utils_1 = require("../utils/devkit-utils/ast-utils");
15
- const ts = require("typescript");
16
- const change_1 = require("../utils/devkit-utils/change");
17
- function mgAdd(options) {
18
- return (0, schematics_1.chain)([
19
- (0, init_magic_metadata_rule_1.initMagicMetadata)(options),
20
- (0, utils_1.copyMagicFiles)(options),
21
- // handel app.modules.ts
22
- addMagicModuleToAppModule(options),
23
- // handel Angular.json
24
- updateAngularJsonWithMagicStyle(options),
25
- updateTsConfigAppJson(options),
26
- addLazyLoadProvider(),
27
- // handel app.component.html
28
- //updateAppComponentHtmlFiles (options),
29
- //handel package.Json
30
- //addMagicDependenciesToPackageJson (options),
31
- ]);
32
- }
33
- exports.mgAdd = mgAdd;
34
- function updateAppComponentHtmlFiles(options) {
35
- return (0, generate_rule_1.generate)({
36
- template: "./templates/angular/src/app/app.component.html.ejs",
37
- name: "app.component.html",
38
- destination: env_1.env.metadata.paths.rootMagicGenFolder,
39
- type: generated_file_types_enum_1.GeneratedFileTypes.HTML,
40
- data: {
41
- skipHelp: options.skipHelp
42
- }
43
- }, options);
44
- }
45
- function updateAngularJsonWithMagicStyle(options) {
46
- return (host, context) => {
47
- const project = env_1.env.project;
48
- let isDirty = false;
49
- let fullPathmagicStylePath = env_1.env.metadata.paths.magicStylePath;
50
- if (!project.architect.test.options.styles.includes(fullPathmagicStylePath)) {
51
- context.logger.info(` [>]add file ${fullPathmagicStylePath} to test`);
52
- project.architect.test.options.styles.push(fullPathmagicStylePath);
53
- isDirty = true;
54
- }
55
- if (!project.architect.build.options.styles.includes(fullPathmagicStylePath)) {
56
- context.logger.info(` [>]add file ${fullPathmagicStylePath} to build`);
57
- project.architect.build.options.styles.push(fullPathmagicStylePath);
58
- isDirty = true;
59
- }
60
- if (isDirty) {
61
- let fullPath = env_1.env.metadata.paths.angularJsonPath;
62
- host.overwrite(fullPath, JSON.stringify(env_1.env.workspace, null, 2));
63
- }
64
- return host;
65
- };
66
- }
67
- // Angular 10 , does not include .ts file for compilation
68
- // So to avoid compilation error , add *.module.ts in includes section
69
- function updateTsConfigAppJson(option) {
70
- return (host, context) => {
71
- const tsConfigPath = env_1.env.metadata.paths.tsConfigAppJsonPath;
72
- const tsConfig = host.read(tsConfigPath).toString("utf-8");
73
- // extract the comment
74
- let comment = tsConfig.substring(tsConfig.indexOf('/*'), tsConfig.indexOf('*/') + 2);
75
- // replace the comment as parsing json with comment throws exception
76
- var config = JSON.parse(tsConfig.replace(comment, ''));
77
- //Add module files for compilation
78
- if (!config['include'].includes('src/**/*module.ts'))
79
- config['include'].push('src/**/*module.ts');
80
- // append the comment again and write the file
81
- host.overwrite(tsConfigPath, comment + "\n" + JSON.stringify(config, null, 2));
82
- return host;
83
- };
84
- }
85
- function addMagicDependenciesToPackageJson(option) {
86
- return (host, context) => {
87
- if (!option.skipPackageJson) {
88
- for (let dep of env_1.dependencies) {
89
- (0, Util_1.LogLn)(`[>] Add dependencies ${dep.name}`);
90
- (0, package_1.addPackageToPackageJson)(host, 'dependencies', dep.name, dep.version);
91
- }
92
- /*
93
- // done in pre-install step
94
- for (let dep of devDependencies){
95
- LogLn(`[>] Add devDependencies ${dep.name}`);
96
- addPackageToPackageJson(host, 'devDependencies', dep.name, dep.version);
97
- }
98
- */
99
- }
100
- if (!option.skipInstall) {
101
- (0, Util_1.LogLn)(`[>] Install dependencies.`);
102
- context.addTask(new tasks_1.NodePackageInstallTask());
103
- }
104
- else {
105
- (0, Util_1.LogLn)(`skipIstalls ${env_1.dependencies.length} dependencies`);
106
- (0, Util_1.LogLn)(`skipIstalls ${env_1.devDependencies.length} devDependencies`);
107
- }
108
- return host;
109
- };
110
- }
111
- function addMagicModuleToAppModule(options) {
112
- return (host, context) => {
113
- const workspace = env_1.env.workspace;
114
- const project = env_1.env.project;
115
- (0, ast_1.addModuleImportToRootModule)(host, 'BrowserAnimationsModule', '@angular/platform-browser/animations', project);
116
- (0, ast_1.addModuleImportToRootModule)(host, 'ReactiveFormsModule', '@angular/forms', project);
117
- (0, ast_1.addModuleImportToRootModule)(host, 'MagicModule', "@magic-xpa/angular", project);
118
- (0, ast_1.addModuleImportToRootModule)(host, 'MagicAngularMaterialModule', "@magic-xpa/angular-material-core", project);
119
- (0, ast_1.addModuleImportToRootModule)(host, 'MagicGenLibModule', "./magic/magic.gen.lib.module", project);
120
- (0, ast_1.addModuleImportToRootModule)(host, 'MagicRoutingModule', "./app.routes", project);
121
- };
122
- }
123
- function addLazyLoadProvider() {
124
- return (host) => {
125
- const appmodule = env_1.env.metadata.paths.rootMagicGenFolder + '/app.module.ts';
126
- const lazyLoaderService = 'LazyLoaderService';
127
- const lazyLoaderServicePath = './magic/lazy-loader.service';
128
- let text = host.read(appmodule);
129
- let sourceText = text.toString('utf-8');
130
- let source = ts.createSourceFile(appmodule, sourceText, ts.ScriptTarget.Latest, true);
131
- let providerChanges = (0, ast_utils_1.addProviderToModule)(source, appmodule, '{ provide: MagicLazyLoaderService, useClass: LazyLoaderService }', lazyLoaderServicePath);
132
- const providerRecorder = host.beginUpdate(appmodule);
133
- for (const change of providerChanges) {
134
- if (change instanceof change_1.InsertChange) {
135
- if (!change.toAdd.includes('import')) // skip import change
136
- providerRecorder.insertLeft(change.pos, change.toAdd);
137
- }
138
- }
139
- host.commitUpdate(providerRecorder);
140
- const lazyLoaderServiceImport = (0, ast_utils_1.insertImport)(source, appmodule, lazyLoaderService, lazyLoaderServicePath, false);
141
- const lazyLoaderServiceChangesRecorder = host.beginUpdate(appmodule);
142
- if (lazyLoaderServiceImport instanceof change_1.InsertChange)
143
- lazyLoaderServiceChangesRecorder.insertLeft(lazyLoaderServiceImport.pos, lazyLoaderServiceImport.toAdd);
144
- host.commitUpdate(lazyLoaderServiceChangesRecorder);
145
- // add import for MagicLazyLoaderService
146
- const magicLazyLoaderServiceImportChanges = (0, ast_utils_1.insertImport)(source, appmodule, 'MagicLazyLoaderService', '@magic-xpa/angular', false);
147
- const magicImportChangesRecorder = host.beginUpdate(appmodule);
148
- magicImportChangesRecorder.insertLeft(magicLazyLoaderServiceImportChanges.pos, magicLazyLoaderServiceImportChanges.toAdd);
149
- host.commitUpdate(magicImportChangesRecorder);
150
- };
151
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mgAdd = mgAdd;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
6
+ const package_1 = require("./../utils/package");
7
+ const env_1 = require("../magic-utils/env");
8
+ const utils_1 = require("../magic-utils/utils");
9
+ const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
10
+ const ast_1 = require("../utils/ast");
11
+ const Util_1 = require("../magic-utils/Util");
12
+ const generate_rule_1 = require("../magic-utils/rules/generate.rule");
13
+ const generated_file_types_enum_1 = require("../../types/enums/generated-file-types.enum");
14
+ const ast_utils_1 = require("../utils/devkit-utils/ast-utils");
15
+ const ts = require("typescript");
16
+ const change_1 = require("../utils/devkit-utils/change");
17
+ function mgAdd(options) {
18
+ return (0, schematics_1.chain)([
19
+ (0, init_magic_metadata_rule_1.initMagicMetadata)(options),
20
+ (0, utils_1.copyMagicFiles)(options),
21
+ // handel app.modules.ts
22
+ addMagicModuleToAppModule(options),
23
+ // handel Angular.json
24
+ updateAngularJsonWithMagicStyle(options),
25
+ updateTsConfigAppJson(options),
26
+ addLazyLoadProvider(),
27
+ // handel app.component.html
28
+ //updateAppComponentHtmlFiles (options),
29
+ //handel package.Json
30
+ //addMagicDependenciesToPackageJson (options),
31
+ ]);
32
+ }
33
+ function updateAppComponentHtmlFiles(options) {
34
+ return (0, generate_rule_1.generate)({
35
+ template: "./templates/angular/src/app/app.component.html.ejs",
36
+ name: "app.component.html",
37
+ destination: env_1.env.metadata.paths.rootMagicGenFolder,
38
+ type: generated_file_types_enum_1.GeneratedFileTypes.HTML,
39
+ data: {
40
+ skipHelp: options.skipHelp
41
+ }
42
+ }, options);
43
+ }
44
+ function updateAngularJsonWithMagicStyle(options) {
45
+ return (host, context) => {
46
+ const project = env_1.env.project;
47
+ let isDirty = false;
48
+ let fullPathmagicStylePath = env_1.env.metadata.paths.magicStylePath;
49
+ if (!project.architect.test.options.styles.includes(fullPathmagicStylePath)) {
50
+ context.logger.info(` [>]add file ${fullPathmagicStylePath} to test`);
51
+ project.architect.test.options.styles.push(fullPathmagicStylePath);
52
+ isDirty = true;
53
+ }
54
+ if (!project.architect.build.options.styles.includes(fullPathmagicStylePath)) {
55
+ context.logger.info(` [>]add file ${fullPathmagicStylePath} to build`);
56
+ project.architect.build.options.styles.push(fullPathmagicStylePath);
57
+ isDirty = true;
58
+ }
59
+ if (isDirty) {
60
+ let fullPath = env_1.env.metadata.paths.angularJsonPath;
61
+ host.overwrite(fullPath, JSON.stringify(env_1.env.workspace, null, 2));
62
+ }
63
+ return host;
64
+ };
65
+ }
66
+ // Angular 10 , does not include .ts file for compilation
67
+ // So to avoid compilation error , add *.module.ts in includes section
68
+ function updateTsConfigAppJson(option) {
69
+ return (host, context) => {
70
+ const tsConfigPath = env_1.env.metadata.paths.tsConfigAppJsonPath;
71
+ const tsConfig = host.read(tsConfigPath).toString("utf-8");
72
+ // extract the comment
73
+ let comment = tsConfig.substring(tsConfig.indexOf('/*'), tsConfig.indexOf('*/') + 2);
74
+ // replace the comment as parsing json with comment throws exception
75
+ var config = JSON.parse(tsConfig.replace(comment, ''));
76
+ //Add module files for compilation
77
+ if (!config['include'].includes('src/**/*module.ts'))
78
+ config['include'].push('src/**/*module.ts');
79
+ // append the comment again and write the file
80
+ host.overwrite(tsConfigPath, comment + "\n" + JSON.stringify(config, null, 2));
81
+ return host;
82
+ };
83
+ }
84
+ function addMagicDependenciesToPackageJson(option) {
85
+ return (host, context) => {
86
+ if (!option.skipPackageJson) {
87
+ for (let dep of env_1.dependencies) {
88
+ (0, Util_1.LogLn)(`[>] Add dependencies ${dep.name}`);
89
+ (0, package_1.addPackageToPackageJson)(host, 'dependencies', dep.name, dep.version);
90
+ }
91
+ /*
92
+ // done in pre-install step
93
+ for (let dep of devDependencies){
94
+ LogLn(`[>] Add devDependencies ${dep.name}`);
95
+ addPackageToPackageJson(host, 'devDependencies', dep.name, dep.version);
96
+ }
97
+ */
98
+ }
99
+ if (!option.skipInstall) {
100
+ (0, Util_1.LogLn)(`[>] Install dependencies.`);
101
+ context.addTask(new tasks_1.NodePackageInstallTask());
102
+ }
103
+ else {
104
+ (0, Util_1.LogLn)(`skipIstalls ${env_1.dependencies.length} dependencies`);
105
+ (0, Util_1.LogLn)(`skipIstalls ${env_1.devDependencies.length} devDependencies`);
106
+ }
107
+ return host;
108
+ };
109
+ }
110
+ function addMagicModuleToAppModule(options) {
111
+ return (host, context) => {
112
+ const workspace = env_1.env.workspace;
113
+ const project = env_1.env.project;
114
+ (0, ast_1.addModuleImportToRootModule)(host, 'BrowserAnimationsModule', '@angular/platform-browser/animations', project);
115
+ (0, ast_1.addModuleImportToRootModule)(host, 'ReactiveFormsModule', '@angular/forms', project);
116
+ (0, ast_1.addModuleImportToRootModule)(host, 'MagicModule', "@magic-xpa/angular", project);
117
+ (0, ast_1.addModuleImportToRootModule)(host, 'MagicAngularMaterialModule', "@magic-xpa/angular-material-core", project);
118
+ (0, ast_1.addModuleImportToRootModule)(host, 'MagicGenLibModule', "./magic/magic.gen.lib.module", project);
119
+ (0, ast_1.addModuleImportToRootModule)(host, 'MagicRoutingModule', "./app.routes", project);
120
+ };
121
+ }
122
+ function addLazyLoadProvider() {
123
+ return (host) => {
124
+ const appmodule = env_1.env.metadata.paths.rootMagicGenFolder + '/app.module.ts';
125
+ const lazyLoaderService = 'LazyLoaderService';
126
+ const lazyLoaderServicePath = './magic/lazy-loader.service';
127
+ let text = host.read(appmodule);
128
+ let sourceText = text.toString('utf-8');
129
+ let source = ts.createSourceFile(appmodule, sourceText, ts.ScriptTarget.Latest, true);
130
+ let providerChanges = (0, ast_utils_1.addProviderToModule)(source, appmodule, '{ provide: MagicLazyLoaderService, useClass: LazyLoaderService }', lazyLoaderServicePath);
131
+ const providerRecorder = host.beginUpdate(appmodule);
132
+ for (const change of providerChanges) {
133
+ if (change instanceof change_1.InsertChange) {
134
+ if (!change.toAdd.includes('import')) // skip import change
135
+ providerRecorder.insertLeft(change.pos, change.toAdd);
136
+ }
137
+ }
138
+ host.commitUpdate(providerRecorder);
139
+ const lazyLoaderServiceImport = (0, ast_utils_1.insertImport)(source, appmodule, lazyLoaderService, lazyLoaderServicePath, false);
140
+ const lazyLoaderServiceChangesRecorder = host.beginUpdate(appmodule);
141
+ if (lazyLoaderServiceImport instanceof change_1.InsertChange)
142
+ lazyLoaderServiceChangesRecorder.insertLeft(lazyLoaderServiceImport.pos, lazyLoaderServiceImport.toAdd);
143
+ host.commitUpdate(lazyLoaderServiceChangesRecorder);
144
+ // add import for MagicLazyLoaderService
145
+ const magicLazyLoaderServiceImportChanges = (0, ast_utils_1.insertImport)(source, appmodule, 'MagicLazyLoaderService', '@magic-xpa/angular', false);
146
+ const magicImportChangesRecorder = host.beginUpdate(appmodule);
147
+ magicImportChangesRecorder.insertLeft(magicLazyLoaderServiceImportChanges.pos, magicLazyLoaderServiceImportChanges.toAdd);
148
+ host.commitUpdate(magicImportChangesRecorder);
149
+ };
150
+ }
152
151
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","s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ACzH,IAAI,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC,CAAA;AACH,CAAC","sourcesContent":["import {\r\n Rule,\r\n chain,\r\n Tree,\r\n SchematicContext\r\n} from \"@angular-devkit/schematics\";\r\nimport {NodePackageInstallTask} from \"@angular-devkit/schematics/tasks\";\r\n\r\nimport {addPackageToPackageJson} from './../utils/package';\r\nimport { dependencies, devDependencies, env} from \"../magic-utils/env\";\r\nimport { addImportTSModule, copyMagicFiles} from \"../magic-utils/utils\";\r\nimport { initMagicMetadata} from \"../magic-utils/rules/init-magic-metadata.rule\";\r\nimport { addModuleImportToRootModule } from \"../utils/ast\";\r\nimport { LogLn } from \"../magic-utils/Util\";\r\nimport { generate } from \"../magic-utils/rules/generate.rule\";\r\nimport { GeneratedFileTypes } from \"../../types/enums/generated-file-types.enum\";\r\nimport { MagicOptionScheme } from \"../magic-utils/rules/magic-option.scheme\";\r\nimport {addProviderToModule, insertImport} from \"../utils/devkit-utils/ast-utils\";\r\nimport * as ts from 'typescript';\r\nimport {InsertChange} from \"../utils/devkit-utils/change\";\r\nexport function mgAdd(options:MagicOptionScheme): Rule {\r\n return chain([\r\n initMagicMetadata (options),\r\n copyMagicFiles (options),\r\n\r\n // handel app.modules.ts\r\n addMagicModuleToAppModule (options),\r\n\r\n // handel Angular.json\r\n updateAngularJsonWithMagicStyle (options),\r\n\r\n updateTsConfigAppJson (options),\r\n\r\n addLazyLoadProvider(),\r\n // handel app.component.html\r\n //updateAppComponentHtmlFiles (options),\r\n\r\n //handel package.Json\r\n //addMagicDependenciesToPackageJson (options),\r\n ]);\r\n}\r\n\r\nfunction updateAppComponentHtmlFiles(options:MagicOptionScheme): Rule {\r\n return generate({\r\n template : \"./templates/angular/src/app/app.component.html.ejs\",\r\n name : \"app.component.html\",\r\n destination : env.metadata.paths.rootMagicGenFolder,\r\n type :GeneratedFileTypes.HTML,\r\n data : {\r\n skipHelp : options.skipHelp\r\n }\r\n },options)\r\n}\r\nfunction updateAngularJsonWithMagicStyle(options:MagicOptionScheme): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n const project = env.project;\r\n let isDirty = false;\r\n\r\n let fullPathmagicStylePath = env.metadata.paths.magicStylePath;\r\n if (!project.architect.test.options.styles.includes(fullPathmagicStylePath)) {\r\n context.logger.info(` [>]add file ${fullPathmagicStylePath} to test`);\r\n project.architect.test.options.styles.push(fullPathmagicStylePath);\r\n isDirty = true;\r\n }\r\n\r\n if (!project.architect.build.options.styles.includes(fullPathmagicStylePath)) {\r\n context.logger.info(` [>]add file ${fullPathmagicStylePath} to build`);\r\n project.architect.build.options.styles.push(fullPathmagicStylePath);\r\n isDirty = true;\r\n }\r\n\r\n if(isDirty){\r\n let fullPath = env.metadata.paths.angularJsonPath;\r\n host.overwrite(fullPath, JSON.stringify(env.workspace, null, 2));\r\n }\r\n\r\n return host;\r\n };\r\n}\r\n\r\n// Angular 10 , does not include .ts file for compilation\r\n// So to avoid compilation error , add *.module.ts in includes section\r\nfunction updateTsConfigAppJson (option: MagicOptionScheme): Rule{\r\n return (host: Tree, context: SchematicContext) => {\r\n\r\n const tsConfigPath = env.metadata.paths.tsConfigAppJsonPath;\r\n const tsConfig = host.read(tsConfigPath)!.toString(\"utf-8\");\r\n\r\n // extract the comment\r\n let comment = tsConfig.substring(tsConfig.indexOf('/*'), tsConfig.indexOf('*/') + 2);\r\n\r\n // replace the comment as parsing json with comment throws exception\r\n var config = JSON.parse(tsConfig.replace(comment, ''));\r\n\r\n //Add module files for compilation\r\n if(!config['include'].includes('src/**/*module.ts'))\r\n config['include'].push('src/**/*module.ts');\r\n\r\n // append the comment again and write the file\r\n host.overwrite(tsConfigPath, comment + \"\\n\" + JSON.stringify(config, null , 2));\r\n return host;\r\n }\r\n}\r\n\r\nfunction addMagicDependenciesToPackageJson(option:MagicOptionScheme): Rule {\r\n\treturn (host: Tree, context: SchematicContext) => {\r\n\t if(!option.skipPackageJson){\r\n for (let dep of dependencies){\r\n LogLn(`[>] Add dependencies ${dep.name}`);\r\n addPackageToPackageJson(host, 'dependencies', dep.name, dep.version);\r\n }\r\n /*\r\n // done in pre-install step\r\n for (let dep of devDependencies){\r\n LogLn(`[>] Add devDependencies ${dep.name}`);\r\n addPackageToPackageJson(host, 'devDependencies', dep.name, dep.version);\r\n }\r\n */\r\n }\r\n\r\n\t\tif(!option.skipInstall){\r\n LogLn(`[>] Install dependencies.`);\r\n context.addTask(new NodePackageInstallTask());\r\n }else{\r\n LogLn(`skipIstalls ${dependencies.length} dependencies`);\r\n LogLn(`skipIstalls ${devDependencies.length} devDependencies`);\r\n }\r\n\r\n\t\treturn host;\r\n\t};\r\n}\r\nfunction addMagicModuleToAppModule(options: MagicOptionScheme) : Rule {\r\n return (host: Tree , context : SchematicContext)=>{\r\n const workspace = env.workspace;\r\n const project = env.project;\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'BrowserAnimationsModule',\r\n '@angular/platform-browser/animations',\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'ReactiveFormsModule',\r\n '@angular/forms',\r\n project);\r\n\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicModule',\r\n \"@magic-xpa/angular\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicAngularMaterialModule',\r\n \"@magic-xpa/angular-material-core\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicGenLibModule',\r\n \"./magic/magic.gen.lib.module\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicRoutingModule',\r\n \"./app.routes\",\r\n project);\r\n\r\n\r\n }\r\n}\r\n\r\nfunction addLazyLoadProvider(): Rule {\r\n return (host: Tree) => {\r\n const appmodule = env.metadata.paths.rootMagicGenFolder + '/app.module.ts';\r\n\r\n const lazyLoaderService = 'LazyLoaderService';\r\n const lazyLoaderServicePath = './magic/lazy-loader.service';\r\n\r\n let text = host.read(appmodule);\r\n let sourceText = text.toString('utf-8');\r\n let source = ts.createSourceFile(appmodule, sourceText, ts.ScriptTarget.Latest, true);\r\n let providerChanges = addProviderToModule(source, appmodule, '{ provide: MagicLazyLoaderService, useClass: LazyLoaderService }', lazyLoaderServicePath)\r\n\r\n const providerRecorder = host.beginUpdate(appmodule);\r\n for (const change of providerChanges) {\r\n if (change instanceof InsertChange) {\r\n if (!change.toAdd.includes('import')) // skip import change\r\n providerRecorder.insertLeft(change.pos, change.toAdd);\r\n }\r\n }\r\n host.commitUpdate(providerRecorder);\r\n\r\n const lazyLoaderServiceImport = insertImport(source, appmodule, lazyLoaderService, lazyLoaderServicePath, false);\r\n const lazyLoaderServiceChangesRecorder = host.beginUpdate(appmodule);\r\n if (lazyLoaderServiceImport instanceof InsertChange)\r\n lazyLoaderServiceChangesRecorder.insertLeft(lazyLoaderServiceImport.pos, lazyLoaderServiceImport.toAdd);\r\n host.commitUpdate(lazyLoaderServiceChangesRecorder);\r\n\r\n // add import for MagicLazyLoaderService\r\n const magicLazyLoaderServiceImportChanges: InsertChange = <InsertChange>insertImport(source, appmodule, 'MagicLazyLoaderService', '@magic-xpa/angular', false);\r\n const magicImportChangesRecorder = host.beginUpdate(appmodule);\r\n magicImportChangesRecorder.insertLeft(magicLazyLoaderServiceImportChanges.pos, magicLazyLoaderServiceImportChanges.toAdd)\r\n host.commitUpdate(magicImportChangesRecorder);\r\n }\r\n}\r\n\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAoBA,sBAoBC;AAxCD,2DAKoC;AACpC,4DAAwE;AAExE,gDAA2D;AAC3D,4CAAuE;AACvE,gDAAwE;AACxE,4FAAiF;AACjF,sCAA2D;AAC3D,8CAA4C;AAC5C,sEAA8D;AAC9D,2FAAiF;AAEjF,+DAAkF;AAClF,iCAAiC;AACjC,yDAA0D;AAC1D,SAAgB,KAAK,CAAC,OAAyB;IAC7C,OAAO,IAAA,kBAAK,EAAC;QACX,IAAA,4CAAiB,EAAkB,OAAO,CAAC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CAAC;QACrD,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;YACrC,IAAI,MAAM,YAAY,qBAAY,EAAE,CAAC;gBACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAG,qBAAqB;oBAC5D,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;QAEpC,MAAM,uBAAuB,GAAG,IAAA,wBAAY,EAAC,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;QACjH,MAAM,gCAAgC,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACrE,IAAI,uBAAuB,YAAY,qBAAY;YACjD,gCAAgC,CAAC,UAAU,CAAC,uBAAuB,CAAC,GAAG,EAAE,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAC1G,IAAI,CAAC,YAAY,CAAC,gCAAgC,CAAC,CAAC;QAEpD,wCAAwC;QACxC,MAAM,mCAAmC,GAA+B,IAAA,wBAAY,EAAC,MAAM,EAAE,SAAS,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAC/J,MAAM,0BAA0B,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAC/D,0BAA0B,CAAC,UAAU,CAAC,mCAAmC,CAAC,GAAG,EAAE,mCAAmC,CAAC,KAAK,CAAC,CAAA;QACzH,IAAI,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC,CAAA;AACH,CAAC","sourcesContent":["import {\r\n Rule,\r\n chain,\r\n Tree,\r\n SchematicContext\r\n} from \"@angular-devkit/schematics\";\r\nimport {NodePackageInstallTask} from \"@angular-devkit/schematics/tasks\";\r\n\r\nimport {addPackageToPackageJson} from './../utils/package';\r\nimport { dependencies, devDependencies, env} from \"../magic-utils/env\";\r\nimport { addImportTSModule, copyMagicFiles} from \"../magic-utils/utils\";\r\nimport { initMagicMetadata} from \"../magic-utils/rules/init-magic-metadata.rule\";\r\nimport { addModuleImportToRootModule } from \"../utils/ast\";\r\nimport { LogLn } from \"../magic-utils/Util\";\r\nimport { generate } from \"../magic-utils/rules/generate.rule\";\r\nimport { GeneratedFileTypes } from \"../../types/enums/generated-file-types.enum\";\r\nimport { MagicOptionScheme } from \"../magic-utils/rules/magic-option.scheme\";\r\nimport {addProviderToModule, insertImport} from \"../utils/devkit-utils/ast-utils\";\r\nimport * as ts from 'typescript';\r\nimport {InsertChange} from \"../utils/devkit-utils/change\";\r\nexport function mgAdd(options:MagicOptionScheme): Rule {\r\n return chain([\r\n initMagicMetadata (options),\r\n copyMagicFiles (options),\r\n\r\n // handel app.modules.ts\r\n addMagicModuleToAppModule (options),\r\n\r\n // handel Angular.json\r\n updateAngularJsonWithMagicStyle (options),\r\n\r\n updateTsConfigAppJson (options),\r\n\r\n addLazyLoadProvider(),\r\n // handel app.component.html\r\n //updateAppComponentHtmlFiles (options),\r\n\r\n //handel package.Json\r\n //addMagicDependenciesToPackageJson (options),\r\n ]);\r\n}\r\n\r\nfunction updateAppComponentHtmlFiles(options:MagicOptionScheme): Rule {\r\n return generate({\r\n template : \"./templates/angular/src/app/app.component.html.ejs\",\r\n name : \"app.component.html\",\r\n destination : env.metadata.paths.rootMagicGenFolder,\r\n type :GeneratedFileTypes.HTML,\r\n data : {\r\n skipHelp : options.skipHelp\r\n }\r\n },options)\r\n}\r\nfunction updateAngularJsonWithMagicStyle(options:MagicOptionScheme): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n const project = env.project;\r\n let isDirty = false;\r\n\r\n let fullPathmagicStylePath = env.metadata.paths.magicStylePath;\r\n if (!project.architect.test.options.styles.includes(fullPathmagicStylePath)) {\r\n context.logger.info(` [>]add file ${fullPathmagicStylePath} to test`);\r\n project.architect.test.options.styles.push(fullPathmagicStylePath);\r\n isDirty = true;\r\n }\r\n\r\n if (!project.architect.build.options.styles.includes(fullPathmagicStylePath)) {\r\n context.logger.info(` [>]add file ${fullPathmagicStylePath} to build`);\r\n project.architect.build.options.styles.push(fullPathmagicStylePath);\r\n isDirty = true;\r\n }\r\n\r\n if(isDirty){\r\n let fullPath = env.metadata.paths.angularJsonPath;\r\n host.overwrite(fullPath, JSON.stringify(env.workspace, null, 2));\r\n }\r\n\r\n return host;\r\n };\r\n}\r\n\r\n// Angular 10 , does not include .ts file for compilation\r\n// So to avoid compilation error , add *.module.ts in includes section\r\nfunction updateTsConfigAppJson (option: MagicOptionScheme): Rule{\r\n return (host: Tree, context: SchematicContext) => {\r\n\r\n const tsConfigPath = env.metadata.paths.tsConfigAppJsonPath;\r\n const tsConfig = host.read(tsConfigPath)!.toString(\"utf-8\");\r\n\r\n // extract the comment\r\n let comment = tsConfig.substring(tsConfig.indexOf('/*'), tsConfig.indexOf('*/') + 2);\r\n\r\n // replace the comment as parsing json with comment throws exception\r\n var config = JSON.parse(tsConfig.replace(comment, ''));\r\n\r\n //Add module files for compilation\r\n if(!config['include'].includes('src/**/*module.ts'))\r\n config['include'].push('src/**/*module.ts');\r\n\r\n // append the comment again and write the file\r\n host.overwrite(tsConfigPath, comment + \"\\n\" + JSON.stringify(config, null , 2));\r\n return host;\r\n }\r\n}\r\n\r\nfunction addMagicDependenciesToPackageJson(option:MagicOptionScheme): Rule {\r\n\treturn (host: Tree, context: SchematicContext) => {\r\n\t if(!option.skipPackageJson){\r\n for (let dep of dependencies){\r\n LogLn(`[>] Add dependencies ${dep.name}`);\r\n addPackageToPackageJson(host, 'dependencies', dep.name, dep.version);\r\n }\r\n /*\r\n // done in pre-install step\r\n for (let dep of devDependencies){\r\n LogLn(`[>] Add devDependencies ${dep.name}`);\r\n addPackageToPackageJson(host, 'devDependencies', dep.name, dep.version);\r\n }\r\n */\r\n }\r\n\r\n\t\tif(!option.skipInstall){\r\n LogLn(`[>] Install dependencies.`);\r\n context.addTask(new NodePackageInstallTask());\r\n }else{\r\n LogLn(`skipIstalls ${dependencies.length} dependencies`);\r\n LogLn(`skipIstalls ${devDependencies.length} devDependencies`);\r\n }\r\n\r\n\t\treturn host;\r\n\t};\r\n}\r\nfunction addMagicModuleToAppModule(options: MagicOptionScheme) : Rule {\r\n return (host: Tree , context : SchematicContext)=>{\r\n const workspace = env.workspace;\r\n const project = env.project;\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'BrowserAnimationsModule',\r\n '@angular/platform-browser/animations',\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'ReactiveFormsModule',\r\n '@angular/forms',\r\n project);\r\n\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicModule',\r\n \"@magic-xpa/angular\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicAngularMaterialModule',\r\n \"@magic-xpa/angular-material-core\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicGenLibModule',\r\n \"./magic/magic.gen.lib.module\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicRoutingModule',\r\n \"./app.routes\",\r\n project);\r\n\r\n\r\n }\r\n}\r\n\r\nfunction addLazyLoadProvider(): Rule {\r\n return (host: Tree) => {\r\n const appmodule = env.metadata.paths.rootMagicGenFolder + '/app.module.ts';\r\n\r\n const lazyLoaderService = 'LazyLoaderService';\r\n const lazyLoaderServicePath = './magic/lazy-loader.service';\r\n\r\n let text = host.read(appmodule);\r\n let sourceText = text.toString('utf-8');\r\n let source = ts.createSourceFile(appmodule, sourceText, ts.ScriptTarget.Latest, true);\r\n let providerChanges = addProviderToModule(source, appmodule, '{ provide: MagicLazyLoaderService, useClass: LazyLoaderService }', lazyLoaderServicePath)\r\n\r\n const providerRecorder = host.beginUpdate(appmodule);\r\n for (const change of providerChanges) {\r\n if (change instanceof InsertChange) {\r\n if (!change.toAdd.includes('import')) // skip import change\r\n providerRecorder.insertLeft(change.pos, change.toAdd);\r\n }\r\n }\r\n host.commitUpdate(providerRecorder);\r\n\r\n const lazyLoaderServiceImport = insertImport(source, appmodule, lazyLoaderService, lazyLoaderServicePath, false);\r\n const lazyLoaderServiceChangesRecorder = host.beginUpdate(appmodule);\r\n if (lazyLoaderServiceImport instanceof InsertChange)\r\n lazyLoaderServiceChangesRecorder.insertLeft(lazyLoaderServiceImport.pos, lazyLoaderServiceImport.toAdd);\r\n host.commitUpdate(lazyLoaderServiceChangesRecorder);\r\n\r\n // add import for MagicLazyLoaderService\r\n const magicLazyLoaderServiceImportChanges: InsertChange = <InsertChange>insertImport(source, appmodule, 'MagicLazyLoaderService', '@magic-xpa/angular', false);\r\n const magicImportChangesRecorder = host.beginUpdate(appmodule);\r\n magicImportChangesRecorder.insertLeft(magicLazyLoaderServiceImportChanges.pos, magicLazyLoaderServiceImportChanges.toAdd)\r\n host.commitUpdate(magicImportChangesRecorder);\r\n }\r\n}\r\n\r\n"]}
@@ -1,29 +1,29 @@
1
- {
2
- "$schema": "http://json-schema.org/schema",
3
- "$id": "SchematicsMagicAdd",
4
- "title": "Magic Options Schema",
5
- "type": "object",
6
- "properties": {
7
- "skipInstall": {
8
- "type": "boolean",
9
- "default": false,
10
- "description": "Do not install the new packages (e.g., --skipInstall)"
11
- },
12
- "skipPackageJson": {
13
- "type": "boolean",
14
- "default": false,
15
- "description": "Do not add magic dependencies to package.json (e.g., --skipPackageJson)"
16
- },
17
- "skipHelp": {
18
- "type": "boolean",
19
- "default": false,
20
- "description": "Whether to create Startup Welcome Pag (e.g., --skipHelp)"
21
- },
22
- "project":{
23
- "type": "string",
24
- "description": "The name of the project",
25
- "aliases" : ["p"]
26
- }
27
- },
28
- "required": []
29
- }
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "SchematicsMagicAdd",
4
+ "title": "Magic Options Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "skipInstall": {
8
+ "type": "boolean",
9
+ "default": false,
10
+ "description": "Do not install the new packages (e.g., --skipInstall)"
11
+ },
12
+ "skipPackageJson": {
13
+ "type": "boolean",
14
+ "default": false,
15
+ "description": "Do not add magic dependencies to package.json (e.g., --skipPackageJson)"
16
+ },
17
+ "skipHelp": {
18
+ "type": "boolean",
19
+ "default": false,
20
+ "description": "Whether to create Startup Welcome Pag (e.g., --skipHelp)"
21
+ },
22
+ "project":{
23
+ "type": "string",
24
+ "description": "The name of the project",
25
+ "aliases" : ["p"]
26
+ }
27
+ },
28
+ "required": []
29
+ }
@@ -1,2 +1,2 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export declare function addDeclarationToRootModule(host: Tree, moduleName: string, importSrc: string): void;
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function addDeclarationToRootModule(host: Tree, moduleName: string, importSrc: string): void;
@@ -1,12 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addDeclarationToRootModule = void 0;
4
- const ast_1 = require("../../utils/ast");
5
- const ast_utils_1 = require("../../utils/devkit-utils/ast-utils");
6
- const core_1 = require("@angular-devkit/core");
7
- function addDeclarationToRootModule(host, moduleName, importSrc) {
8
- let path = `src/app/app.module.ts`, source = (0, ast_1.getSourceFile)(host, path);
9
- (0, ast_utils_1.addDeclarationToModule)(source, (0, core_1.normalize)(path), moduleName, importSrc);
10
- }
11
- exports.addDeclarationToRootModule = addDeclarationToRootModule;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addDeclarationToRootModule = addDeclarationToRootModule;
4
+ const ast_1 = require("../../utils/ast");
5
+ const ast_utils_1 = require("../../utils/devkit-utils/ast-utils");
6
+ const core_1 = require("@angular-devkit/core");
7
+ function addDeclarationToRootModule(host, moduleName, importSrc) {
8
+ let path = `src/app/app.module.ts`, source = (0, ast_1.getSourceFile)(host, path);
9
+ (0, ast_utils_1.addDeclarationToModule)(source, (0, core_1.normalize)(path), moduleName, importSrc);
10
+ }
12
11
  //# sourceMappingURL=add-declaration-to-root-module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-declaration-to-root-module.js","sourceRoot":"","sources":["add-declaration-to-root-module.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAC9C,kEAA0E;AAE1E,+CAA+C;AAE/C,SAAgB,0BAA0B,CAAC,IAAU,EAAE,UAAkB,EAAE,SAAiB;IAC3F,IACC,IAAI,GAAK,uBAAuB,EAChC,MAAM,GAAG,IAAA,mBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEpC,IAAA,kCAAsB,EAAC,MAAM,EAAE,IAAA,gBAAS,EAAC,IAAI,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACxE,CAAC;AAND,gEAMC","sourcesContent":["import {getSourceFile} from '../../utils/ast';\r\nimport {addDeclarationToModule} from '../../utils/devkit-utils/ast-utils';\r\nimport {Tree} from '@angular-devkit/schematics';\r\nimport {normalize} from '@angular-devkit/core';\r\n\r\nexport function addDeclarationToRootModule(host: Tree, moduleName: string, importSrc: string) {\r\n\tlet\r\n\t\tpath = `src/app/app.module.ts`,\r\n\t\tsource = getSourceFile(host, path);\r\n\t\r\n\taddDeclarationToModule(source, normalize(path), moduleName, importSrc);\r\n}\r\n"]}
1
+ {"version":3,"file":"add-declaration-to-root-module.js","sourceRoot":"","sources":["add-declaration-to-root-module.ts"],"names":[],"mappings":";;AAKA,gEAMC;AAXD,yCAA8C;AAC9C,kEAA0E;AAE1E,+CAA+C;AAE/C,SAAgB,0BAA0B,CAAC,IAAU,EAAE,UAAkB,EAAE,SAAiB;IAC3F,IACC,IAAI,GAAK,uBAAuB,EAChC,MAAM,GAAG,IAAA,mBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEpC,IAAA,kCAAsB,EAAC,MAAM,EAAE,IAAA,gBAAS,EAAC,IAAI,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import {getSourceFile} from '../../utils/ast';\nimport {addDeclarationToModule} from '../../utils/devkit-utils/ast-utils';\nimport {Tree} from '@angular-devkit/schematics';\nimport {normalize} from '@angular-devkit/core';\n\nexport function addDeclarationToRootModule(host: Tree, moduleName: string, importSrc: string) {\n\tlet\n\t\tpath = `src/app/app.module.ts`,\n\t\tsource = getSourceFile(host, path);\n\t\n\taddDeclarationToModule(source, normalize(path), moduleName, importSrc);\n}\n"]}
@@ -1,12 +1,12 @@
1
- import {getSourceFile} from '../../utils/ast';
2
- import {addDeclarationToModule} from '../../utils/devkit-utils/ast-utils';
3
- import {Tree} from '@angular-devkit/schematics';
4
- import {normalize} from '@angular-devkit/core';
5
-
6
- export function addDeclarationToRootModule(host: Tree, moduleName: string, importSrc: string) {
7
- let
8
- path = `src/app/app.module.ts`,
9
- source = getSourceFile(host, path);
10
-
11
- addDeclarationToModule(source, normalize(path), moduleName, importSrc);
12
- }
1
+ import {getSourceFile} from '../../utils/ast';
2
+ import {addDeclarationToModule} from '../../utils/devkit-utils/ast-utils';
3
+ import {Tree} from '@angular-devkit/schematics';
4
+ import {normalize} from '@angular-devkit/core';
5
+
6
+ export function addDeclarationToRootModule(host: Tree, moduleName: string, importSrc: string) {
7
+ let
8
+ path = `src/app/app.module.ts`,
9
+ source = getSourceFile(host, path);
10
+
11
+ addDeclarationToModule(source, normalize(path), moduleName, importSrc);
12
+ }
@@ -1,14 +1,14 @@
1
- import {Routes, RouterModule} from '@angular/router';
2
- import { NgModule } from "@angular/core";
3
- import { CommonModule } from "@angular/common";
4
-
5
- export const routes: Routes = [
6
-
7
- ];
8
-
9
-
10
- @NgModule({
11
- imports: [CommonModule,RouterModule.forChild(routes)],
12
- exports: [RouterModule]
13
- })
14
- export class MagicRoutingModule { }
1
+ import {Routes, RouterModule} from '@angular/router';
2
+ import { NgModule } from "@angular/core";
3
+ import { CommonModule } from "@angular/common";
4
+
5
+ export const routes: Routes = [
6
+
7
+ ];
8
+
9
+
10
+ @NgModule({
11
+ imports: [CommonModule,RouterModule.forChild(routes)],
12
+ exports: [RouterModule]
13
+ })
14
+ export class MagicRoutingModule { }
@@ -1,3 +1,3 @@
1
- import { Rule } from "@angular-devkit/schematics";
2
- import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
3
- export declare function mgAddTasks(options: MagicOptionScheme): Rule;
1
+ import { Rule } from "@angular-devkit/schematics";
2
+ import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
3
+ export declare function mgAddTasks(options: MagicOptionScheme): Rule;
@@ -1,31 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mgAddTasks = void 0;
4
- const tasks_1 = require("@angular-devkit/schematics/tasks");
5
- const env_1 = require("../magic-utils/env");
6
- function mgAddTasks(options) {
7
- return (host, context) => {
8
- console.log(" [V - add install dependencies !] options.cliVersion=" + options.cliVersion);
9
- env_1.devDependencies.push(new env_1.Idependencies("@magic-xpa/cli", options.cliVersion));
10
- // install the devDependencies
11
- const devInstallTask = context.addTask(new tasks_1.RunSchematicTask('mg-install', {
12
- skipInstall: false,
13
- skipPackageJson: false,
14
- dependencies: [],
15
- devDependencies: env_1.devDependencies
16
- }));
17
- console.log(" [V - add install dependencies !] options.angularVersion=" + options.angularVersion);
18
- env_1.dependencies.push(new env_1.Idependencies("@magic-xpa/angular", options.angularVersion));
19
- // install the dependencies
20
- const packagesInstallTask = context.addTask(new tasks_1.RunSchematicTask('mg-install', {
21
- skipInstall: options.skipInstall,
22
- skipPackageJson: options.skipPackageJson,
23
- dependencies: env_1.dependencies,
24
- devDependencies: []
25
- }), [devInstallTask]);
26
- const deleteFilesTask = context.addTask(new tasks_1.RunSchematicTask('delete-files', options), [devInstallTask, packagesInstallTask]);
27
- const ngAddTask = context.addTask(new tasks_1.RunSchematicTask('mg-add', options), [devInstallTask, packagesInstallTask, deleteFilesTask]);
28
- };
29
- }
30
- exports.mgAddTasks = mgAddTasks;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mgAddTasks = mgAddTasks;
4
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
5
+ const env_1 = require("../magic-utils/env");
6
+ function mgAddTasks(options) {
7
+ return (host, context) => {
8
+ console.log(" [V - add install dependencies !] options.cliVersion=" + options.cliVersion);
9
+ env_1.devDependencies.push(new env_1.Idependencies("@magic-xpa/cli", options.cliVersion));
10
+ // install the devDependencies
11
+ const devInstallTask = context.addTask(new tasks_1.RunSchematicTask('mg-install', {
12
+ skipInstall: false,
13
+ skipPackageJson: false,
14
+ dependencies: [],
15
+ devDependencies: env_1.devDependencies
16
+ }));
17
+ console.log(" [V - add install dependencies !] options.angularVersion=" + options.angularVersion);
18
+ env_1.dependencies.push(new env_1.Idependencies("@magic-xpa/angular", options.angularVersion));
19
+ // install the dependencies
20
+ const packagesInstallTask = context.addTask(new tasks_1.RunSchematicTask('mg-install', {
21
+ skipInstall: options.skipInstall,
22
+ skipPackageJson: options.skipPackageJson,
23
+ dependencies: env_1.dependencies,
24
+ devDependencies: []
25
+ }), [devInstallTask]);
26
+ const deleteFilesTask = context.addTask(new tasks_1.RunSchematicTask('delete-files', options), [devInstallTask, packagesInstallTask]);
27
+ const ngAddTask = context.addTask(new tasks_1.RunSchematicTask('mg-add', options), [devInstallTask, packagesInstallTask, deleteFilesTask]);
28
+ };
29
+ }
31
30
  //# sourceMappingURL=index.js.map