@storybook/angular 7.0.0-alpha.45 → 7.0.0-alpha.47

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 (269) hide show
  1. package/.eslintrc.js +8 -0
  2. package/dist/{types/builders → builders}/build-storybook/index.d.ts +1 -1
  3. package/dist/{types/builders → builders}/build-storybook/index.js +0 -0
  4. package/dist/{types/builders → builders}/build-storybook/index.spec.d.ts +0 -0
  5. package/dist/{types/builders → builders}/build-storybook/index.spec.js +0 -0
  6. package/dist/{types/builders → builders}/build-storybook/schema.json +0 -0
  7. package/dist/{types/builders → builders}/builders.json +0 -0
  8. package/dist/{types/builders → builders}/start-storybook/index.d.ts +1 -1
  9. package/dist/{types/builders → builders}/start-storybook/index.js +0 -0
  10. package/dist/{types/builders → builders}/start-storybook/index.spec.d.ts +0 -0
  11. package/dist/{types/builders → builders}/start-storybook/index.spec.js +0 -0
  12. package/dist/{types/builders → builders}/start-storybook/schema.json +0 -0
  13. package/dist/{types/builders → builders}/utils/build-standalone-errors-handler.d.ts +0 -0
  14. package/dist/{types/builders → builders}/utils/build-standalone-errors-handler.js +0 -0
  15. package/dist/{types/builders → builders}/utils/run-compodoc.d.ts +0 -0
  16. package/dist/{types/builders → builders}/utils/run-compodoc.js +0 -0
  17. package/dist/{types/builders → builders}/utils/run-compodoc.spec.d.ts +0 -0
  18. package/dist/{types/builders → builders}/utils/run-compodoc.spec.js +0 -0
  19. package/dist/{types/builders → builders}/utils/standalone-options.d.ts +2 -2
  20. package/dist/{types/builders → builders}/utils/standalone-options.js +0 -0
  21. package/dist/{types/client → client}/angular/app.component.d.ts +1 -1
  22. package/dist/{types/client → client}/angular/app.component.js +0 -0
  23. package/dist/{types/client → client}/angular/app.token.d.ts +0 -0
  24. package/dist/{types/client → client}/angular/app.token.js +0 -0
  25. package/dist/{types/client → client}/angular/helpers.d.ts +2 -2
  26. package/dist/{types/client → client}/angular/helpers.js +0 -0
  27. package/dist/{types/client → client}/angular-beta/AbstractRenderer.d.ts +0 -0
  28. package/dist/{types/client → client}/angular-beta/AbstractRenderer.js +0 -0
  29. package/dist/{types/client → client}/angular-beta/CanvasRenderer.d.ts +0 -0
  30. package/dist/{types/client → client}/angular-beta/CanvasRenderer.js +0 -0
  31. package/dist/{types/client → client}/angular-beta/ComputesTemplateFromComponent.d.ts +3 -3
  32. package/dist/{types/client → client}/angular-beta/ComputesTemplateFromComponent.js +0 -0
  33. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +1 -0
  34. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +389 -0
  35. package/dist/{types/client → client}/angular-beta/DocsRenderer.d.ts +0 -0
  36. package/dist/{types/client → client}/angular-beta/DocsRenderer.js +0 -0
  37. package/dist/{types/client → client}/angular-beta/RendererFactory.d.ts +0 -0
  38. package/dist/{types/client → client}/angular-beta/RendererFactory.js +0 -0
  39. package/dist/client/angular-beta/RendererFactory.test.d.ts +1 -0
  40. package/dist/client/angular-beta/RendererFactory.test.js +295 -0
  41. package/dist/{types/client → client}/angular-beta/StorybookModule.d.ts +1 -1
  42. package/dist/{types/client → client}/angular-beta/StorybookModule.js +0 -0
  43. package/dist/client/angular-beta/StorybookModule.test.d.ts +1 -0
  44. package/dist/client/angular-beta/StorybookModule.test.js +279 -0
  45. package/dist/{types/client → client}/angular-beta/StorybookProvider.d.ts +1 -1
  46. package/dist/{types/client → client}/angular-beta/StorybookProvider.js +0 -0
  47. package/dist/{types/client → client}/angular-beta/StorybookWrapperComponent.d.ts +0 -0
  48. package/dist/{types/client → client}/angular-beta/StorybookWrapperComponent.js +0 -0
  49. package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +26 -0
  50. package/dist/client/angular-beta/__testfixtures__/input.component.js +67 -0
  51. package/dist/{types/client → client}/angular-beta/utils/NgComponentAnalyzer.d.ts +1 -1
  52. package/dist/{types/client → client}/angular-beta/utils/NgComponentAnalyzer.js +0 -0
  53. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.d.ts +1 -0
  54. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +340 -0
  55. package/dist/{types/client → client}/angular-beta/utils/NgModulesAnalyzer.d.ts +0 -0
  56. package/dist/{types/client → client}/angular-beta/utils/NgModulesAnalyzer.js +0 -0
  57. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.d.ts +1 -0
  58. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +23 -0
  59. package/dist/{types/client → client}/config.d.ts +0 -0
  60. package/dist/{types/client → client}/config.js +0 -0
  61. package/dist/{types/client → client}/decorateStory.d.ts +2 -2
  62. package/dist/{types/client → client}/decorateStory.js +0 -0
  63. package/dist/client/decorateStory.test.d.ts +1 -0
  64. package/dist/client/decorateStory.test.js +335 -0
  65. package/dist/{types/client → client}/decorators.d.ts +3 -3
  66. package/dist/{types/client → client}/decorators.js +0 -0
  67. package/dist/client/decorators.test.d.ts +1 -0
  68. package/dist/client/decorators.test.js +106 -0
  69. package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +111 -0
  70. package/dist/client/docs/__testfixtures__/doc-button/input.js +207 -0
  71. package/dist/client/docs/__testfixtures__/doc-button/tsconfig.json +7 -0
  72. package/dist/client/docs/angular-properties.test.d.ts +1 -0
  73. package/dist/client/docs/angular-properties.test.js +56 -0
  74. package/dist/{types/client → client}/docs/compodoc.d.ts +2 -2
  75. package/dist/{types/client → client}/docs/compodoc.js +0 -0
  76. package/dist/client/docs/compodoc.test.d.ts +1 -0
  77. package/dist/client/docs/compodoc.test.js +131 -0
  78. package/dist/{types/client → client}/docs/config.d.ts +1 -1
  79. package/dist/{types/client → client}/docs/config.js +0 -0
  80. package/dist/{types/client → client}/docs/index.d.ts +0 -0
  81. package/dist/{types/client → client}/docs/index.js +0 -0
  82. package/dist/{types/client → client}/docs/sourceDecorator.d.ts +1 -1
  83. package/dist/{types/client → client}/docs/sourceDecorator.js +0 -0
  84. package/dist/{types/client → client}/docs/types.d.ts +0 -0
  85. package/dist/{types/client → client}/docs/types.js +0 -0
  86. package/dist/{types/client → client}/globals.d.ts +0 -0
  87. package/dist/{types/client → client}/globals.js +0 -0
  88. package/dist/{types/client → client}/index.d.ts +0 -0
  89. package/dist/{types/client → client}/index.js +0 -0
  90. package/dist/{types/client → client}/public-api.d.ts +2 -2
  91. package/dist/{types/client → client}/public-api.js +0 -0
  92. package/dist/{types/client → client}/public-types.d.ts +1 -1
  93. package/dist/{types/client → client}/public-types.js +0 -0
  94. package/dist/{types/client → client}/render.d.ts +2 -2
  95. package/dist/{types/client → client}/render.js +0 -0
  96. package/dist/{types/client → client}/types.d.ts +1 -1
  97. package/dist/{types/client → client}/types.js +0 -0
  98. package/dist/{types/index.d.ts → index.d.ts} +0 -0
  99. package/dist/{types/index.js → index.js} +0 -0
  100. package/dist/{types/preset.d.ts → preset.d.ts} +1 -1
  101. package/dist/{types/preset.js → preset.js} +0 -0
  102. package/dist/{types/renderer.d.ts → renderer.d.ts} +0 -0
  103. package/dist/{types/renderer.js → renderer.js} +0 -0
  104. package/dist/{types/server → server}/__mocks-ng-workspace__/empty-projects-entry/angular.json +0 -0
  105. package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/angular.json +0 -0
  106. package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/src/main.d.ts +0 -0
  107. package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/src/main.js +0 -0
  108. package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/src/tsconfig.app.json +0 -0
  109. package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/tsconfig.json +0 -0
  110. package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/angular.json +0 -0
  111. package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/src/main.d.ts +0 -0
  112. package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/src/main.js +0 -0
  113. package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/src/tsconfig.app.json +0 -0
  114. package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/tsconfig.json +0 -0
  115. package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +0 -0
  116. package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.d.ts +0 -0
  117. package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.js +0 -0
  118. package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/src/tsconfig.app.json +0 -0
  119. package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +0 -0
  120. package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/angular.json +0 -0
  121. package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.d.ts +0 -0
  122. package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.js +0 -0
  123. package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json +0 -0
  124. package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/tsconfig.json +0 -0
  125. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/angular.json +0 -0
  126. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/nx.json +0 -0
  127. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/src/main.d.ts +0 -0
  128. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/src/main.js +0 -0
  129. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/src/tsconfig.app.json +0 -0
  130. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/tsconfig.json +0 -0
  131. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/nx.json +0 -0
  132. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/src/main.d.ts +0 -0
  133. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/src/main.js +0 -0
  134. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/src/tsconfig.app.json +0 -0
  135. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +0 -0
  136. package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/workspace.json +0 -0
  137. package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/angular.json +0 -0
  138. package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/src/main.d.ts +0 -0
  139. package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/src/main.js +0 -0
  140. package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/src/tsconfig.app.json +0 -0
  141. package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/tsconfig.json +0 -0
  142. package/dist/{types/server → server}/__mocks-ng-workspace__/without-architect-build/angular.json +0 -0
  143. package/dist/{types/server → server}/__mocks-ng-workspace__/without-architect-build-options/angular.json +0 -0
  144. package/dist/{types/server → server}/__mocks-ng-workspace__/without-compatible-projects/angular.json +0 -0
  145. package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/angular.json +0 -0
  146. package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.d.ts +0 -0
  147. package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.js +0 -0
  148. package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json +0 -0
  149. package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +0 -0
  150. package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/angular.json +0 -0
  151. package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/src/main.d.ts +0 -0
  152. package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/src/main.js +0 -0
  153. package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/src/tsconfig.app.json +0 -0
  154. package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +0 -0
  155. package/dist/server/__tests__/angular.json +96 -0
  156. package/dist/{types/server → server}/angular-cli-webpack-13.x.x.d.ts +0 -0
  157. package/dist/{types/server → server}/angular-cli-webpack-13.x.x.js +0 -0
  158. package/dist/{types/server → server}/angular-read-workspace.d.ts +0 -0
  159. package/dist/{types/server → server}/angular-read-workspace.js +0 -0
  160. package/dist/{types/server → server}/framework-preset-angular-cli.d.ts +1 -1
  161. package/dist/{types/server → server}/framework-preset-angular-cli.js +0 -0
  162. package/dist/server/framework-preset-angular-cli.test.d.ts +1 -0
  163. package/dist/server/framework-preset-angular-cli.test.js +708 -0
  164. package/dist/{types/server → server}/framework-preset-angular-docs.d.ts +1 -1
  165. package/dist/{types/server → server}/framework-preset-angular-docs.js +1 -1
  166. package/dist/{types/server → server}/framework-preset-angular-ivy.d.ts +1 -1
  167. package/dist/{types/server → server}/framework-preset-angular-ivy.js +0 -0
  168. package/dist/{types/server → server}/preset-options.d.ts +1 -1
  169. package/dist/{types/server → server}/preset-options.js +0 -0
  170. package/dist/{types/server → server}/utils/filter-out-styling-rules.d.ts +1 -1
  171. package/dist/{types/server → server}/utils/filter-out-styling-rules.js +0 -0
  172. package/dist/{types/server → server}/utils/module-is-available.d.ts +0 -0
  173. package/dist/{types/server → server}/utils/module-is-available.js +0 -0
  174. package/dist/{types/server → server}/utils/normalize-asset-patterns.d.ts +1 -1
  175. package/dist/{types/server → server}/utils/normalize-asset-patterns.js +0 -0
  176. package/dist/{types/server → server}/utils/normalize-optimization.d.ts +0 -0
  177. package/dist/{types/server → server}/utils/normalize-optimization.js +0 -0
  178. package/dist/{types/types.d.ts → types.d.ts} +2 -2
  179. package/dist/{types/types.js → types.js} +0 -0
  180. package/package.json +23 -21
  181. package/preset.js +1 -1
  182. package/renderer.d.ts +1 -1
  183. package/renderer.js +1 -1
  184. package/template/cli/.eslintrc.json +5 -0
  185. package/template/cli/Button.stories.ts +52 -0
  186. package/template/cli/Header.stories.ts +35 -0
  187. package/template/cli/Page.stories.ts +46 -0
  188. package/template/cli/User.ts +2 -0
  189. package/template/cli/button.component.ts +53 -0
  190. package/template/cli/header.component.ts +75 -0
  191. package/template/cli/page.component.ts +77 -0
  192. package/template/components/button.component.ts +54 -0
  193. package/template/components/button.css +30 -0
  194. package/template/components/form.component.ts +37 -0
  195. package/template/components/html.component.ts +22 -0
  196. package/template/components/index.js +8 -0
  197. package/template/components/pre.component.ts +29 -0
  198. package/template/stories/angular-mdx.stories.mdx +25 -0
  199. package/template/stories/argTypes/doc-button/doc-button.component.html +7 -0
  200. package/template/stories/argTypes/doc-button/doc-button.component.scss +3 -0
  201. package/template/stories/argTypes/doc-button/doc-button.component.ts +233 -0
  202. package/template/stories/argTypes/doc-button/doc-button.stories.ts +24 -0
  203. package/template/stories/argTypes/doc-directive/doc-directive.directive.ts +24 -0
  204. package/template/stories/argTypes/doc-directive/doc-directive.stories.ts +14 -0
  205. package/template/stories/argTypes/doc-injectable/doc-injectable.service.ts +27 -0
  206. package/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts +17 -0
  207. package/template/stories/argTypes/doc-pipe/doc-pipe.pipe.ts +18 -0
  208. package/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts +17 -0
  209. package/template/stories/basics/README.stories.mdx +7 -0
  210. package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts +27 -0
  211. package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva.component.ts +57 -0
  212. package/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts +19 -0
  213. package/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts +8 -0
  214. package/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.ts +8 -0
  215. package/template/stories/basics/component-with-complex-selectors/class-selector.component.ts +19 -0
  216. package/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.ts +8 -0
  217. package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.ts +8 -0
  218. package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts +37 -0
  219. package/template/stories/basics/component-with-enums/enums.component.html +8 -0
  220. package/template/stories/basics/component-with-enums/enums.component.stories.ts +24 -0
  221. package/template/stories/basics/component-with-enums/enums.component.ts +53 -0
  222. package/template/stories/basics/component-with-inheritance/base-button.component.ts +10 -0
  223. package/template/stories/basics/component-with-inheritance/base-button.stories.ts +12 -0
  224. package/template/stories/basics/component-with-inheritance/icon-button.component.ts +11 -0
  225. package/template/stories/basics/component-with-inheritance/icon-button.stories.ts +13 -0
  226. package/template/stories/basics/component-with-ng-content/ng-content-about-parent.stories.ts +58 -0
  227. package/template/stories/basics/component-with-ng-content/ng-content-simple.stories.ts +29 -0
  228. package/template/stories/basics/component-with-ng-on-destroy/component-with-on-destroy.stories.ts +42 -0
  229. package/template/stories/basics/component-with-on-push/on-push-box.component.ts +21 -0
  230. package/template/stories/basics/component-with-on-push/on-push.stories.ts +21 -0
  231. package/template/stories/basics/component-with-pipe/custom-pipes.stories.ts +31 -0
  232. package/template/stories/basics/component-with-pipe/custom.pipe.ts +10 -0
  233. package/template/stories/basics/component-with-pipe/with-pipe.component.ts +10 -0
  234. package/template/stories/basics/component-with-provider/di.component.html +7 -0
  235. package/template/stories/basics/component-with-provider/di.component.stories.ts +26 -0
  236. package/template/stories/basics/component-with-provider/di.component.ts +28 -0
  237. package/template/stories/basics/component-with-style/styled.component.css +3 -0
  238. package/template/stories/basics/component-with-style/styled.component.html +5 -0
  239. package/template/stories/basics/component-with-style/styled.component.scss +5 -0
  240. package/template/stories/basics/component-with-style/styled.component.stories.ts +10 -0
  241. package/template/stories/basics/component-with-style/styled.component.ts +8 -0
  242. package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +73 -0
  243. package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +71 -0
  244. package/template/stories/basics/component-without-selector/without-selector.component.ts +30 -0
  245. package/template/stories/basics/component-without-selector/without-selector.stories.ts +30 -0
  246. package/template/stories/basics/ng-module/angular-src/chip-color.token.ts +3 -0
  247. package/template/stories/basics/ng-module/angular-src/chip-text.pipe.ts +29 -0
  248. package/template/stories/basics/ng-module/angular-src/chip.component.ts +60 -0
  249. package/template/stories/basics/ng-module/angular-src/chips-group.component.ts +49 -0
  250. package/template/stories/basics/ng-module/angular-src/chips.module.ts +31 -0
  251. package/template/stories/basics/ng-module/import-module-for-root.stories.ts +50 -0
  252. package/template/stories/basics/ng-module/import-module.stories.ts +46 -0
  253. package/template/stories/button.component.ts +26 -0
  254. package/template/stories/core/README.stories.mdx +7 -0
  255. package/template/stories/core/decorators/componentWrapperDecorator/child.component.ts +20 -0
  256. package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +117 -0
  257. package/template/stories/core/decorators/componentWrapperDecorator/parent.component.ts +18 -0
  258. package/template/stories/core/decorators/theme-decorator/decorators.stories.ts +20 -0
  259. package/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts +10 -0
  260. package/template/stories/core/moduleMetadata/angular-src/dummy.service.ts +14 -0
  261. package/template/stories/core/moduleMetadata/angular-src/service.component.ts +24 -0
  262. package/template/stories/core/moduleMetadata/angular-src/token.component.ts +31 -0
  263. package/template/stories/core/moduleMetadata/in-export-default.stories.ts +38 -0
  264. package/template/stories/core/moduleMetadata/in-stories.stories.ts +46 -0
  265. package/template/stories/core/moduleMetadata/merge-default-and-story.stories.ts +35 -0
  266. package/template/stories/core/parameters/bootstrap-options.stories.ts +22 -0
  267. package/template/stories/core/styles/story-styles.stories.ts +50 -0
  268. package/template/stories/others/issues/12009-unknown-component.stories.ts +14 -0
  269. package/template/stories/others/ngx-translate/README.stories.mdx +58 -0
