@storybook/angular 7.0.0-alpha.7 → 7.0.0-beta.0

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