@magic-xpa/cli 4.1201.0 → 4.1201.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +28 -28
  2. package/index.js.map +1 -1
  3. package/index.ts +1 -1
  4. package/package.json +1 -1
  5. package/src/collection.json +75 -75
  6. package/src/public_api.js.map +1 -1
  7. package/src/public_api.ts +5 -5
  8. package/src/schematics/magic-utils/config.js.map +1 -1
  9. package/src/schematics/magic-utils/config.ts +68 -68
  10. package/src/schematics/magic-utils/env.js.map +1 -1
  11. package/src/schematics/magic-utils/env.ts +50 -50
  12. package/src/schematics/magic-utils/manifest.js.map +1 -1
  13. package/src/schematics/magic-utils/manifest.ts +46 -46
  14. package/src/schematics/magic-utils/metadata.class.js.map +1 -1
  15. package/src/schematics/magic-utils/metadata.class.ts +159 -159
  16. package/src/schematics/magic-utils/rules/generate.rule.js.map +1 -1
  17. package/src/schematics/magic-utils/rules/generate.rule.ts +61 -61
  18. package/src/schematics/magic-utils/rules/init-add-modules.rule.js.map +1 -1
  19. package/src/schematics/magic-utils/rules/init-add-modules.rule.ts +360 -360
  20. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js.map +1 -1
  21. package/src/schematics/magic-utils/rules/init-magic-metadata.rule.ts +19 -19
  22. package/src/schematics/magic-utils/rules/magic-option.scheme.js.map +1 -1
  23. package/src/schematics/magic-utils/rules/magic-option.scheme.ts +24 -24
  24. package/src/schematics/magic-utils/utils.js.map +1 -1
  25. package/src/schematics/magic-utils/utils.ts +134 -134
  26. package/src/schematics/mg-Install-prerequisites/index.js.map +1 -1
  27. package/src/schematics/mg-Install-prerequisites/index.ts +30 -30
  28. package/src/schematics/mg-Install-prerequisites/schema.json +14 -14
  29. package/src/schematics/mg-add/files/src/app/app.component.html +17 -17
  30. package/src/schematics/mg-add/files/src/app/app.routes.ts +14 -14
  31. package/src/schematics/mg-add/files/src/app/magic/component-list.g.ts +9 -9
  32. package/src/schematics/mg-add/files/src/magic-styles.css +131 -131
  33. package/src/schematics/mg-add/schema.json +29 -29
  34. package/src/schematics/mg-add/utils/add-declaration-to-root-module.js.map +1 -1
  35. package/src/schematics/mg-add/utils/add-declaration-to-root-module.ts +12 -12
  36. package/src/schematics/mg-add/webModule/app.routes.ts +14 -14
  37. package/src/schematics/mg-add-tasks/index.js.map +1 -1
  38. package/src/schematics/mg-add-tasks/index.ts +53 -53
  39. package/src/schematics/mg-add-tasks/schema.json +41 -41
  40. package/src/schematics/mg-delete-files/index.js.map +1 -1
  41. package/src/schematics/mg-delete-files/index.ts +12 -12
  42. package/src/schematics/mg-delete-files/schema.json +14 -14
  43. package/src/schematics/mg-gen-module/index.js.map +1 -1
  44. package/src/schematics/mg-gen-module/index.ts +14 -14
  45. package/src/schematics/mg-gen-module/schema.json +24 -24
  46. package/src/schematics/mg-generate/index.js.map +1 -1
  47. package/src/schematics/mg-generate/index.ts +12 -12
  48. package/src/schematics/mg-generate/schema.json +34 -34
  49. package/src/schematics/mg-install/index.js.map +1 -1
  50. package/src/schematics/mg-install/index.ts +37 -37
  51. package/src/schematics/mg-install/schema.json +24 -24
  52. package/src/schematics/mg-routes/schema.json +14 -14
  53. package/src/schematics/mg-single-control/schema.json +24 -24
  54. package/src/schematics/utils/ast.js.map +1 -1
  55. package/src/schematics/utils/ast.ts +103 -103
  56. package/src/schematics/utils/devkit-utils/README.md +1 -1
  57. package/src/schematics/utils/devkit-utils/ast-utils.js.map +1 -1
  58. package/src/schematics/utils/devkit-utils/ast-utils.ts +570 -570
  59. package/src/schematics/utils/devkit-utils/ast-utils_old.js.map +1 -1
  60. package/src/schematics/utils/devkit-utils/ast-utils_old.ts +478 -478
  61. package/src/schematics/utils/devkit-utils/change.js.map +1 -1
  62. package/src/schematics/utils/devkit-utils/change.ts +127 -127
  63. package/src/schematics/utils/devkit-utils/component.js.map +1 -1
  64. package/src/schematics/utils/devkit-utils/component.ts +136 -136
  65. package/src/schematics/utils/devkit-utils/config.js.map +1 -1
  66. package/src/schematics/utils/devkit-utils/config.ts +120 -120
  67. package/src/schematics/utils/devkit-utils/find-module.js.map +1 -1
  68. package/src/schematics/utils/devkit-utils/find-module.ts +108 -108
  69. package/src/schematics/utils/devkit-utils/ng-ast-utils.js.map +1 -1
  70. package/src/schematics/utils/devkit-utils/ng-ast-utils.ts +84 -84
  71. package/src/schematics/utils/devkit-utils/parse-name.js.map +1 -1
  72. package/src/schematics/utils/devkit-utils/parse-name.ts +24 -24
  73. package/src/schematics/utils/devkit-utils/route-utils.js.map +1 -1
  74. package/src/schematics/utils/devkit-utils/route-utils.ts +180 -180
  75. package/src/schematics/utils/devkit-utils/validation.js +1 -1
  76. package/src/schematics/utils/devkit-utils/validation.js.map +1 -1
  77. package/src/schematics/utils/devkit-utils/validation.ts +16 -16
  78. package/src/schematics/utils/html.js.map +1 -1
  79. package/src/schematics/utils/html.ts +63 -63
  80. package/src/schematics/utils/lib-versions.js.map +1 -1
  81. package/src/schematics/utils/lib-versions.ts +3 -3
  82. package/src/schematics/utils/package.js.map +1 -1
  83. package/src/schematics/utils/package.ts +22 -22
  84. package/src/schematics/utils/testing.js.map +1 -1
  85. package/src/schematics/utils/testing.ts +25 -25
  86. package/src/types/enums/Enums.js.map +1 -1
  87. package/src/types/enums/Enums.ts +2063 -2063
  88. package/src/types/enums/generated-file-types.enum.js.map +1 -1
  89. package/src/types/enums/generated-file-types.enum.ts +6 -6
  90. package/src/types/enums/horizontal-alignments.enum.js.map +1 -1
  91. package/src/types/enums/horizontal-alignments.enum.ts +6 -6
  92. package/src/types/enums/themes.enum.js.map +1 -1
  93. package/src/types/enums/themes.enum.ts +6 -6
  94. package/src/types/index.js.map +1 -1
  95. package/src/types/index.ts +8 -8
  96. package/src/types/interfaces/app.js.map +1 -1
  97. package/src/types/interfaces/app.ts +89 -89
  98. package/src/types/interfaces/control.js.map +1 -1
  99. package/src/types/interfaces/control.ts +106 -106
  100. package/src/types/interfaces/template.config.js.map +1 -1
  101. package/src/types/interfaces/template.config.ts +11 -11
  102. package/templates/angular/src/app/app.component.html.ejs +17 -17
  103. package/templates/angular/src/app/cmp-array.ejs +3 -3
  104. package/templates/angular/src/app/cmp-hash.ejs +3 -3
  105. package/templates/angular/src/app/component-list.g.ts +21 -21
  106. package/templates/angular/src/app.component.ts +16 -16
  107. package/templates/angular/src/app.module.ts +70 -70
  108. package/templates/angular/src/app.routes.ts +73 -73
  109. package/templates/angular/src/styles/app.css +5 -5
  110. package/templates/attributes/button_attributes.ejs +2 -2
  111. package/templates/attributes/common/base/class.ejs +6 -6
  112. package/templates/attributes/common/base/control_type.ejs +53 -53
  113. package/templates/attributes/common/base/enabled.ejs +9 -9
  114. package/templates/attributes/common/base/imageFileName.ejs +3 -3
  115. package/templates/attributes/common/base/no_control_class.ejs +3 -3
  116. package/templates/attributes/common/base/rtol.ejs +3 -3
  117. package/templates/attributes/common/base/tabindex.ejs +11 -11
  118. package/templates/attributes/common/base/testingId.ejs +8 -8
  119. package/templates/attributes/common/base/tooltip.ejs +7 -7
  120. package/templates/attributes/common/base/visible.ejs +6 -6
  121. package/templates/attributes/common/base/wallpaper.ejs +3 -3
  122. package/templates/attributes/common/base_attributes.ejs +10 -10
  123. package/templates/attributes/common/container_attributes.ejs +6 -6
  124. package/templates/attributes/common/control_attributes.ejs +3 -3
  125. package/templates/attributes/common/format.ejs +5 -5
  126. package/templates/attributes/common/input/hint.ejs +13 -13
  127. package/templates/attributes/common/input/multiline_edit.ejs +3 -3
  128. package/templates/attributes/common/input/must_input.ejs +8 -8
  129. package/templates/attributes/common/input/password_edit.ejs +7 -7
  130. package/templates/attributes/common/input/row_editing_input_attributes.ejs +6 -6
  131. package/templates/attributes/common/input/validation.ejs +5 -5
  132. package/templates/attributes/common/input_attributes.ejs +4 -4
  133. package/templates/attributes/common/no_control_base_attributes.ejs +4 -4
  134. package/templates/attributes/common/row_editing_button_attributes.ejs +10 -10
  135. package/templates/component/view.component.html +14 -14
  136. package/templates/component/view.component.ts +136 -136
  137. package/templates/themes/basicHTML/Code/theme.module.ts +10 -10
  138. package/templates/themes/basicHTML/combobox.ejs +37 -37
  139. package/templates/themes/basicHTML/edit.ejs +169 -169
  140. package/templates/themes/basicHTML/form.ejs +4 -4
  141. package/templates/themes/basicHTML/group.ejs +4 -4
  142. package/templates/themes/basicHTML/image.ejs +6 -6
  143. package/templates/themes/basicHTML/label.ejs +11 -11
  144. package/templates/themes/basicHTML/listbox.ejs +21 -21
  145. package/templates/themes/basicHTML/push-button.ejs +28 -28
  146. package/templates/themes/basicHTML/radio.ejs +20 -20
  147. package/templates/themes/basicHTML/subform.ejs +6 -6
  148. package/templates/themes/basicHTML/tab.ejs +31 -31
  149. package/templates/themes/basicHTML/tabpage.ejs +5 -5
  150. package/templates/themes/basicHiddenHTML/Code/theme.module.ts +10 -10
  151. package/templates/themes/basicHiddenHTML/combobox.ejs +5 -5
  152. package/templates/themes/basicHiddenHTML/form.ejs +3 -3
  153. package/templates/themes/basicHiddenHTML/group.ejs +2 -2
  154. package/templates/themes/basicHiddenHTML/image.ejs +4 -4
  155. package/templates/themes/basicHiddenHTML/label.ejs +1 -1
  156. package/templates/themes/basicHiddenHTML/listbox.ejs +8 -8
  157. package/templates/themes/basicHiddenHTML/push-button.ejs +26 -26
  158. package/templates/themes/basicHiddenHTML/radio.ejs +17 -17
  159. package/templates/themes/basicHiddenHTML/tab.ejs +13 -13
  160. package/templates/themes/basicHiddenHTML/table.ejs +18 -18
  161. package/templates/themes/basicHiddenHTML/tabpage.ejs +2 -2
  162. package/templates/themes/container.ejs +26 -26
  163. package/templates/themes/control.ejs +52 -52
  164. package/templates/themes/editTypeSelector.ejs +1 -1
  165. package/templates/themes/material/Code/theme.module.ts +68 -68
  166. package/templates/themes/material/base_attributes_date.ejs +8 -8
  167. package/templates/themes/material/combobox.ejs +58 -58
  168. package/templates/themes/material/edit.ejs +204 -204
  169. package/templates/themes/material/group.ejs +3 -3
  170. package/templates/themes/material/listbox.ejs +22 -22
  171. package/templates/themes/material/push-button.ejs +28 -28
  172. package/templates/themes/material/radio.ejs +22 -22
  173. package/templates/themes/material/subform.ejs +8 -8
  174. package/templates/themes/material/tab.ejs +19 -19
  175. package/templates/themes/router_outlet.ejs +5 -5
  176. package/templates/themes/table/HTMLTable/table.ejs +37 -37
  177. package/templates/themes/table/grid/additionalComponentCode.ejs +26 -26
  178. package/templates/themes/table/grid/additionalIncludes.ejs +1 -1
  179. package/templates/themes/table/grid/table.ejs +37 -37
  180. package/templates/themes/table/repeatable/column.ejs +11 -11
  181. package/templates/themes/table/repeatable/table.ejs +28 -28
  182. package/templates/themes/tableTypeSelector.ejs +21 -21
  183. package/tsconfig.json +36 -36