@@ -0,0 +1,708 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = __importDefault(require("path"));
7
+ const node_logger_1 = require("@storybook/node-logger");
8
+ const core_1 = require("@angular-devkit/core");
9
+ const framework_preset_angular_cli_1 = require("./framework-preset-angular-cli");
10
+ const testPath = __dirname;
11
+ let workspaceRoot = testPath;
12
+ let cwdSpy;
13
+ beforeEach(() => {
14
+ cwdSpy = jest.spyOn(process, 'cwd');
15
+ jest.spyOn(node_logger_1.logger, 'error').mockImplementation();
16
+ jest.spyOn(node_logger_1.logger, 'info').mockImplementation();
17
+ });
18
+ afterEach(() => {
19
+ jest.clearAllMocks();
20
+ });
21
+ function initMockWorkspace(name) {
22
+ workspaceRoot = path_1.default.join(__dirname, '__mocks-ng-workspace__', name);
23
+ cwdSpy.mockReturnValue(workspaceRoot);
24
+ }
25
+ describe('framework-preset-angular-cli', () => {
26
+ let options;
27
+ beforeEach(() => {
28
+ options = {};
29
+ });
30
+ describe('without angular.json', () => {
31
+ let consoleErrorSpy;
32
+ beforeEach(() => {
33
+ initMockWorkspace('');
34
+ consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
35
+ });
36
+ it('should return webpack base config and display log error', async () => {
37
+ const webpackBaseConfig = newWebpackConfiguration();
38
+ const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
39
+ expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
40
+ expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not find angular workspace config (angular.json) on this path "${workspaceRoot}"`);
41
+ expect(config).toEqual(webpackBaseConfig);
42
+ });
43
+ });
44
+ describe("when angular.json haven't projects entry", () => {
45
+ beforeEach(() => {
46
+ initMockWorkspace('without-projects-entry');
47
+ });
48
+ it('should return webpack base config and display log error', async () => {
49
+ const webpackBaseConfig = newWebpackConfiguration();
50
+ const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
51
+ expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
52
+ expect(node_logger_1.logger.error).toHaveBeenCalledWith('=> Could not find angular project: No angular projects found');
53
+ expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Fail to load angular-cli config. Using base config');
54
+ expect(config).toEqual(webpackBaseConfig);
55
+ });
56
+ });
57
+ describe('when angular.json have empty projects entry', () => {
58
+ beforeEach(() => {
59
+ initMockWorkspace('empty-projects-entry');
60
+ });
61
+ it('should return webpack base config and display log error', async () => {
62
+ const webpackBaseConfig = newWebpackConfiguration();
63
+ const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
64
+ expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
65
+ expect(node_logger_1.logger.error).toHaveBeenCalledWith('=> Could not find angular project: No angular projects found');
66
+ expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Fail to load angular-cli config. Using base config');
67
+ expect(config).toEqual(webpackBaseConfig);
68
+ });
69
+ });
70
+ describe('when angular.json does not have a compatible project', () => {
71
+ beforeEach(() => {
72
+ initMockWorkspace('without-compatible-projects');
73
+ });
74
+ it('should return webpack base config and display log error', async () => {
75
+ const webpackBaseConfig = newWebpackConfiguration();
76
+ const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
77
+ expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
78
+ expect(node_logger_1.logger.error).toHaveBeenCalledWith('=> Could not find angular project: "missing-project" project is not found in angular.json');
79
+ expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Fail to load angular-cli config. Using base config');
80
+ expect(config).toEqual(webpackBaseConfig);
81
+ });
82
+ });
83
+ describe('when angular.json have projects without architect.build', () => {
84
+ beforeEach(() => {
85
+ initMockWorkspace('without-architect-build');
86
+ });
87
+ it('should return webpack base config and display log error', async () => {
88
+ const webpackBaseConfig = newWebpackConfiguration();
89
+ const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
90
+ expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
91
+ expect(node_logger_1.logger.error).toHaveBeenCalledWith('=> Could not find angular project: "build" target is not found in "foo-project" project');
92
+ expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Fail to load angular-cli config. Using base config');
93
+ expect(config).toEqual(webpackBaseConfig);
94
+ });
95
+ });
96
+ describe('when angular.json have projects without architect.build.options', () => {
97
+ beforeEach(() => {
98
+ initMockWorkspace('without-architect-build-options');
99
+ });
100
+ it('throws error', async () => {
101
+ await expect(() => (0, framework_preset_angular_cli_1.webpackFinal)(newWebpackConfiguration(), options)).rejects.toThrowError('Missing required options in project target. Check "tsConfig"');
102
+ expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not get angular cli webpack config`);
103
+ });
104
+ });
105
+ describe('when angular.json have minimal config', () => {
106
+ beforeEach(() => {
107
+ initMockWorkspace('minimal-config');
108
+ });
109
+ it('should log', async () => {
110
+ const baseWebpackConfig = newWebpackConfiguration();
111
+ await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
112
+ expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
113
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
114
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using angular project "foo-project:build" for configuring Storybook');
115
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
116
+ });
117
+ it('should extends webpack base config', async () => {
118
+ const baseWebpackConfig = newWebpackConfiguration();
119
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
120
+ expect(webpackFinalConfig).toEqual({
121
+ ...baseWebpackConfig,
122
+ module: { ...baseWebpackConfig.module, rules: expect.anything() },
123
+ plugins: expect.anything(),
124
+ resolve: {
125
+ ...baseWebpackConfig.resolve,
126
+ modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
127
+ // the base resolve.plugins are not kept 🤷‍♂️
128
+ plugins: expect.arrayContaining([
129
+ expect.objectContaining({
130
+ absoluteBaseUrl: expect.any(String),
131
+ }),
132
+ ]),
133
+ },
134
+ resolveLoader: expect.anything(),
135
+ });
136
+ });
137
+ it('should set webpack "module.rules"', async () => {
138
+ const baseWebpackConfig = newWebpackConfiguration();
139
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
140
+ const expectedRules = [
141
+ {
142
+ oneOf: [
143
+ {
144
+ exclude: [],
145
+ use: expect.anything(),
146
+ },
147
+ {
148
+ include: [],
149
+ use: expect.anything(),
150
+ },
151
+ ],
152
+ },
153
+ { use: expect.anything() },
154
+ ];
155
+ expect(webpackFinalConfig.module.rules).toEqual([
156
+ {
157
+ test: /\.(?:css)$/i,
158
+ rules: expectedRules,
159
+ },
160
+ {
161
+ test: /\.(?:scss)$/i,
162
+ rules: expectedRules,
163
+ },
164
+ {
165
+ test: /\.(?:sass)$/i,
166
+ rules: expectedRules,
167
+ },
168
+ {
169
+ test: /\.(?:less)$/i,
170
+ rules: expectedRules,
171
+ },
172
+ {
173
+ test: /\.(?:styl)$/i,
174
+ rules: expectedRules,
175
+ },
176
+ { mimetype: 'text/css', use: expect.anything() },
177
+ { mimetype: 'text/x-scss', use: expect.anything() },
178
+ { mimetype: 'text/x-sass', use: expect.anything() },
179
+ { mimetype: 'text/x-less', use: expect.anything() },
180
+ { mimetype: 'text/x-stylus', use: expect.anything() },
181
+ ...baseWebpackConfig.module.rules,
182
+ ]);
183
+ });
184
+ it('should set webpack "plugins"', async () => {
185
+ const baseWebpackConfig = newWebpackConfiguration();
186
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
187
+ expect(webpackFinalConfig.plugins).toMatchInlineSnapshot(`
188
+ Array [
189
+ AnyComponentStyleBudgetChecker {
190
+ "budgets": Array [],
191
+ },
192
+ Object {
193
+ "apply": [Function],
194
+ },
195
+ ContextReplacementPlugin {
196
+ "newContentCreateContextMap": [Function],
197
+ "newContentResource": "/Users/shilman/projects/baseline/storybook/app/angular/src/server/__mocks-ng-workspace__/minimal-config/$_lazy_route_resources",
198
+ "resourceRegExp": /\\\\@angular\\(\\\\\\\\\\|\\\\/\\)core\\(\\\\\\\\\\|\\\\/\\)/,
199
+ },
200
+ DedupeModuleResolvePlugin {
201
+ "modules": Map {},
202
+ "options": Object {
203
+ "verbose": undefined,
204
+ },
205
+ },
206
+ Object {
207
+ "keepBasePlugin": true,
208
+ },
209
+ ]
210
+ `);
211
+ });
212
+ it('should set webpack "resolve.modules"', async () => {
213
+ const baseWebpackConfig = newWebpackConfiguration();
214
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
215
+ expect(webpackFinalConfig.resolve.modules).toEqual([
216
+ ...baseWebpackConfig.resolve.modules,
217
+ (0, core_1.getSystemPath)((0, core_1.normalize)(path_1.default.join(workspaceRoot, 'src'))).replace(/\\/g, '/'),
218
+ ]);
219
+ });
220
+ it('should replace webpack "resolve.plugins"', async () => {
221
+ const baseWebpackConfig = newWebpackConfiguration();
222
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
223
+ expect(webpackFinalConfig.resolve.plugins).toMatchInlineSnapshot(`
224
+ Array [
225
+ TsconfigPathsPlugin {
226
+ "absoluteBaseUrl": "`);
227
+ });
228
+ });
229
+ describe('when angular.json have "options.styles" config', () => {
230
+ beforeEach(() => {
231
+ initMockWorkspace('with-options-styles');
232
+ });
233
+ it('should extends webpack base config', async () => {
234
+ const baseWebpackConfig = newWebpackConfiguration();
235
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
236
+ expect(webpackFinalConfig).toEqual({
237
+ ...baseWebpackConfig,
238
+ entry: [
239
+ ...baseWebpackConfig.entry,
240
+ path_1.default.join(workspaceRoot, 'src', 'styles.css'),
241
+ path_1.default.join(workspaceRoot, 'src', 'styles.scss'),
242
+ ],
243
+ module: { ...baseWebpackConfig.module, rules: expect.anything() },
244
+ plugins: expect.anything(),
245
+ resolve: {
246
+ ...baseWebpackConfig.resolve,
247
+ modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
248
+ // the base resolve.plugins are not kept 🤷‍♂️
249
+ plugins: expect.not.arrayContaining(baseWebpackConfig.resolve.plugins),
250
+ },
251
+ resolveLoader: expect.anything(),
252
+ });
253
+ });
254
+ it('should set webpack "module.rules"', async () => {
255
+ const baseWebpackConfig = newWebpackConfiguration();
256
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
257
+ const expectedRules = [
258
+ {
259
+ oneOf: [
260
+ {
261
+ exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
262
+ use: expect.anything(),
263
+ },
264
+ {
265
+ include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
266
+ use: expect.anything(),
267
+ },
268
+ ],
269
+ },
270
+ { use: expect.anything() },
271
+ ];
272
+ expect(webpackFinalConfig.module.rules).toEqual([
273
+ {
274
+ test: /\.(?:css)$/i,
275
+ rules: expectedRules,
276
+ },
277
+ {
278
+ test: /\.(?:scss)$/i,
279
+ rules: expectedRules,
280
+ },
281
+ {
282
+ test: /\.(?:sass)$/i,
283
+ rules: expectedRules,
284
+ },
285
+ {
286
+ test: /\.(?:less)$/i,
287
+ rules: expectedRules,
288
+ },
289
+ {
290
+ test: /\.(?:styl)$/i,
291
+ rules: expectedRules,
292
+ },
293
+ { mimetype: 'text/css', use: expect.anything() },
294
+ { mimetype: 'text/x-scss', use: expect.anything() },
295
+ { mimetype: 'text/x-sass', use: expect.anything() },
296
+ { mimetype: 'text/x-less', use: expect.anything() },
297
+ { mimetype: 'text/x-stylus', use: expect.anything() },
298
+ ...baseWebpackConfig.module.rules,
299
+ ]);
300
+ });
301
+ });
302
+ describe('when angular.json haven\'t "options.tsConfig" config', () => {
303
+ beforeEach(() => {
304
+ initMockWorkspace('without-tsConfig');
305
+ });
306
+ it('throws error', async () => {
307
+ await expect(() => (0, framework_preset_angular_cli_1.webpackFinal)(newWebpackConfiguration(), options)).rejects.toThrowError('Missing required options in project target. Check "tsConfig"');
308
+ expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not get angular cli webpack config`);
309
+ });
310
+ });
311
+ describe('when is a nx with angular.json', () => {
312
+ beforeEach(() => {
313
+ initMockWorkspace('with-nx');
314
+ });
315
+ it('should extends webpack base config', async () => {
316
+ const baseWebpackConfig = newWebpackConfiguration();
317
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
318
+ expect(webpackFinalConfig).toEqual({
319
+ ...baseWebpackConfig,
320
+ entry: [
321
+ ...baseWebpackConfig.entry,
322
+ path_1.default.join(workspaceRoot, 'src', 'styles.css'),
323
+ path_1.default.join(workspaceRoot, 'src', 'styles.scss'),
324
+ ],
325
+ module: { ...baseWebpackConfig.module, rules: expect.anything() },
326
+ plugins: expect.anything(),
327
+ resolve: {
328
+ ...baseWebpackConfig.resolve,
329
+ modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
330
+ // the base resolve.plugins are not kept 🤷‍♂️
331
+ plugins: expect.not.arrayContaining(baseWebpackConfig.resolve.plugins),
332
+ },
333
+ resolveLoader: expect.anything(),
334
+ });
335
+ });
336
+ it('should set webpack "module.rules"', async () => {
337
+ const baseWebpackConfig = newWebpackConfiguration();
338
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
339
+ const stylePaths = [
340
+ path_1.default.join(workspaceRoot, 'src', 'styles.css'),
341
+ path_1.default.join(workspaceRoot, 'src', 'styles.scss'),
342
+ ];
343
+ const expectedRules = [
344
+ {
345
+ oneOf: [
346
+ {
347
+ exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
348
+ use: expect.anything(),
349
+ },
350
+ {
351
+ include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
352
+ use: expect.anything(),
353
+ },
354
+ ],
355
+ },
356
+ { use: expect.anything() },
357
+ ];
358
+ expect(webpackFinalConfig.module.rules).toEqual([
359
+ {
360
+ test: /\.(?:css)$/i,
361
+ rules: expectedRules,
362
+ },
363
+ {
364
+ test: /\.(?:scss)$/i,
365
+ rules: expectedRules,
366
+ },
367
+ {
368
+ test: /\.(?:sass)$/i,
369
+ rules: expectedRules,
370
+ },
371
+ {
372
+ test: /\.(?:less)$/i,
373
+ rules: expectedRules,
374
+ },
375
+ {
376
+ test: /\.(?:styl)$/i,
377
+ rules: expectedRules,
378
+ },
379
+ { mimetype: 'text/css', use: expect.anything() },
380
+ { mimetype: 'text/x-scss', use: expect.anything() },
381
+ { mimetype: 'text/x-sass', use: expect.anything() },
382
+ { mimetype: 'text/x-less', use: expect.anything() },
383
+ { mimetype: 'text/x-stylus', use: expect.anything() },
384
+ ...baseWebpackConfig.module.rules,
385
+ ]);
386
+ });
387
+ });
388
+ describe('when is a nx with workspace.json', () => {
389
+ beforeEach(() => {
390
+ initMockWorkspace('with-nx-workspace');
391
+ });
392
+ it('should extends webpack base config', async () => {
393
+ const baseWebpackConfig = newWebpackConfiguration();
394
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
395
+ expect(webpackFinalConfig).toEqual({
396
+ ...baseWebpackConfig,
397
+ entry: [
398
+ ...baseWebpackConfig.entry,
399
+ path_1.default.join(workspaceRoot, 'src', 'styles.css'),
400
+ path_1.default.join(workspaceRoot, 'src', 'styles.scss'),
401
+ ],
402
+ module: { ...baseWebpackConfig.module, rules: expect.anything() },
403
+ plugins: expect.anything(),
404
+ resolve: {
405
+ ...baseWebpackConfig.resolve,
406
+ modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
407
+ // the base resolve.plugins are not kept 🤷‍♂️
408
+ plugins: expect.arrayContaining([
409
+ expect.objectContaining({
410
+ absoluteBaseUrl: expect.any(String),
411
+ }),
412
+ ]),
413
+ },
414
+ resolveLoader: expect.anything(),
415
+ });
416
+ });
417
+ it('should set webpack "module.rules"', async () => {
418
+ const baseWebpackConfig = newWebpackConfiguration();
419
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
420
+ const stylePaths = [
421
+ path_1.default.join(workspaceRoot, 'src', 'styles.css'),
422
+ path_1.default.join(workspaceRoot, 'src', 'styles.scss'),
423
+ ];
424
+ const expectedRules = [
425
+ {
426
+ oneOf: [
427
+ {
428
+ exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
429
+ use: expect.anything(),
430
+ },
431
+ {
432
+ include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
433
+ use: expect.anything(),
434
+ },
435
+ ],
436
+ },
437
+ { use: expect.anything() },
438
+ ];
439
+ expect(webpackFinalConfig.module.rules).toEqual([
440
+ {
441
+ test: /\.(?:css)$/i,
442
+ rules: expectedRules,
443
+ },
444
+ {
445
+ test: /\.(?:scss)$/i,
446
+ rules: expectedRules,
447
+ },
448
+ {
449
+ test: /\.(?:sass)$/i,
450
+ rules: expectedRules,
451
+ },
452
+ {
453
+ test: /\.(?:less)$/i,
454
+ rules: expectedRules,
455
+ },
456
+ {
457
+ test: /\.(?:styl)$/i,
458
+ rules: expectedRules,
459
+ },
460
+ { mimetype: 'text/css', use: expect.anything() },
461
+ { mimetype: 'text/x-scss', use: expect.anything() },
462
+ { mimetype: 'text/x-sass', use: expect.anything() },
463
+ { mimetype: 'text/x-less', use: expect.anything() },
464
+ { mimetype: 'text/x-stylus', use: expect.anything() },
465
+ ...baseWebpackConfig.module.rules,
466
+ ]);
467
+ });
468
+ });
469
+ describe('when angular.json have only one lib project', () => {
470
+ beforeEach(() => {
471
+ initMockWorkspace('with-lib');
472
+ });
473
+ it('should extends webpack base config', async () => {
474
+ const baseWebpackConfig = newWebpackConfiguration();
475
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
476
+ expect(webpackFinalConfig).toEqual({
477
+ ...baseWebpackConfig,
478
+ entry: [...baseWebpackConfig.entry],
479
+ module: { ...baseWebpackConfig.module, rules: expect.anything() },
480
+ plugins: expect.anything(),
481
+ resolve: {
482
+ ...baseWebpackConfig.resolve,
483
+ modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
484
+ // the base resolve.plugins are not kept 🤷‍♂️
485
+ plugins: expect.not.arrayContaining(baseWebpackConfig.resolve.plugins),
486
+ },
487
+ resolveLoader: expect.anything(),
488
+ });
489
+ });
490
+ it('should set webpack "module.rules"', async () => {
491
+ const baseWebpackConfig = newWebpackConfiguration();
492
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
493
+ const expectedRules = [
494
+ {
495
+ oneOf: [
496
+ {
497
+ exclude: [],
498
+ use: expect.anything(),
499
+ },
500
+ {
501
+ include: [],
502
+ use: expect.anything(),
503
+ },
504
+ ],
505
+ },
506
+ { use: expect.anything() },
507
+ ];
508
+ expect(webpackFinalConfig.module.rules).toEqual([
509
+ {
510
+ test: /\.(?:css)$/i,
511
+ rules: expectedRules,
512
+ },
513
+ {
514
+ test: /\.(?:scss)$/i,
515
+ rules: expectedRules,
516
+ },
517
+ {
518
+ test: /\.(?:sass)$/i,
519
+ rules: expectedRules,
520
+ },
521
+ {
522
+ test: /\.(?:less)$/i,
523
+ rules: expectedRules,
524
+ },
525
+ {
526
+ test: /\.(?:styl)$/i,
527
+ rules: expectedRules,
528
+ },
529
+ { mimetype: 'text/css', use: expect.anything() },
530
+ { mimetype: 'text/x-scss', use: expect.anything() },
531
+ { mimetype: 'text/x-sass', use: expect.anything() },
532
+ { mimetype: 'text/x-less', use: expect.anything() },
533
+ { mimetype: 'text/x-stylus', use: expect.anything() },
534
+ ...baseWebpackConfig.module.rules,
535
+ ]);
536
+ });
537
+ });
538
+ describe('when angular.json have some config', () => {
539
+ beforeEach(() => {
540
+ initMockWorkspace('some-config');
541
+ });
542
+ it('should log', async () => {
543
+ const baseWebpackConfig = newWebpackConfiguration();
544
+ await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
545
+ expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
546
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
547
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using angular project "foo-project:build" for configuring Storybook');
548
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
549
+ });
550
+ });
551
+ describe('with angularBrowserTarget option', () => {
552
+ beforeEach(() => {
553
+ initMockWorkspace('with-angularBrowserTarget');
554
+ options = { angularBrowserTarget: 'target-project:target-build' };
555
+ });
556
+ it('should log', async () => {
557
+ const baseWebpackConfig = newWebpackConfiguration();
558
+ await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
559
+ expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
560
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
561
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using angular project "target-project:target-build" for configuring Storybook');
562
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
563
+ });
564
+ });
565
+ describe('with angularBrowserTarget option with configuration', () => {
566
+ beforeEach(() => {
567
+ initMockWorkspace('with-angularBrowserTarget');
568
+ });
569
+ describe('when angular.json have the target without "configurations" section', () => {
570
+ beforeEach(() => {
571
+ options = {
572
+ angularBrowserTarget: 'no-confs-project:target-build:target-conf',
573
+ };
574
+ });
575
+ it('throws error', async () => {
576
+ await expect(() => (0, framework_preset_angular_cli_1.webpackFinal)(newWebpackConfiguration(), options)).rejects.toThrowError('Missing "configurations" section in project target');
577
+ expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not get angular cli webpack config`);
578
+ });
579
+ });
580
+ describe('when angular.json have the target without required configuration', () => {
581
+ beforeEach(() => {
582
+ options = {
583
+ angularBrowserTarget: 'no-target-conf-project:target-build:target-conf',
584
+ };
585
+ });
586
+ it('throws error', async () => {
587
+ await expect(() => (0, framework_preset_angular_cli_1.webpackFinal)(newWebpackConfiguration(), options)).rejects.toThrowError('Missing required configuration in project target. Check "target-conf"');
588
+ expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not get angular cli webpack config`);
589
+ });
590
+ });
591
+ describe('when angular.json have the target with required configuration', () => {
592
+ beforeEach(() => {
593
+ options = {
594
+ angularBrowserTarget: 'target-project:target-build:target-conf',
595
+ };
596
+ });
597
+ it('should log', async () => {
598
+ const baseWebpackConfig = newWebpackConfiguration();
599
+ await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
600
+ expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
601
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
602
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using angular project "target-project:target-build:target-conf" for configuring Storybook');
603
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
604
+ });
605
+ it('should extends webpack base config', async () => {
606
+ const baseWebpackConfig = newWebpackConfiguration();
607
+ const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
608
+ expect(webpackFinalConfig).toEqual({
609
+ ...baseWebpackConfig,
610
+ entry: [
611
+ ...baseWebpackConfig.entry,
612
+ path_1.default.join(workspaceRoot, 'src', 'styles.css'),
613
+ ],
614
+ module: { ...baseWebpackConfig.module, rules: expect.anything() },
615
+ plugins: expect.anything(),
616
+ resolve: {
617
+ ...baseWebpackConfig.resolve,
618
+ modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
619
+ // the base resolve.plugins are not kept 🤷‍♂️
620
+ plugins: expect.not.arrayContaining(baseWebpackConfig.resolve.plugins),
621
+ },
622
+ resolveLoader: expect.anything(),
623
+ });
624
+ });
625
+ });
626
+ });
627
+ describe('with only tsConfig option', () => {
628
+ beforeEach(() => {
629
+ initMockWorkspace('without-projects-entry');
630
+ options = {
631
+ tsConfig: 'projects/pattern-lib/tsconfig.lib.json',
632
+ angularBrowserTarget: null,
633
+ };
634
+ });
635
+ it('should log', async () => {
636
+ const baseWebpackConfig = newWebpackConfiguration();
637
+ await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
638
+ expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
639
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
640
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using default angular project with "tsConfig:projects/pattern-lib/tsconfig.lib.json"');
641
+ expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
642
+ });
643
+ });
644
+ });
645
+ const newWebpackConfiguration = (transformer = (c) => c) => {
646
+ return transformer({
647
+ name: 'preview',
648
+ mode: 'development',
649
+ bail: false,
650
+ devtool: 'cheap-module-source-map',
651
+ entry: [
652
+ '/Users/joe/storybook/lib/core-server/dist/esm/globals/polyfills.js',
653
+ '/Users/joe/storybook/examples/angular-cli/.storybook/storybook-init-framework-entry.js',
654
+ '/Users/joe/storybook/addons/docs/dist/esm/frameworks/common/config.js-generated-other-entry.js',
655
+ '/Users/joe/storybook/addons/docs/dist/esm/frameworks/angular/config.js-generated-other-entry.js',
656
+ '/Users/joe/storybook/addons/actions/dist/esm/preset/addDecorator.js-generated-other-entry.js',
657
+ '/Users/joe/storybook/addons/actions/dist/esm/preset/addArgs.js-generated-other-entry.js',
658
+ '/Users/joe/storybook/addons/links/dist/esm/preset/addDecorator.js-generated-other-entry.js',
659
+ '/Users/joe/storybook/addons/knobs/dist/esm/preset/addDecorator.js-generated-other-entry.js',
660
+ '/Users/joe/storybook/addons/backgrounds/dist/esm/preset/addDecorator.js-generated-other-entry.js',
661
+ '/Users/joe/storybook/addons/backgrounds/dist/esm/preset/addParameter.js-generated-other-entry.js',
662
+ '/Users/joe/storybook/addons/a11y/dist/esm/a11yRunner.js-generated-other-entry.js',
663
+ '/Users/joe/storybook/addons/a11y/dist/esm/a11yHighlight.js-generated-other-entry.js',
664
+ '/Users/joe/storybook/examples/angular-cli/.storybook/preview.ts-generated-config-entry.js',
665
+ '/Users/joe/storybook/examples/angular-cli/.storybook/generated-stories-entry.js',
666
+ '/Users/joe/storybook/node_modules/webpack-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined',
667
+ ],
668
+ output: {
669
+ path: '/Users/joe/storybook/examples/angular-cli/node_modules/.cache/storybook/public',
670
+ filename: '[name].[hash].bundle.js',
671
+ publicPath: '',
672
+ },
673
+ plugins: [{ keepBasePlugin: true }],
674
+ module: {
675
+ rules: [{ keepBaseRule: true }],
676
+ },
677
+ resolve: {
678
+ extensions: ['.mjs', '.js', '.jsx', '.ts', '.tsx', '.json', '.cjs'],
679
+ modules: ['node_modules'],
680
+ mainFields: ['browser', 'main'],
681
+ alias: {
682
+ '@storybook/addons': '/Users/joe/storybook/lib/addons',
683
+ '@storybook/api': '/Users/joe/storybook/lib/api',
684
+ '@storybook/channels': '/Users/joe/storybook/lib/channels',
685
+ '@storybook/channel-postmessage': '/Users/joe/storybook/lib/channel-postmessage',
686
+ '@storybook/components': '/Users/joe/storybook/ui/components',
687
+ '@storybook/core-events': '/Users/joe/storybook/lib/core-events',
688
+ '@storybook/router': '/Users/joe/storybook/lib/router',
689
+ '@storybook/theming': '/Users/joe/storybook/lib/theming',
690
+ '@storybook/client-api': '/Users/joe/storybook/lib/client-api',
691
+ '@storybook/client-logger': '/Users/joe/storybook/lib/client-logger',
692
+ react: '/Users/joe/storybook/node_modules/react',
693
+ 'react-dom': '/Users/joe/storybook/node_modules/react-dom',
694
+ },
695
+ plugins: [{ keepBasePlugin: true }],
696
+ },
697
+ resolveLoader: { plugins: [] },
698
+ optimization: {
699
+ splitChunks: { chunks: 'all' },
700
+ runtimeChunk: true,
701
+ sideEffects: true,
702
+ usedExports: true,
703
+ concatenateModules: true,
704
+ minimizer: [],
705
+ },
706
+ performance: { hints: false },
707
+ });
708
+ };