@magic-xpa/cli 4.1000.0 → 4.1100.0-dev000.0

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 (307) 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 -80
  39. package/src/schematics/magic-utils/rules/build-view.rule.js.map +1 -1
  40. package/src/schematics/magic-utils/rules/build-view.rule.ts +4 -0
  41. package/src/schematics/magic-utils/rules/component-list.rule.d.ts +3 -3
  42. package/src/schematics/magic-utils/rules/component-list.rule.js +316 -317
  43. package/src/schematics/magic-utils/rules/component-list.rule.js.map +1 -1
  44. package/src/schematics/magic-utils/rules/generate.rule.d.ts +5 -5
  45. package/src/schematics/magic-utils/rules/generate.rule.js +53 -54
  46. package/src/schematics/magic-utils/rules/generate.rule.js.map +1 -1
  47. package/src/schematics/magic-utils/rules/generate.rule.ts +61 -61
  48. package/src/schematics/magic-utils/rules/init-add-modules.rule.d.ts +12 -12
  49. package/src/schematics/magic-utils/rules/init-add-modules.rule.js +295 -296
  50. package/src/schematics/magic-utils/rules/init-add-modules.rule.js.map +1 -1
  51. package/src/schematics/magic-utils/rules/init-add-modules.rule.ts +360 -360
  52. package/src/schematics/magic-utils/rules/init-gen-components.rule.d.ts +4 -4
  53. package/src/schematics/magic-utils/rules/init-gen-components.rule.js +65 -66
  54. package/src/schematics/magic-utils/rules/init-gen-components.rule.js.map +1 -1
  55. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.d.ts +3 -3
  56. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js +17 -18
  57. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js.map +1 -1
  58. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.ts +19 -19
  59. package/src/schematics/magic-utils/rules/load-views-gen.rule.d.ts +3 -3
  60. package/src/schematics/magic-utils/rules/load-views-gen.rule.js +28 -29
  61. package/src/schematics/magic-utils/rules/load-views-gen.rule.js.map +1 -1
  62. package/src/schematics/magic-utils/rules/magic-option.scheme.d.ts +22 -21
  63. package/src/schematics/magic-utils/rules/magic-option.scheme.js +2 -2
  64. package/src/schematics/magic-utils/rules/magic-option.scheme.js.map +1 -1
  65. package/src/schematics/magic-utils/rules/magic-option.scheme.ts +24 -23
  66. package/src/schematics/magic-utils/utils.d.ts +12 -12
  67. package/src/schematics/magic-utils/utils.js +116 -117
  68. package/src/schematics/magic-utils/utils.js.map +1 -1
  69. package/src/schematics/magic-utils/utils.ts +134 -134
  70. package/src/schematics/mg-Install-prerequisites/index.d.ts +3 -3
  71. package/src/schematics/mg-Install-prerequisites/index.js +24 -25
  72. package/src/schematics/mg-Install-prerequisites/index.js.map +1 -1
  73. package/src/schematics/mg-Install-prerequisites/index.ts +30 -30
  74. package/src/schematics/mg-Install-prerequisites/schema.json +14 -14
  75. package/src/schematics/mg-add/files/src/app/app.component.html +17 -17
  76. package/src/schematics/mg-add/files/src/app/app.routes.ts +14 -14
  77. package/src/schematics/mg-add/files/src/app/magic/component-list.g.ts +9 -9
  78. package/src/schematics/mg-add/files/src/app/magic/lazy-loader.service.ts +2 -1
  79. package/src/schematics/mg-add/files/src/app/magic/magic.gen.lib.module.ts +19 -19
  80. package/src/schematics/mg-add/files/src/magic-styles.css +131 -131
  81. package/src/schematics/mg-add/index.d.ts +3 -3
  82. package/src/schematics/mg-add/index.js +150 -151
  83. package/src/schematics/mg-add/index.js.map +1 -1
  84. package/src/schematics/mg-add/schema.json +29 -29
  85. package/src/schematics/mg-add/utils/add-declaration-to-root-module.d.ts +2 -2
  86. package/src/schematics/mg-add/utils/add-declaration-to-root-module.js +10 -11
  87. package/src/schematics/mg-add/utils/add-declaration-to-root-module.js.map +1 -1
  88. package/src/schematics/mg-add/utils/add-declaration-to-root-module.ts +12 -12
  89. package/src/schematics/mg-add/webModule/app.routes.ts +14 -14
  90. package/src/schematics/mg-add-tasks/index.d.ts +3 -3
  91. package/src/schematics/mg-add-tasks/index.js +29 -30
  92. package/src/schematics/mg-add-tasks/index.js.map +1 -1
  93. package/src/schematics/mg-add-tasks/index.ts +53 -53
  94. package/src/schematics/mg-add-tasks/schema.json +41 -41
  95. package/src/schematics/mg-delete-files/index.d.ts +3 -3
  96. package/src/schematics/mg-delete-files/index.js +12 -13
  97. package/src/schematics/mg-delete-files/index.js.map +1 -1
  98. package/src/schematics/mg-delete-files/index.ts +12 -12
  99. package/src/schematics/mg-delete-files/schema.json +14 -14
  100. package/src/schematics/mg-gen-module/index.d.ts +3 -3
  101. package/src/schematics/mg-gen-module/index.js +14 -15
  102. package/src/schematics/mg-gen-module/index.js.map +1 -1
  103. package/src/schematics/mg-gen-module/index.ts +14 -14
  104. package/src/schematics/mg-gen-module/schema.json +24 -24
  105. package/src/schematics/mg-generate/index.d.ts +3 -3
  106. package/src/schematics/mg-generate/index.js +12 -13
  107. package/src/schematics/mg-generate/index.js.map +1 -1
  108. package/src/schematics/mg-generate/index.ts +12 -12
  109. package/src/schematics/mg-generate/schema.json +34 -34
  110. package/src/schematics/mg-generate-component/index.d.ts +3 -3
  111. package/src/schematics/mg-generate-component/index.js +34 -35
  112. package/src/schematics/mg-generate-component/index.js.map +1 -1
  113. package/src/schematics/mg-generate-component/schema.json +6 -0
  114. package/src/schematics/mg-install/index.d.ts +3 -3
  115. package/src/schematics/mg-install/index.js +29 -30
  116. package/src/schematics/mg-install/index.js.map +1 -1
  117. package/src/schematics/mg-install/index.ts +37 -37
  118. package/src/schematics/mg-install/schema.json +24 -24
  119. package/src/schematics/mg-routes/index.d.ts +6 -6
  120. package/src/schematics/mg-routes/index.js +62 -63
  121. package/src/schematics/mg-routes/index.js.map +1 -1
  122. package/src/schematics/mg-routes/schema.json +14 -14
  123. package/src/schematics/mg-single-control/index.d.ts +3 -3
  124. package/src/schematics/mg-single-control/index.js +28 -29
  125. package/src/schematics/mg-single-control/index.js.map +1 -1
  126. package/src/schematics/mg-single-control/schema.json +24 -24
  127. package/src/schematics/utils/ast.d.ts +21 -21
  128. package/src/schematics/utils/ast.js +90 -91
  129. package/src/schematics/utils/ast.js.map +1 -1
  130. package/src/schematics/utils/ast.ts +103 -103
  131. package/src/schematics/utils/devkit-utils/README.md +1 -1
  132. package/src/schematics/utils/devkit-utils/ast-utils.d.ts +87 -87
  133. package/src/schematics/utils/devkit-utils/ast-utils.js +489 -490
  134. package/src/schematics/utils/devkit-utils/ast-utils.js.map +1 -1
  135. package/src/schematics/utils/devkit-utils/ast-utils.ts +570 -570
  136. package/src/schematics/utils/devkit-utils/ast-utils_old.d.ts +68 -68
  137. package/src/schematics/utils/devkit-utils/ast-utils_old.js +419 -420
  138. package/src/schematics/utils/devkit-utils/ast-utils_old.js.map +1 -1
  139. package/src/schematics/utils/devkit-utils/ast-utils_old.ts +478 -478
  140. package/src/schematics/utils/devkit-utils/change.d.ts +66 -66
  141. package/src/schematics/utils/devkit-utils/change.js +94 -94
  142. package/src/schematics/utils/devkit-utils/change.js.map +1 -1
  143. package/src/schematics/utils/devkit-utils/change.ts +127 -127
  144. package/src/schematics/utils/devkit-utils/component.d.ts +2 -2
  145. package/src/schematics/utils/devkit-utils/component.js +96 -97
  146. package/src/schematics/utils/devkit-utils/component.js.map +1 -1
  147. package/src/schematics/utils/devkit-utils/component.ts +136 -136
  148. package/src/schematics/utils/devkit-utils/config.d.ts +78 -78
  149. package/src/schematics/utils/devkit-utils/config.js +52 -52
  150. package/src/schematics/utils/devkit-utils/config.js.map +1 -1
  151. package/src/schematics/utils/devkit-utils/config.ts +120 -120
  152. package/src/schematics/utils/devkit-utils/find-module.d.ts +28 -28
  153. package/src/schematics/utils/devkit-utils/find-module.js +92 -93
  154. package/src/schematics/utils/devkit-utils/find-module.js.map +1 -1
  155. package/src/schematics/utils/devkit-utils/find-module.ts +108 -108
  156. package/src/schematics/utils/devkit-utils/ng-ast-utils.d.ts +5 -5
  157. package/src/schematics/utils/devkit-utils/ng-ast-utils.js +73 -74
  158. package/src/schematics/utils/devkit-utils/ng-ast-utils.js.map +1 -1
  159. package/src/schematics/utils/devkit-utils/ng-ast-utils.ts +84 -84
  160. package/src/schematics/utils/devkit-utils/parse-name.d.ts +13 -13
  161. package/src/schematics/utils/devkit-utils/parse-name.js +19 -20
  162. package/src/schematics/utils/devkit-utils/parse-name.js.map +1 -1
  163. package/src/schematics/utils/devkit-utils/parse-name.ts +24 -24
  164. package/src/schematics/utils/devkit-utils/route-utils.d.ts +20 -20
  165. package/src/schematics/utils/devkit-utils/route-utils.js +133 -134
  166. package/src/schematics/utils/devkit-utils/route-utils.js.map +1 -1
  167. package/src/schematics/utils/devkit-utils/route-utils.ts +180 -180
  168. package/src/schematics/utils/devkit-utils/validation.d.ts +1 -1
  169. package/src/schematics/utils/devkit-utils/validation.js +18 -19
  170. package/src/schematics/utils/devkit-utils/validation.js.map +1 -1
  171. package/src/schematics/utils/devkit-utils/validation.ts +16 -16
  172. package/src/schematics/utils/html.d.ts +18 -18
  173. package/src/schematics/utils/html.js +59 -60
  174. package/src/schematics/utils/html.js.map +1 -1
  175. package/src/schematics/utils/html.ts +63 -63
  176. package/src/schematics/utils/lib-versions.d.ts +3 -3
  177. package/src/schematics/utils/lib-versions.js +6 -6
  178. package/src/schematics/utils/lib-versions.js.map +1 -1
  179. package/src/schematics/utils/lib-versions.ts +3 -3
  180. package/src/schematics/utils/package.d.ts +5 -5
  181. package/src/schematics/utils/package.js +20 -21
  182. package/src/schematics/utils/package.js.map +1 -1
  183. package/src/schematics/utils/package.ts +22 -22
  184. package/src/schematics/utils/testing.d.ts +5 -5
  185. package/src/schematics/utils/testing.js +26 -27
  186. package/src/schematics/utils/testing.js.map +1 -1
  187. package/src/schematics/utils/testing.ts +25 -25
  188. package/src/types/enums/Enums.d.ts +1646 -1646
  189. package/src/types/enums/Enums.js +1862 -1862
  190. package/src/types/enums/Enums.js.map +1 -1
  191. package/src/types/enums/Enums.ts +2063 -2063
  192. package/src/types/enums/generated-file-types.enum.d.ts +6 -6
  193. package/src/types/enums/generated-file-types.enum.js +10 -10
  194. package/src/types/enums/generated-file-types.enum.js.map +1 -1
  195. package/src/types/enums/generated-file-types.enum.ts +6 -6
  196. package/src/types/enums/horizontal-alignments.enum.d.ts +5 -5
  197. package/src/types/enums/horizontal-alignments.enum.js +9 -9
  198. package/src/types/enums/horizontal-alignments.enum.js.map +1 -1
  199. package/src/types/enums/horizontal-alignments.enum.ts +6 -6
  200. package/src/types/enums/themes.enum.d.ts +6 -6
  201. package/src/types/enums/themes.enum.js +10 -10
  202. package/src/types/enums/themes.enum.js.map +1 -1
  203. package/src/types/enums/themes.enum.ts +6 -6
  204. package/src/types/index.d.ts +7 -7
  205. package/src/types/index.js +10 -10
  206. package/src/types/index.js.map +1 -1
  207. package/src/types/index.ts +8 -8
  208. package/src/types/interfaces/app.d.ts +53 -53
  209. package/src/types/interfaces/app.js +9 -9
  210. package/src/types/interfaces/app.js.map +1 -1
  211. package/src/types/interfaces/app.ts +89 -89
  212. package/src/types/interfaces/control.d.ts +82 -82
  213. package/src/types/interfaces/control.js +2 -2
  214. package/src/types/interfaces/control.js.map +1 -1
  215. package/src/types/interfaces/control.ts +106 -106
  216. package/src/types/interfaces/env.interface.d.ts +19 -19
  217. package/src/types/interfaces/env.interface.js +10 -10
  218. package/src/types/interfaces/template.config.d.ts +8 -8
  219. package/src/types/interfaces/template.config.js +2 -2
  220. package/src/types/interfaces/template.config.js.map +1 -1
  221. package/src/types/interfaces/template.config.ts +11 -11
  222. package/templates/angular/src/app/app.component.html.ejs +17 -17
  223. package/templates/angular/src/app/cmp-array.ejs +3 -3
  224. package/templates/angular/src/app/cmp-hash.ejs +3 -3
  225. package/templates/angular/src/app/component-list.g.ts +21 -21
  226. package/templates/angular/src/app.component.ts +14 -14
  227. package/templates/angular/src/app.module.ts +70 -70
  228. package/templates/angular/src/app.routes.ts +73 -73
  229. package/templates/angular/src/styles/app.css +5 -5
  230. package/templates/attributes/button_attributes.ejs +2 -2
  231. package/templates/attributes/common/base/class.ejs +6 -6
  232. package/templates/attributes/common/base/control_type.ejs +53 -53
  233. package/templates/attributes/common/base/enabled.ejs +9 -9
  234. package/templates/attributes/common/base/imageFileName.ejs +3 -3
  235. package/templates/attributes/common/base/no_control_class.ejs +3 -3
  236. package/templates/attributes/common/base/rtol.ejs +3 -3
  237. package/templates/attributes/common/base/tabindex.ejs +11 -11
  238. package/templates/attributes/common/base/testingId.ejs +8 -8
  239. package/templates/attributes/common/base/tooltip.ejs +7 -7
  240. package/templates/attributes/common/base/visible.ejs +6 -6
  241. package/templates/attributes/common/base/wallpaper.ejs +3 -3
  242. package/templates/attributes/common/base_attributes.ejs +10 -10
  243. package/templates/attributes/common/container_attributes.ejs +6 -6
  244. package/templates/attributes/common/control_attributes.ejs +3 -3
  245. package/templates/attributes/common/format.ejs +5 -5
  246. package/templates/attributes/common/input/hint.ejs +13 -13
  247. package/templates/attributes/common/input/multiline_edit.ejs +3 -3
  248. package/templates/attributes/common/input/must_input.ejs +8 -8
  249. package/templates/attributes/common/input/password_edit.ejs +7 -7
  250. package/templates/attributes/common/input/row_editing_input_attributes.ejs +6 -6
  251. package/templates/attributes/common/input/validation.ejs +5 -5
  252. package/templates/attributes/common/input_attributes.ejs +4 -4
  253. package/templates/attributes/common/no_control_base_attributes.ejs +4 -4
  254. package/templates/attributes/common/row_editing_button_attributes.ejs +10 -10
  255. package/templates/component/view.component.html +14 -14
  256. package/templates/component/view.component.ts +123 -122
  257. package/templates/themes/basicHTML/Code/theme.module.ts +10 -10
  258. package/templates/themes/basicHTML/checkbox.ejs +1 -1
  259. package/templates/themes/basicHTML/combobox.ejs +37 -37
  260. package/templates/themes/basicHTML/edit.ejs +169 -168
  261. package/templates/themes/basicHTML/form.ejs +4 -4
  262. package/templates/themes/basicHTML/group.ejs +4 -4
  263. package/templates/themes/basicHTML/image.ejs +6 -6
  264. package/templates/themes/basicHTML/label.ejs +11 -11
  265. package/templates/themes/basicHTML/listbox.ejs +21 -21
  266. package/templates/themes/basicHTML/push-button.ejs +28 -28
  267. package/templates/themes/basicHTML/radio.ejs +20 -20
  268. package/templates/themes/basicHTML/subform.ejs +6 -6
  269. package/templates/themes/basicHTML/tab.ejs +31 -31
  270. package/templates/themes/basicHTML/tabpage.ejs +5 -5
  271. package/templates/themes/basicHiddenHTML/Code/theme.module.ts +10 -10
  272. package/templates/themes/basicHiddenHTML/combobox.ejs +5 -5
  273. package/templates/themes/basicHiddenHTML/form.ejs +3 -3
  274. package/templates/themes/basicHiddenHTML/group.ejs +2 -2
  275. package/templates/themes/basicHiddenHTML/image.ejs +4 -4
  276. package/templates/themes/basicHiddenHTML/label.ejs +1 -1
  277. package/templates/themes/basicHiddenHTML/listbox.ejs +8 -8
  278. package/templates/themes/basicHiddenHTML/push-button.ejs +26 -26
  279. package/templates/themes/basicHiddenHTML/radio.ejs +17 -17
  280. package/templates/themes/basicHiddenHTML/tab.ejs +13 -13
  281. package/templates/themes/basicHiddenHTML/table.ejs +18 -18
  282. package/templates/themes/basicHiddenHTML/tabpage.ejs +2 -2
  283. package/templates/themes/container.ejs +26 -26
  284. package/templates/themes/control.ejs +52 -52
  285. package/templates/themes/editTypeSelector.ejs +1 -1
  286. package/templates/themes/material/Code/theme.module.ts +68 -68
  287. package/templates/themes/material/base_attributes_date.ejs +8 -8
  288. package/templates/themes/material/checkbox.ejs +1 -1
  289. package/templates/themes/material/combobox.ejs +43 -43
  290. package/templates/themes/material/edit.ejs +204 -204
  291. package/templates/themes/material/group.ejs +3 -3
  292. package/templates/themes/material/listbox.ejs +22 -23
  293. package/templates/themes/material/push-button.ejs +28 -28
  294. package/templates/themes/material/radio.ejs +22 -22
  295. package/templates/themes/material/subform.ejs +8 -8
  296. package/templates/themes/material/tab.ejs +19 -19
  297. package/templates/themes/router_outlet.ejs +5 -5
  298. package/templates/themes/table/HTMLTable/columnHeader.ejs +3 -1
  299. package/templates/themes/table/HTMLTable/table.ejs +37 -37
  300. package/templates/themes/table/grid/additionalComponentCode.ejs +26 -26
  301. package/templates/themes/table/grid/additionalIncludes.ejs +1 -1
  302. package/templates/themes/table/grid/column.ejs +3 -1
  303. package/templates/themes/table/grid/table.ejs +37 -37
  304. package/templates/themes/table/repeatable/column.ejs +11 -11
  305. package/templates/themes/table/repeatable/table.ejs +28 -28
  306. package/templates/themes/tableTypeSelector.ejs +21 -21
  307. package/tsconfig.json +36 -36