@@ -1 +1 @@
1
- {"version":3,"file":"change.js","sourceRoot":"","sources":["change.ts"],"names":[],"mappings":";;;AA6BA;;GAEG;AACH,MAAa,UAAU;IAAvB;QACE,gBAAW,GAAG,eAAe,CAAC;QAC9B,UAAK,GAAG,QAAQ,CAAC;QACjB,SAAI,GAAG,IAAI,CAAC;IAEd,CAAC;IADC,KAAK,KAAK,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;CACtC;AALD,gCAKC;AAGD;;GAEG;AACH,MAAa,YAAY;IAKvB,YAAmB,IAAY,EAAS,GAAW,EAAS,KAAa;QAAtD,SAAI,GAAJ,IAAI,CAAQ;QAAS,QAAG,GAAH,GAAG,CAAQ;QAAS,UAAK,GAAL,KAAK,CAAQ;QACvE,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,YAAY,KAAK,kBAAkB,GAAG,OAAO,IAAI,EAAE,CAAC;QACvE,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAU;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,I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C,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3BD,sCA2BC","sourcesContent":["/**\r\n * @license\r\n * Copyright Google Inc. All Rights Reserved.\r\n *\r\n * Use of this source code is governed by an MIT-style license that can be\r\n * found in the LICENSE file at https://angular.io/license\r\n */\r\nexport interface Host {\r\n write(path: string, content: string): Promise<void>;\r\n read(path: string): Promise<string>;\r\n}\r\n\r\n\r\nexport interface Change {\r\n apply(host: Host): Promise<void>;\r\n\r\n // The file this change should be applied to. Some changes might not apply to\r\n // a file (maybe the config).\r\n readonly path: string | null;\r\n\r\n // The order this change should be applied. Normally the position inside the file.\r\n // Changes are applied from the bottom of a file to the top.\r\n readonly order: number;\r\n\r\n // The description of this change. This will be outputted in a dry or verbose run.\r\n readonly description: string;\r\n}\r\n\r\n\r\n/**\r\n * An operation that does nothing.\r\n */\r\nexport class NoopChange implements Change {\r\n description = 'No operation.';\r\n order = Infinity;\r\n path = null;\r\n apply() { return Promise.resolve(); }\r\n}\r\n\r\n\r\n/**\r\n * Will add text to the source code.\r\n */\r\nexport class InsertChange implements Change {\r\n\r\n order: number;\r\n description: string;\r\n\r\n constructor(public path: string, public pos: number, public toAdd: string) {\r\n if (pos < 0) {\r\n throw new Error('Negative positions are invalid');\r\n }\r\n this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;\r\n this.order = pos;\r\n }\r\n\r\n /**\r\n * This method does not insert spaces if there is none in the original string.\r\n */\r\n apply(host: Host) {\r\n return host.read(this.path).then(content => {\r\n const prefix = content.substring(0, this.pos);\r\n const suffix = content.substring(this.pos);\r\n\r\n return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Will remove text from the source code.\r\n */\r\nexport class RemoveChange implements Change {\r\n\r\n order: number;\r\n description: string;\r\n\r\n constructor(public path: string, private pos: number, private toRemove: string) {\r\n if (pos < 0) {\r\n throw new Error('Negative positions are invalid');\r\n }\r\n this.description = `Removed ${toRemove} into position ${pos} of ${path}`;\r\n this.order = pos;\r\n }\r\n\r\n apply(host: Host): Promise<void> {\r\n return host.read(this.path).then(content => {\r\n const prefix = content.substring(0, this.pos);\r\n const suffix = content.substring(this.pos + this.toRemove.length);\r\n\r\n // TODO: throw error if toRemove doesn't match removed string.\r\n return host.write(this.path, `${prefix}${suffix}`);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Will replace text from the source code.\r\n */\r\nexport class ReplaceChange implements Change {\r\n order: number;\r\n description: string;\r\n\r\n constructor(public path: string, private pos: number, private oldText: string,\r\n private newText: string) {\r\n if (pos < 0) {\r\n throw new Error('Negative positions are invalid');\r\n }\r\n this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;\r\n this.order = pos;\r\n }\r\n\r\n apply(host: Host): Promise<void> {\r\n return host.read(this.path).then(content => {\r\n const prefix = content.substring(0, this.pos);\r\n const suffix = content.substring(this.pos + this.oldText.length);\r\n const text = content.substring(this.pos, this.pos + this.oldText.length);\r\n\r\n if (text !== this.oldText) {\r\n return Promise.reject(new Error(`Invalid replace: \"${text}\" != \"${this.oldText}\".`));\r\n }\r\n\r\n // TODO: throw error if oldText doesn't match removed string.\r\n return host.write(this.path, `${prefix}${this.newText}${suffix}`);\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"change.js","sourceRoot":"","sources":["change.ts"],"names":[],"mappings":";;;AA6BA;;GAEG;AACH,MAAa,UAAU;IAAvB;QACE,gBAAW,GAAG,eAAe,CAAC;QAC9B,UAAK,GAAG,QAAQ,CAAC;QACjB,SAAI,GAAG,IAAI,CAAC;IAEd,CAAC;IADC,KAAK,KAAK,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;CACtC;AALD,gCAKC;AAGD;;GAEG;AACH,MAAa,YAAY;IAKvB,YAAmB,IAAY,EAAS,GAAW,EAAS,KAAa;QA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GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACjE,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAEzE,IAAI,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC1B,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,IAAI,SAAS,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;YACvF,CAAC;YAED,6DAA6D;YAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3BD,sCA2BC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nexport interface Host {\n write(path: string, content: string): Promise<void>;\n read(path: string): Promise<string>;\n}\n\n\nexport interface Change {\n apply(host: Host): Promise<void>;\n\n // The file this change should be applied to. Some changes might not apply to\n // a file (maybe the config).\n readonly path: string | null;\n\n // The order this change should be applied. Normally the position inside the file.\n // Changes are applied from the bottom of a file to the top.\n readonly order: number;\n\n // The description of this change. This will be outputted in a dry or verbose run.\n readonly description: string;\n}\n\n\n/**\n * An operation that does nothing.\n */\nexport class NoopChange implements Change {\n description = 'No operation.';\n order = Infinity;\n path = null;\n apply() { return Promise.resolve(); }\n}\n\n\n/**\n * Will add text to the source code.\n */\nexport class InsertChange implements Change {\n\n order: number;\n description: string;\n\n constructor(public path: string, public pos: number, public toAdd: string) {\n if (pos < 0) {\n throw new Error('Negative positions are invalid');\n }\n this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;\n this.order = pos;\n }\n\n /**\n * This method does not insert spaces if there is none in the original string.\n */\n apply(host: Host) {\n return host.read(this.path).then(content => {\n const prefix = content.substring(0, this.pos);\n const suffix = content.substring(this.pos);\n\n return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);\n });\n }\n}\n\n/**\n * Will remove text from the source code.\n */\nexport class RemoveChange implements Change {\n\n order: number;\n description: string;\n\n constructor(public path: string, private pos: number, private toRemove: string) {\n if (pos < 0) {\n throw new Error('Negative positions are invalid');\n }\n this.description = `Removed ${toRemove} into position ${pos} of ${path}`;\n this.order = pos;\n }\n\n apply(host: Host): Promise<void> {\n return host.read(this.path).then(content => {\n const prefix = content.substring(0, this.pos);\n const suffix = content.substring(this.pos + this.toRemove.length);\n\n // TODO: throw error if toRemove doesn't match removed string.\n return host.write(this.path, `${prefix}${suffix}`);\n });\n }\n}\n\n/**\n * Will replace text from the source code.\n */\nexport class ReplaceChange implements Change {\n order: number;\n description: string;\n\n constructor(public path: string, private pos: number, private oldText: string,\n private newText: string) {\n if (pos < 0) {\n throw new Error('Negative positions are invalid');\n }\n this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;\n this.order = pos;\n }\n\n apply(host: Host): Promise<void> {\n return host.read(this.path).then(content => {\n const prefix = content.substring(0, this.pos);\n const suffix = content.substring(this.pos + this.oldText.length);\n const text = content.substring(this.pos, this.pos + this.oldText.length);\n\n if (text !== this.oldText) {\n return Promise.reject(new Error(`Invalid replace: \"${text}\" != \"${this.oldText}\".`));\n }\n\n // TODO: throw error if oldText doesn't match removed string.\n return host.write(this.path, `${prefix}${this.newText}${suffix}`);\n });\n }\n}\n"]}
@@ -1,127 +1,127 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- export interface Host {
9
- write(path: string, content: string): Promise<void>;
10
- read(path: string): Promise<string>;
11
- }
12
-
13
-
14
- export interface Change {
15
- apply(host: Host): Promise<void>;
16
-
17
- // The file this change should be applied to. Some changes might not apply to
18
- // a file (maybe the config).
19
- readonly path: string | null;
20
-
21
- // The order this change should be applied. Normally the position inside the file.
22
- // Changes are applied from the bottom of a file to the top.
23
- readonly order: number;
24
-
25
- // The description of this change. This will be outputted in a dry or verbose run.
26
- readonly description: string;
27
- }
28
-
29
-
30
- /**
31
- * An operation that does nothing.
32
- */
33
- export class NoopChange implements Change {
34
- description = 'No operation.';
35
- order = Infinity;
36
- path = null;
37
- apply() { return Promise.resolve(); }
38
- }
39
-
40
-
41
- /**
42
- * Will add text to the source code.
43
- */
44
- export class InsertChange implements Change {
45
-
46
- order: number;
47
- description: string;
48
-
49
- constructor(public path: string, public pos: number, public toAdd: string) {
50
- if (pos < 0) {
51
- throw new Error('Negative positions are invalid');
52
- }
53
- this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
54
- this.order = pos;
55
- }
56
-
57
- /**
58
- * This method does not insert spaces if there is none in the original string.
59
- */
60
- apply(host: Host) {
61
- return host.read(this.path).then(content => {
62
- const prefix = content.substring(0, this.pos);
63
- const suffix = content.substring(this.pos);
64
-
65
- return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
66
- });
67
- }
68
- }
69
-
70
- /**
71
- * Will remove text from the source code.
72
- */
73
- export class RemoveChange implements Change {
74
-
75
- order: number;
76
- description: string;
77
-
78
- constructor(public path: string, private pos: number, private toRemove: string) {
79
- if (pos < 0) {
80
- throw new Error('Negative positions are invalid');
81
- }
82
- this.description = `Removed ${toRemove} into position ${pos} of ${path}`;
83
- this.order = pos;
84
- }
85
-
86
- apply(host: Host): Promise<void> {
87
- return host.read(this.path).then(content => {
88
- const prefix = content.substring(0, this.pos);
89
- const suffix = content.substring(this.pos + this.toRemove.length);
90
-
91
- // TODO: throw error if toRemove doesn't match removed string.
92
- return host.write(this.path, `${prefix}${suffix}`);
93
- });
94
- }
95
- }
96
-
97
- /**
98
- * Will replace text from the source code.
99
- */
100
- export class ReplaceChange implements Change {
101
- order: number;
102
- description: string;
103
-
104
- constructor(public path: string, private pos: number, private oldText: string,
105
- private newText: string) {
106
- if (pos < 0) {
107
- throw new Error('Negative positions are invalid');
108
- }
109
- this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
110
- this.order = pos;
111
- }
112
-
113
- apply(host: Host): Promise<void> {
114
- return host.read(this.path).then(content => {
115
- const prefix = content.substring(0, this.pos);
116
- const suffix = content.substring(this.pos + this.oldText.length);
117
- const text = content.substring(this.pos, this.pos + this.oldText.length);
118
-
119
- if (text !== this.oldText) {
120
- return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
121
- }
122
-
123
- // TODO: throw error if oldText doesn't match removed string.
124
- return host.write(this.path, `${prefix}${this.newText}${suffix}`);
125
- });
126
- }
127
- }
1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ export interface Host {
9
+ write(path: string, content: string): Promise<void>;
10
+ read(path: string): Promise<string>;
11
+ }
12
+
13
+
14
+ export interface Change {
15
+ apply(host: Host): Promise<void>;
16
+
17
+ // The file this change should be applied to. Some changes might not apply to
18
+ // a file (maybe the config).
19
+ readonly path: string | null;
20
+
21
+ // The order this change should be applied. Normally the position inside the file.
22
+ // Changes are applied from the bottom of a file to the top.
23
+ readonly order: number;
24
+
25
+ // The description of this change. This will be outputted in a dry or verbose run.
26
+ readonly description: string;
27
+ }
28
+
29
+
30
+ /**
31
+ * An operation that does nothing.
32
+ */
33
+ export class NoopChange implements Change {
34
+ description = 'No operation.';
35
+ order = Infinity;
36
+ path = null;
37
+ apply() { return Promise.resolve(); }
38
+ }
39
+
40
+
41
+ /**
42
+ * Will add text to the source code.
43
+ */
44
+ export class InsertChange implements Change {
45
+
46
+ order: number;
47
+ description: string;
48
+
49
+ constructor(public path: string, public pos: number, public toAdd: string) {
50
+ if (pos < 0) {
51
+ throw new Error('Negative positions are invalid');
52
+ }
53
+ this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
54
+ this.order = pos;
55
+ }
56
+
57
+ /**
58
+ * This method does not insert spaces if there is none in the original string.
59
+ */
60
+ apply(host: Host) {
61
+ return host.read(this.path).then(content => {
62
+ const prefix = content.substring(0, this.pos);
63
+ const suffix = content.substring(this.pos);
64
+
65
+ return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
66
+ });
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Will remove text from the source code.
72
+ */
73
+ export class RemoveChange implements Change {
74
+
75
+ order: number;
76
+ description: string;
77
+
78
+ constructor(public path: string, private pos: number, private toRemove: string) {
79
+ if (pos < 0) {
80
+ throw new Error('Negative positions are invalid');
81
+ }
82
+ this.description = `Removed ${toRemove} into position ${pos} of ${path}`;
83
+ this.order = pos;
84
+ }
85
+
86
+ apply(host: Host): Promise<void> {
87
+ return host.read(this.path).then(content => {
88
+ const prefix = content.substring(0, this.pos);
89
+ const suffix = content.substring(this.pos + this.toRemove.length);
90
+
91
+ // TODO: throw error if toRemove doesn't match removed string.
92
+ return host.write(this.path, `${prefix}${suffix}`);
93
+ });
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Will replace text from the source code.
99
+ */
100
+ export class ReplaceChange implements Change {
101
+ order: number;
102
+ description: string;
103
+
104
+ constructor(public path: string, private pos: number, private oldText: string,
105
+ private newText: string) {
106
+ if (pos < 0) {
107
+ throw new Error('Negative positions are invalid');
108
+ }
109
+ this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
110
+ this.order = pos;
111
+ }
112
+
113
+ apply(host: Host): Promise<void> {
114
+ return host.read(this.path).then(content => {
115
+ const prefix = content.substring(0, this.pos);
116
+ const suffix = content.substring(this.pos + this.oldText.length);
117
+ const text = content.substring(this.pos, this.pos + this.oldText.length);
118
+
119
+ if (text !== this.oldText) {
120
+ return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
121
+ }
122
+
123
+ // TODO: throw error if oldText doesn't match removed string.
124
+ return host.write(this.path, `${prefix}${this.newText}${suffix}`);
125
+ });
126
+ }
127
+ }
@@ -1 +1 @@
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,UAAU,CAAC,CAAC;QACnC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,IAAI,gCAAmB,CAAC,QAAQ,UAAU,kBAAkB,CAAC,CAAC;QACtE,CAAC;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,UAA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BACjC,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
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IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {normalize, strings} 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,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
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["config.ts"],"names":[],"mappings":";;;AA+EA,oCAOC;AAMD,0DA2BC;AAvHD;;;;;;GAMG;AACH,2DAAqE;AAExD,QAAA,0BAA0B,GAAG,eAAe,CAAC;AAqE1D,2DAA2D;AAC3D,SAAgB,YAAY,CAAC,IAAU;IACrC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,kCAA0B,CAAC,CAAC;IAC3D,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,gCAAmB,CAAC,6BAA6B,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CAAC,MAAiB,EAAE,WAAoB;IAC7E,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,gCAAmB,CAAC,qBAAqB,WAAW,WAAW,CAAC,CAAC;YAC7E,CAAC;YAED,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAC,CAAC,CAAC;YAChF,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,wFAAwF;QACxF,wBAAwB;QACxB,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACrF,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,oFAAoF;YACpF,oEAAoE;YACpE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAC,CAAC,CAAC;YAChF,OAAO,OAAO,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,gCAAmB,CAAC,8DAA8D,CAAC,CAAC;QAChG,CAAC;IACH,CAAC;IAED,MAAM,IAAI,gCAAmB,CAAC,yBAAyB,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/**\r\n * @license\r\n * Copyright Google Inc. All Rights Reserved.\r\n *\r\n * Use of this source code is governed by an MIT-style license that can be\r\n * found in the LICENSE file at https://angular.io/license\r\n */\r\nimport {SchematicsException, Tree} from '@angular-devkit/schematics';\r\n\r\nexport const ANGULAR_CLI_WORKSPACE_PATH = '/angular.json';\r\n\r\n\r\n/** An Angular CLI Workspacer config (angular.json) */\r\nexport interface Workspace {\r\n /** Link to schema. */\r\n $schema?: string;\r\n /** Workspace Schema version. */\r\n version: number;\r\n /** New project root. */\r\n newProjectRoot?: string;\r\n /** Tool options. */\r\n cli?: {\r\n /** Link to schema. */\r\n $schema?: string;\r\n [k: string]: any;\r\n };\r\n /** Tool options. */\r\n schematics?: {\r\n /** Link to schema. */\r\n $schema?: string;\r\n [k: string]: any;\r\n };\r\n /** Tool options. */\r\n architect?: {\r\n /** Link to schema. */\r\n $schema?: string;\r\n [k: string]: any;\r\n };\r\n /** A map of project names to project options. */\r\n projects: {\r\n [k: string]: Project;\r\n };\r\n}\r\n\r\n/**\r\n * A project in an Angular CLI workspace (e.g. an app or a library). A single workspace\r\n * can house multiple projects.\r\n */\r\nexport interface Project {\r\n name: string;\r\n\r\n /** Project type. */\r\n projectType: 'application' | 'library';\r\n /** Root of the project sourcefiles. */\r\n root: string;\r\n /** Tool options. */\r\n cli?: {\r\n /** Link to schema. */\r\n $schema?: string;\r\n [k: string]: any;\r\n };\r\n /** Tool options. */\r\n schematics?: {\r\n /** Link to schema. */\r\n $schema?: string;\r\n [k: string]: any;\r\n };\r\n /** Tool options. */\r\n architect?: ProjectBuildOptions;\r\n}\r\n\r\n/** Architect options for an Angular CLI workspace. */\r\nexport interface ProjectBuildOptions {\r\n /** Link to schema. */\r\n $schema?: string;\r\n [k: string]: any;\r\n}\r\n\r\n/** Gets the Angular CLI workspace config (angular.json) */\r\nexport function getWorkspace(host: Tree): Workspace {\r\n const configBuffer = host.read(ANGULAR_CLI_WORKSPACE_PATH);\r\n if (configBuffer === null) {\r\n throw new SchematicsException('Could not find angular.json');\r\n }\r\n\r\n return JSON.parse(configBuffer.toString());\r\n}\r\n\r\n/**\r\n * Gets a project from the Angular CLI workspace. If no project name is given, the first project\r\n * will be retrieved.\r\n */\r\nexport function getProjectFromWorkspace(config: Workspace, projectName?: string): Project {\r\n if (config.projects) {\r\n if (projectName) {\r\n const project = config.projects[projectName];\r\n if (!project) {\r\n throw new SchematicsException(`No project named \"${projectName}\" exists.`);\r\n }\r\n\r\n Object.defineProperty(project, 'name', {enumerable: false, value: projectName});\r\n return project;\r\n }\r\n\r\n // If there is exactly one non-e2e project, use that. Otherwise, require that a specific\r\n // project be specified.\r\n const allProjectNames = Object.keys(config.projects).filter(p => !p.includes('e2e'));\r\n if (allProjectNames.length === 1) {\r\n const project = config.projects[allProjectNames[0]];\r\n // Set a non-enumerable project name to the project. We need the name for schematics\r\n // later on, but don't want to write it back out to the config file.\r\n Object.defineProperty(project, 'name', {enumerable: false, value: projectName});\r\n return project;\r\n } else {\r\n throw new SchematicsException('Multiple projects are defined; please specify a project name');\r\n }\r\n }\r\n\r\n throw new SchematicsException('No projects are defined');\r\n}\r\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["config.ts"],"names":[],"mappings":";;;AA+EA,oCAOC;AAMD,0DA2BC;AAvHD;;;;;;GAMG;AACH,2DAAqE;AAExD,QAAA,0BAA0B,GAAG,eAAe,CAAC;AAqE1D,2DAA2D;AAC3D,SAAgB,YAAY,CAAC,IAAU;IACrC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,kCAA0B,CAAC,CAAC;IAC3D,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,gCAAmB,CAAC,6BAA6B,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CAAC,MAAiB,EAAE,WAAoB;IAC7E,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,gCAAmB,CAAC,qBAAqB,WAAW,WAAW,CAAC,CAAC;YAC7E,CAAC;YAED,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAC,CAAC,CAAC;YAChF,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,wFAAwF;QACxF,wBAAwB;QACxB,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACrF,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,oFAAoF;YACpF,oEAAoE;YACpE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAC,CAAC,CAAC;YAChF,OAAO,OAAO,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,gCAAmB,CAAC,8DAA8D,CAAC,CAAC;QAChG,CAAC;IACH,CAAC;IAED,MAAM,IAAI,gCAAmB,CAAC,yBAAyB,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {SchematicsException, Tree} from '@angular-devkit/schematics';\n\nexport const ANGULAR_CLI_WORKSPACE_PATH = '/angular.json';\n\n\n/** An Angular CLI Workspacer config (angular.json) */\nexport interface Workspace {\n /** Link to schema. */\n $schema?: string;\n /** Workspace Schema version. */\n version: number;\n /** New project root. */\n newProjectRoot?: string;\n /** Tool options. */\n cli?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** Tool options. */\n schematics?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** Tool options. */\n architect?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** A map of project names to project options. */\n projects: {\n [k: string]: Project;\n };\n}\n\n/**\n * A project in an Angular CLI workspace (e.g. an app or a library). A single workspace\n * can house multiple projects.\n */\nexport interface Project {\n name: string;\n\n /** Project type. */\n projectType: 'application' | 'library';\n /** Root of the project sourcefiles. */\n root: string;\n /** Tool options. */\n cli?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** Tool options. */\n schematics?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** Tool options. */\n architect?: ProjectBuildOptions;\n}\n\n/** Architect options for an Angular CLI workspace. */\nexport interface ProjectBuildOptions {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n}\n\n/** Gets the Angular CLI workspace config (angular.json) */\nexport function getWorkspace(host: Tree): Workspace {\n const configBuffer = host.read(ANGULAR_CLI_WORKSPACE_PATH);\n if (configBuffer === null) {\n throw new SchematicsException('Could not find angular.json');\n }\n\n return JSON.parse(configBuffer.toString());\n}\n\n/**\n * Gets a project from the Angular CLI workspace. If no project name is given, the first project\n * will be retrieved.\n */\nexport function getProjectFromWorkspace(config: Workspace, projectName?: string): Project {\n if (config.projects) {\n if (projectName) {\n const project = config.projects[projectName];\n if (!project) {\n throw new SchematicsException(`No project named \"${projectName}\" exists.`);\n }\n\n Object.defineProperty(project, 'name', {enumerable: false, value: projectName});\n return project;\n }\n\n // If there is exactly one non-e2e project, use that. Otherwise, require that a specific\n // project be specified.\n const allProjectNames = Object.keys(config.projects).filter(p => !p.includes('e2e'));\n if (allProjectNames.length === 1) {\n const project = config.projects[allProjectNames[0]];\n // Set a non-enumerable project name to the project. We need the name for schematics\n // later on, but don't want to write it back out to the config file.\n Object.defineProperty(project, 'name', {enumerable: false, value: projectName});\n return project;\n } else {\n throw new SchematicsException('Multiple projects are defined; please specify a project name');\n }\n }\n\n throw new SchematicsException('No projects are defined');\n}\n"]}