@@ -1,98 +1,97 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildComponent = void 0;
4
- const core_1 = require("@angular-devkit/core");
5
- const schematics_1 = require("@angular-devkit/schematics");
6
- const ts = require("typescript");
7
- const ast_utils_1 = require("./ast-utils");
8
- const change_1 = require("./change");
9
- const find_module_1 = require("./find-module");
10
- const config_1 = require("./config");
11
- const parse_name_1 = require("./parse-name");
12
- const validation_1 = require("./validation");
13
- function addDeclarationToNgModule(options) {
14
- return (host) => {
15
- if (options.skipImport || !options.module) {
16
- return host;
17
- }
18
- const modulePath = options.module;
19
- const text = host.read(modulePath);
20
- if (text === null) {
21
- throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
22
- }
23
- const sourceText = text.toString('utf-8');
24
- const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
25
- const componentPath = `/${options.path}/`
26
- + (options.flat ? '' : core_1.strings.dasherize(options.name) + '/')
27
- + core_1.strings.dasherize(options.name)
28
- + '.component';
29
- const relativePath = (0, find_module_1.buildRelativePath)(modulePath, componentPath);
30
- const classifiedName = core_1.strings.classify(`${options.name}Component`);
31
- const declarationChanges = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, classifiedName, relativePath);
32
- const declarationRecorder = host.beginUpdate(modulePath);
33
- for (const change of declarationChanges) {
34
- if (change instanceof change_1.InsertChange) {
35
- declarationRecorder.insertLeft(change.pos, change.toAdd);
36
- }
37
- }
38
- host.commitUpdate(declarationRecorder);
39
- if (options.export) {
40
- // Need to refresh the AST because we overwrote the file in the host.
41
- const text = host.read(modulePath);
42
- if (text === null) {
43
- throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
44
- }
45
- const sourceText = text.toString('utf-8');
46
- const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
47
- const exportRecorder = host.beginUpdate(modulePath);
48
- const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, core_1.strings.classify(`${options.name}Component`), relativePath);
49
- for (const change of exportChanges) {
50
- if (change instanceof change_1.InsertChange) {
51
- exportRecorder.insertLeft(change.pos, change.toAdd);
52
- }
53
- }
54
- host.commitUpdate(exportRecorder);
55
- }
56
- return host;
57
- };
58
- }
59
- function buildSelector(options) {
60
- let selector = core_1.strings.dasherize(options.name);
61
- if (options.prefix) {
62
- selector = `${options.prefix}-${selector}`;
63
- }
64
- return selector;
65
- }
66
- function buildComponent(options) {
67
- return (host, context) => {
68
- const workspace = (0, config_1.getWorkspace)(host);
69
- if (!options.project) {
70
- options.project = Object.keys(workspace.projects)[0];
71
- }
72
- const project = workspace.projects[options.project];
73
- if (options.path === undefined) {
74
- options.path = `/${project.root}/src/app`;
75
- }
76
- options.selector = options.selector || buildSelector(options);
77
- options.module = (0, find_module_1.findModuleFromOptions)(host, options);
78
- const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
79
- options.name = parsedPath.name;
80
- options.path = parsedPath.path;
81
- (0, validation_1.validateName)(options.name);
82
- const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
83
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
84
- options.inlineStyle ? (0, schematics_1.filter)(path => !path.endsWith('.__styleext__')) : (0, schematics_1.noop)(),
85
- options.inlineTemplate ? (0, schematics_1.filter)(path => !path.endsWith('.html')) : (0, schematics_1.noop)(),
86
- (0, schematics_1.template)(Object.assign(Object.assign(Object.assign({}, core_1.strings), { 'if-flat': (s) => options.flat ? '' : s }), options)),
87
- (0, schematics_1.move)(null, parsedPath.path),
88
- ]);
89
- return (0, schematics_1.chain)([
90
- (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
91
- addDeclarationToNgModule(options),
92
- (0, schematics_1.mergeWith)(templateSource),
93
- ])),
94
- ])(host, context);
95
- };
96
- }
97
- exports.buildComponent = buildComponent;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildComponent = buildComponent;
4
+ const core_1 = require("@angular-devkit/core");
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ const ts = require("typescript");
7
+ const ast_utils_1 = require("./ast-utils");
8
+ const change_1 = require("./change");
9
+ const find_module_1 = require("./find-module");
10
+ const config_1 = require("./config");
11
+ const parse_name_1 = require("./parse-name");
12
+ const validation_1 = require("./validation");
13
+ function addDeclarationToNgModule(options) {
14
+ return (host) => {
15
+ if (options.skipImport || !options.module) {
16
+ return host;
17
+ }
18
+ const modulePath = options.module;
19
+ const text = host.read(modulePath);
20
+ if (text === null) {
21
+ throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
22
+ }
23
+ const sourceText = text.toString('utf-8');
24
+ const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
25
+ const componentPath = `/${options.path}/`
26
+ + (options.flat ? '' : core_1.strings.dasherize(options.name) + '/')
27
+ + core_1.strings.dasherize(options.name)
28
+ + '.component';
29
+ const relativePath = (0, find_module_1.buildRelativePath)(modulePath, componentPath);
30
+ const classifiedName = core_1.strings.classify(`${options.name}Component`);
31
+ const declarationChanges = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, classifiedName, relativePath);
32
+ const declarationRecorder = host.beginUpdate(modulePath);
33
+ for (const change of declarationChanges) {
34
+ if (change instanceof change_1.InsertChange) {
35
+ declarationRecorder.insertLeft(change.pos, change.toAdd);
36
+ }
37
+ }
38
+ host.commitUpdate(declarationRecorder);
39
+ if (options.export) {
40
+ // Need to refresh the AST because we overwrote the file in the host.
41
+ const text = host.read(modulePath);
42
+ if (text === null) {
43
+ throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
44
+ }
45
+ const sourceText = text.toString('utf-8');
46
+ const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
47
+ const exportRecorder = host.beginUpdate(modulePath);
48
+ const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, core_1.strings.classify(`${options.name}Component`), relativePath);
49
+ for (const change of exportChanges) {
50
+ if (change instanceof change_1.InsertChange) {
51
+ exportRecorder.insertLeft(change.pos, change.toAdd);
52
+ }
53
+ }
54
+ host.commitUpdate(exportRecorder);
55
+ }
56
+ return host;
57
+ };
58
+ }
59
+ function buildSelector(options) {
60
+ let selector = core_1.strings.dasherize(options.name);
61
+ if (options.prefix) {
62
+ selector = `${options.prefix}-${selector}`;
63
+ }
64
+ return selector;
65
+ }
66
+ function buildComponent(options) {
67
+ return (host, context) => {
68
+ const workspace = (0, config_1.getWorkspace)(host);
69
+ if (!options.project) {
70
+ options.project = Object.keys(workspace.projects)[0];
71
+ }
72
+ const project = workspace.projects[options.project];
73
+ if (options.path === undefined) {
74
+ options.path = `/${project.root}/src/app`;
75
+ }
76
+ options.selector = options.selector || buildSelector(options);
77
+ options.module = (0, find_module_1.findModuleFromOptions)(host, options);
78
+ const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
79
+ options.name = parsedPath.name;
80
+ options.path = parsedPath.path;
81
+ (0, validation_1.validateName)(options.name);
82
+ const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
83
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
84
+ options.inlineStyle ? (0, schematics_1.filter)(path => !path.endsWith('.__styleext__')) : (0, schematics_1.noop)(),
85
+ options.inlineTemplate ? (0, schematics_1.filter)(path => !path.endsWith('.html')) : (0, schematics_1.noop)(),
86
+ (0, schematics_1.template)(Object.assign(Object.assign(Object.assign({}, core_1.strings), { 'if-flat': (s) => options.flat ? '' : s }), options)),
87
+ (0, schematics_1.move)(null, parsedPath.path),
88
+ ]);
89
+ return (0, schematics_1.chain)([
90
+ (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
91
+ addDeclarationToNgModule(options),
92
+ (0, schematics_1.mergeWith)(templateSource),
93
+ ])),
94
+ ])(host, context);
95
+ };
96
+ }
98
97
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["component.ts"],"names":[],"mappings":";;;AAAA,+CAAwD;AACxD,2DAcoC;AACpC,iCAAiC;AACjC,2CAAsE;AACtE,qCAAsC;AACtC,+CAAuE;AACvE,qCAAsC;AACtC,6CAAuC;AACvC,6CAA0C;AAE1C,SAAS,wBAAwB,CAAC,OAAY;IAC5C,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACzC,OAAO,IAAI,CAAC;SACb;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,MAAM,IAAI,gCAAmB,CAAC,QAAQ,UAAU,kBAAkB,CAAC,CAAC;SACrE;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAEzF,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,IAAI,GAAG;cACjB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;cAC3D,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;cAC/B,YAAY,CAAC;QACrC,MAAM,YAAY,GAAG,IAAA,+BAAiB,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QAClE,MAAM,cAAc,GAAG,cAAO,CAA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ings} from '@angular-devkit/core';\nimport {\n apply,\n branchAndMerge,\n chain,\n filter,\n mergeWith,\n move,\n noop,\n Rule,\n SchematicContext,\n SchematicsException,\n template,\n Tree,\n url,\n} from '@angular-devkit/schematics';\nimport * as ts from 'typescript';\nimport {addDeclarationToModule, addExportToModule} from './ast-utils';\nimport {InsertChange} from './change';\nimport {buildRelativePath, findModuleFromOptions} from './find-module';\nimport {getWorkspace} from './config';\nimport {parseName} from './parse-name';\nimport {validateName} from './validation';\n\nfunction addDeclarationToNgModule(options: any): Rule {\n return (host: Tree) => {\n if (options.skipImport || !options.module) {\n return host;\n }\n\n const modulePath = options.module;\n const text = host.read(modulePath);\n if (text === null) {\n throw new SchematicsException(`File ${modulePath} does not exist.`);\n }\n const sourceText = text.toString('utf-8');\n const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);\n\n const componentPath = `/${options.path}/`\n + (options.flat ? '' : strings.dasherize(options.name) + '/')\n + strings.dasherize(options.name)\n + '.component';\n const relativePath = buildRelativePath(modulePath, componentPath);\n const classifiedName = strings.classify(`${options.name}Component`);\n const declarationChanges = addDeclarationToModule(source,\n modulePath,\n classifiedName,\n relativePath);\n\n const declarationRecorder = host.beginUpdate(modulePath);\n for (const change of declarationChanges) {\n if (change instanceof InsertChange) {\n declarationRecorder.insertLeft(change.pos, change.toAdd);\n }\n }\n host.commitUpdate(declarationRecorder);\n\n if (options.export) {\n // Need to refresh the AST because we overwrote the file in the host.\n const text = host.read(modulePath);\n if (text === null) {\n throw new SchematicsException(`File ${modulePath} does not exist.`);\n }\n const sourceText = text.toString('utf-8');\n const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);\n\n const exportRecorder = host.beginUpdate(modulePath);\n const exportChanges = addExportToModule(source, modulePath,\n strings.classify(`${options.name}Component`),\n relativePath);\n\n for (const change of exportChanges) {\n if (change instanceof InsertChange) {\n exportRecorder.insertLeft(change.pos, change.toAdd);\n }\n }\n host.commitUpdate(exportRecorder);\n }\n\n\n return host;\n };\n}\n\n\nfunction buildSelector(options: any) {\n let selector = strings.dasherize(options.name);\n if (options.prefix) {\n selector = `${options.prefix}-${selector}`;\n }\n\n return selector;\n}\n\n\nexport function buildComponent(options: any): Rule {\n return (host: Tree, context: SchematicContext) => {\n const workspace = getWorkspace(host);\n if (!options.project) {\n options.project = Object.keys(workspace.projects)[0];\n }\n const project = workspace.projects[options.project];\n\n if (options.path === undefined) {\n options.path = `/${project.root}/src/app`;\n }\n\n options.selector = options.selector || buildSelector(options);\n options.module = findModuleFromOptions(host, options);\n\n const parsedPath = parseName(options.path, options.name);\n options.name = parsedPath.name;\n options.path = parsedPath.path;\n\n validateName(options.name);\n\n const templateSource = apply(url('./files'), [\n options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),\n options.inlineStyle ? filter(path => !path.endsWith('.__styleext__')) : noop(),\n options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(),\n template({\n ...strings,\n 'if-flat': (s: string) => options.flat ? '' : s,\n ...options,\n }),\n move(null, parsedPath.path),\n ]);\n\n return chain([\n branchAndMerge(chain([\n addDeclarationToNgModule(options),\n mergeWith(templateSource),\n ])),\n ])(host, context);\n };\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["component.ts"],"names":[],"mappings":";;AA+FA,wCAwCC;AAvID,+CAAwD;AACxD,2DAcoC;AACpC,iCAAiC;AACjC,2CAAsE;AACtE,qCAAsC;AACtC,+CAAuE;AACvE,qCAAsC;AACtC,6CAAuC;AACvC,6CAA0C;AAE1C,SAAS,wBAAwB,CAAC,OAAY;IAC5C,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAA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AAM,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;YAC9E,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAA,mBAAM,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;YACzE,IAAA,qBAAQ,gDACH,cAAO,KACV,SAAS,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAC5C,OAAO,EACV;YACF,IAAA,iBAAI,EAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC;SAC5B,CAAC,CAAC;QAEH,OAAO,IAAA,kBAAK,EAAC;YACX,IAAA,2BAAc,EAAC,IAAA,kBAAK,EAAC;gBACnB,wBAAwB,CAAC,OAAO,CAAC;gBACjC,IAAA,sBAAS,EAAC,cAAc,CAAC;aAC1B,CAAC,CAAC;SACJ,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {normalize, strings} from '@angular-devkit/core';\r\nimport {\r\n apply,\r\n branchAndMerge,\r\n chain,\r\n filter,\r\n mergeWith,\r\n move,\r\n noop,\r\n Rule,\r\n SchematicContext,\r\n SchematicsException,\r\n template,\r\n Tree,\r\n url,\r\n} from '@angular-devkit/schematics';\r\nimport * as ts from 'typescript';\r\nimport {addDeclarationToModule, addExportToModule} from './ast-utils';\r\nimport {InsertChange} from './change';\r\nimport {buildRelativePath, findModuleFromOptions} from './find-module';\r\nimport {getWorkspace} from './config';\r\nimport {parseName} from './parse-name';\r\nimport {validateName} from './validation';\r\n\r\nfunction addDeclarationToNgModule(options: any): Rule {\r\n return (host: Tree) => {\r\n if (options.skipImport || !options.module) {\r\n return host;\r\n }\r\n\r\n const modulePath = options.module;\r\n const text = host.read(modulePath);\r\n if (text === null) {\r\n throw new SchematicsException(`File ${modulePath} does not exist.`);\r\n }\r\n const sourceText = text.toString('utf-8');\r\n const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);\r\n\r\n const componentPath = `/${options.path}/`\r\n + (options.flat ? '' : strings.dasherize(options.name) + '/')\r\n + strings.dasherize(options.name)\r\n + '.component';\r\n const relativePath = buildRelativePath(modulePath, componentPath);\r\n const classifiedName = strings.classify(`${options.name}Component`);\r\n const declarationChanges = addDeclarationToModule(source,\r\n modulePath,\r\n classifiedName,\r\n relativePath);\r\n\r\n const declarationRecorder = host.beginUpdate(modulePath);\r\n for (const change of declarationChanges) {\r\n if (change instanceof InsertChange) {\r\n declarationRecorder.insertLeft(change.pos, change.toAdd);\r\n }\r\n }\r\n host.commitUpdate(declarationRecorder);\r\n\r\n if (options.export) {\r\n // Need to refresh the AST because we overwrote the file in the host.\r\n const text = host.read(modulePath);\r\n if (text === null) {\r\n throw new SchematicsException(`File ${modulePath} does not exist.`);\r\n }\r\n const sourceText = text.toString('utf-8');\r\n const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);\r\n\r\n const exportRecorder = host.beginUpdate(modulePath);\r\n const exportChanges = addExportToModule(source, modulePath,\r\n strings.classify(`${options.name}Component`),\r\n relativePath);\r\n\r\n for (const change of exportChanges) {\r\n if (change instanceof InsertChange) {\r\n exportRecorder.insertLeft(change.pos, change.toAdd);\r\n }\r\n }\r\n host.commitUpdate(exportRecorder);\r\n }\r\n\r\n\r\n return host;\r\n };\r\n}\r\n\r\n\r\nfunction buildSelector(options: any) {\r\n let selector = strings.dasherize(options.name);\r\n if (options.prefix) {\r\n selector = `${options.prefix}-${selector}`;\r\n }\r\n\r\n return selector;\r\n}\r\n\r\n\r\nexport function buildComponent(options: any): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n const workspace = getWorkspace(host);\r\n if (!options.project) {\r\n options.project = Object.keys(workspace.projects)[0];\r\n }\r\n const project = workspace.projects[options.project];\r\n\r\n if (options.path === undefined) {\r\n options.path = `/${project.root}/src/app`;\r\n }\r\n\r\n options.selector = options.selector || buildSelector(options);\r\n options.module = findModuleFromOptions(host, options);\r\n\r\n const parsedPath = parseName(options.path, options.name);\r\n options.name = parsedPath.name;\r\n options.path = parsedPath.path;\r\n\r\n validateName(options.name);\r\n\r\n const templateSource = apply(url('./files'), [\r\n options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),\r\n options.inlineStyle ? filter(path => !path.endsWith('.__styleext__')) : noop(),\r\n options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(),\r\n template({\r\n ...strings,\r\n 'if-flat': (s: string) => options.flat ? '' : s,\r\n ...options,\r\n }),\r\n move(null, parsedPath.path),\r\n ]);\r\n\r\n return chain([\r\n branchAndMerge(chain([\r\n addDeclarationToNgModule(options),\r\n mergeWith(templateSource),\r\n ])),\r\n ])(host, context);\r\n };\r\n}\r\n"]}
@@ -1,136 +1,136 @@
1
- import {normalize, strings} from '@angular-devkit/core';
2
- import {
3
- apply,
4
- branchAndMerge,
5
- chain,
6
- filter,
7
- mergeWith,
8
- move,
9
- noop,
10
- Rule,
11
- SchematicContext,
12
- SchematicsException,
13
- template,
14
- Tree,
15
- url,
16
- } from '@angular-devkit/schematics';
17
- import * as ts from 'typescript';
18
- import {addDeclarationToModule, addExportToModule} from './ast-utils';
19
- import {InsertChange} from './change';
20
- import {buildRelativePath, findModuleFromOptions} from './find-module';
21
- import {getWorkspace} from './config';
22
- import {parseName} from './parse-name';
23
- import {validateName} from './validation';
24
-
25
- function addDeclarationToNgModule(options: any): Rule {
26
- return (host: Tree) => {
27
- if (options.skipImport || !options.module) {
28
- return host;
29
- }
30
-
31
- const modulePath = options.module;
32
- const text = host.read(modulePath);
33
- if (text === null) {
34
- throw new SchematicsException(`File ${modulePath} does not exist.`);
35
- }
36
- const sourceText = text.toString('utf-8');
37
- const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
38
-
39
- const componentPath = `/${options.path}/`
40
- + (options.flat ? '' : strings.dasherize(options.name) + '/')
41
- + strings.dasherize(options.name)
42
- + '.component';
43
- const relativePath = buildRelativePath(modulePath, componentPath);
44
- const classifiedName = strings.classify(`${options.name}Component`);
45
- const declarationChanges = addDeclarationToModule(source,
46
- modulePath,
47
- classifiedName,
48
- relativePath);
49
-
50
- const declarationRecorder = host.beginUpdate(modulePath);
51
- for (const change of declarationChanges) {
52
- if (change instanceof InsertChange) {
53
- declarationRecorder.insertLeft(change.pos, change.toAdd);
54
- }
55
- }
56
- host.commitUpdate(declarationRecorder);
57
-
58
- if (options.export) {
59
- // Need to refresh the AST because we overwrote the file in the host.
60
- const text = host.read(modulePath);
61
- if (text === null) {
62
- throw new SchematicsException(`File ${modulePath} does not exist.`);
63
- }
64
- const sourceText = text.toString('utf-8');
65
- const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
66
-
67
- const exportRecorder = host.beginUpdate(modulePath);
68
- const exportChanges = addExportToModule(source, modulePath,
69
- strings.classify(`${options.name}Component`),
70
- relativePath);
71
-
72
- for (const change of exportChanges) {
73
- if (change instanceof InsertChange) {
74
- exportRecorder.insertLeft(change.pos, change.toAdd);
75
- }
76
- }
77
- host.commitUpdate(exportRecorder);
78
- }
79
-
80
-
81
- return host;
82
- };
83
- }
84
-
85
-
86
- function buildSelector(options: any) {
87
- let selector = strings.dasherize(options.name);
88
- if (options.prefix) {
89
- selector = `${options.prefix}-${selector}`;
90
- }
91
-
92
- return selector;
93
- }
94
-
95
-
96
- export function buildComponent(options: any): Rule {
97
- return (host: Tree, context: SchematicContext) => {
98
- const workspace = getWorkspace(host);
99
- if (!options.project) {
100
- options.project = Object.keys(workspace.projects)[0];
101
- }
102
- const project = workspace.projects[options.project];
103
-
104
- if (options.path === undefined) {
105
- options.path = `/${project.root}/src/app`;
106
- }
107
-
108
- options.selector = options.selector || buildSelector(options);
109
- options.module = findModuleFromOptions(host, options);
110
-
111
- const parsedPath = parseName(options.path, options.name);
112
- options.name = parsedPath.name;
113
- options.path = parsedPath.path;
114
-
115
- validateName(options.name);
116
-
117
- const templateSource = apply(url('./files'), [
118
- options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
119
- options.inlineStyle ? filter(path => !path.endsWith('.__styleext__')) : noop(),
120
- options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(),
121
- template({
122
- ...strings,
123
- 'if-flat': (s: string) => options.flat ? '' : s,
124
- ...options,
125
- }),
126
- move(null, parsedPath.path),
127
- ]);
128
-
129
- return chain([
130
- branchAndMerge(chain([
131
- addDeclarationToNgModule(options),
132
- mergeWith(templateSource),
133
- ])),
134
- ])(host, context);
135
- };
136
- }
1
+ import {normalize, strings} from '@angular-devkit/core';
2
+ import {
3
+ apply,
4
+ branchAndMerge,
5
+ chain,
6
+ filter,
7
+ mergeWith,
8
+ move,
9
+ noop,
10
+ Rule,
11
+ SchematicContext,
12
+ SchematicsException,
13
+ template,
14
+ Tree,
15
+ url,
16
+ } from '@angular-devkit/schematics';
17
+ import * as ts from 'typescript';
18
+ import {addDeclarationToModule, addExportToModule} from './ast-utils';
19
+ import {InsertChange} from './change';
20
+ import {buildRelativePath, findModuleFromOptions} from './find-module';
21
+ import {getWorkspace} from './config';
22
+ import {parseName} from './parse-name';
23
+ import {validateName} from './validation';
24
+
25
+ function addDeclarationToNgModule(options: any): Rule {
26
+ return (host: Tree) => {
27
+ if (options.skipImport || !options.module) {
28
+ return host;
29
+ }
30
+
31
+ const modulePath = options.module;
32
+ const text = host.read(modulePath);
33
+ if (text === null) {
34
+ throw new SchematicsException(`File ${modulePath} does not exist.`);
35
+ }
36
+ const sourceText = text.toString('utf-8');
37
+ const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
38
+
39
+ const componentPath = `/${options.path}/`
40
+ + (options.flat ? '' : strings.dasherize(options.name) + '/')
41
+ + strings.dasherize(options.name)
42
+ + '.component';
43
+ const relativePath = buildRelativePath(modulePath, componentPath);
44
+ const classifiedName = strings.classify(`${options.name}Component`);
45
+ const declarationChanges = addDeclarationToModule(source,
46
+ modulePath,
47
+ classifiedName,
48
+ relativePath);
49
+
50
+ const declarationRecorder = host.beginUpdate(modulePath);
51
+ for (const change of declarationChanges) {
52
+ if (change instanceof InsertChange) {
53
+ declarationRecorder.insertLeft(change.pos, change.toAdd);
54
+ }
55
+ }
56
+ host.commitUpdate(declarationRecorder);
57
+
58
+ if (options.export) {
59
+ // Need to refresh the AST because we overwrote the file in the host.
60
+ const text = host.read(modulePath);
61
+ if (text === null) {
62
+ throw new SchematicsException(`File ${modulePath} does not exist.`);
63
+ }
64
+ const sourceText = text.toString('utf-8');
65
+ const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
66
+
67
+ const exportRecorder = host.beginUpdate(modulePath);
68
+ const exportChanges = addExportToModule(source, modulePath,
69
+ strings.classify(`${options.name}Component`),
70
+ relativePath);
71
+
72
+ for (const change of exportChanges) {
73
+ if (change instanceof InsertChange) {
74
+ exportRecorder.insertLeft(change.pos, change.toAdd);
75
+ }
76
+ }
77
+ host.commitUpdate(exportRecorder);
78
+ }
79
+
80
+
81
+ return host;
82
+ };
83
+ }
84
+
85
+
86
+ function buildSelector(options: any) {
87
+ let selector = strings.dasherize(options.name);
88
+ if (options.prefix) {
89
+ selector = `${options.prefix}-${selector}`;
90
+ }
91
+
92
+ return selector;
93
+ }
94
+
95
+
96
+ export function buildComponent(options: any): Rule {
97
+ return (host: Tree, context: SchematicContext) => {
98
+ const workspace = getWorkspace(host);
99
+ if (!options.project) {
100
+ options.project = Object.keys(workspace.projects)[0];
101
+ }
102
+ const project = workspace.projects[options.project];
103
+
104
+ if (options.path === undefined) {
105
+ options.path = `/${project.root}/src/app`;
106
+ }
107
+
108
+ options.selector = options.selector || buildSelector(options);
109
+ options.module = findModuleFromOptions(host, options);
110
+
111
+ const parsedPath = parseName(options.path, options.name);
112
+ options.name = parsedPath.name;
113
+ options.path = parsedPath.path;
114
+
115
+ validateName(options.name);
116
+
117
+ const templateSource = apply(url('./files'), [
118
+ options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
119
+ options.inlineStyle ? filter(path => !path.endsWith('.__styleext__')) : noop(),
120
+ options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(),
121
+ template({
122
+ ...strings,
123
+ 'if-flat': (s: string) => options.flat ? '' : s,
124
+ ...options,
125
+ }),
126
+ move(null, parsedPath.path),
127
+ ]);
128
+
129
+ return chain([
130
+ branchAndMerge(chain([
131
+ addDeclarationToNgModule(options),
132
+ mergeWith(templateSource),
133
+ ])),
134
+ ])(host, context);
135
+ };
136
+ }