@nx/react 0.0.0-pr-22179-271588f

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 (347) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/ast-utils.d.ts +1 -0
  4. package/ast-utils.js +11 -0
  5. package/babel.d.ts +20 -0
  6. package/babel.js +50 -0
  7. package/executors.json +14 -0
  8. package/generators.json +112 -0
  9. package/index.d.ts +22 -0
  10. package/index.js +47 -0
  11. package/mf/dynamic-federation.d.ts +4 -0
  12. package/mf/dynamic-federation.js +75 -0
  13. package/mf/index.d.ts +1 -0
  14. package/mf/index.js +7 -0
  15. package/migrations.json +310 -0
  16. package/module-federation.d.ts +4 -0
  17. package/module-federation.js +12 -0
  18. package/package.json +49 -0
  19. package/plugins/bundle-rollup.d.ts +1 -0
  20. package/plugins/bundle-rollup.js +47 -0
  21. package/plugins/component-testing/index.d.ts +37 -0
  22. package/plugins/component-testing/index.js +222 -0
  23. package/plugins/component-testing/webpack-fallback.d.ts +5 -0
  24. package/plugins/component-testing/webpack-fallback.js +125 -0
  25. package/plugins/jest.d.ts +1 -0
  26. package/plugins/jest.js +59 -0
  27. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +4 -0
  28. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +60 -0
  29. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +8 -0
  30. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +13 -0
  31. package/plugins/storybook/index.d.ts +3 -0
  32. package/plugins/storybook/index.js +174 -0
  33. package/plugins/storybook/merge-plugins.d.ts +3 -0
  34. package/plugins/storybook/merge-plugins.js +17 -0
  35. package/plugins/webpack.d.ts +1 -0
  36. package/plugins/webpack.js +6 -0
  37. package/plugins/with-react.d.ts +10 -0
  38. package/plugins/with-react.js +22 -0
  39. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +25 -0
  40. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +211 -0
  41. package/src/executors/module-federation-dev-server/schema.json +114 -0
  42. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +9 -0
  43. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +106 -0
  44. package/src/executors/module-federation-ssr-dev-server/schema.json +48 -0
  45. package/src/generators/application/application.d.ts +5 -0
  46. package/src/generators/application/application.js +232 -0
  47. package/src/generators/application/files/base-rspack/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
  48. package/src/generators/application/files/base-rspack/src/assets/.gitkeep +0 -0
  49. package/src/generators/application/files/base-rspack/src/favicon.ico +0 -0
  50. package/src/generators/application/files/base-rspack/src/index.html +14 -0
  51. package/src/generators/application/files/base-rspack/src/main.tsx__tmpl__ +10 -0
  52. package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +14 -0
  53. package/src/generators/application/files/base-vite/index.html__tmpl__ +16 -0
  54. package/src/generators/application/files/base-vite/public/favicon.ico +0 -0
  55. package/src/generators/application/files/base-vite/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
  56. package/src/generators/application/files/base-vite/src/assets/.gitkeep +0 -0
  57. package/src/generators/application/files/base-vite/src/environments/environment.prod.ts__tmpl__ +3 -0
  58. package/src/generators/application/files/base-vite/src/environments/environment.ts__tmpl__ +6 -0
  59. package/src/generators/application/files/base-vite/src/main.tsx__tmpl__ +10 -0
  60. package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +14 -0
  61. package/src/generators/application/files/base-webpack/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
  62. package/src/generators/application/files/base-webpack/src/assets/.gitkeep +0 -0
  63. package/src/generators/application/files/base-webpack/src/favicon.ico +0 -0
  64. package/src/generators/application/files/base-webpack/src/index.html +12 -0
  65. package/src/generators/application/files/base-webpack/src/main.tsx__tmpl__ +10 -0
  66. package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +14 -0
  67. package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +50 -0
  68. package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +886 -0
  69. package/src/generators/application/files/style-css-module/src/app/__fileName__.module.__style__ +1 -0
  70. package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +36 -0
  71. package/src/generators/application/files/style-css-module/src/styles.__style__ +1 -0
  72. package/src/generators/application/files/style-global-css/src/app/__fileName__.__style__ +1 -0
  73. package/src/generators/application/files/style-global-css/src/app/__fileName__.tsx__tmpl__ +35 -0
  74. package/src/generators/application/files/style-global-css/src/styles.__style__ +1 -0
  75. package/src/generators/application/files/style-none/src/app/__fileName__.tsx__tmpl__ +34 -0
  76. package/src/generators/application/files/style-styled-jsx/src/app/__fileName__.tsx__tmpl__ +37 -0
  77. package/src/generators/application/files/style-styled-module/src/app/__fileName__.tsx__tmpl__ +40 -0
  78. package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +33 -0
  79. package/src/generators/application/files/style-tailwind/src/styles.css +1 -0
  80. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  81. package/src/generators/application/lib/add-e2e.js +79 -0
  82. package/src/generators/application/lib/add-jest.d.ts +3 -0
  83. package/src/generators/application/lib/add-jest.js +21 -0
  84. package/src/generators/application/lib/add-project.d.ts +3 -0
  85. package/src/generators/application/lib/add-project.js +96 -0
  86. package/src/generators/application/lib/add-routing.d.ts +3 -0
  87. package/src/generators/application/lib/add-routing.js +27 -0
  88. package/src/generators/application/lib/create-application-files.d.ts +3 -0
  89. package/src/generators/application/lib/create-application-files.js +143 -0
  90. package/src/generators/application/lib/find-free-port.d.ts +2 -0
  91. package/src/generators/application/lib/find-free-port.js +16 -0
  92. package/src/generators/application/lib/get-app-tests.d.ts +2 -0
  93. package/src/generators/application/lib/get-app-tests.js +21 -0
  94. package/src/generators/application/lib/install-common-dependencies.d.ts +3 -0
  95. package/src/generators/application/lib/install-common-dependencies.js +47 -0
  96. package/src/generators/application/lib/normalize-options.d.ts +5 -0
  97. package/src/generators/application/lib/normalize-options.js +72 -0
  98. package/src/generators/application/lib/set-defaults.d.ts +3 -0
  99. package/src/generators/application/lib/set-defaults.js +43 -0
  100. package/src/generators/application/lib/show-possible-warnings.d.ts +3 -0
  101. package/src/generators/application/lib/show-possible-warnings.js +11 -0
  102. package/src/generators/application/lib/update-jest-config.d.ts +3 -0
  103. package/src/generators/application/lib/update-jest-config.js +30 -0
  104. package/src/generators/application/schema.d.ts +45 -0
  105. package/src/generators/application/schema.json +201 -0
  106. package/src/generators/component/component.d.ts +5 -0
  107. package/src/generators/component/component.js +93 -0
  108. package/src/generators/component/files/__fileName__.__style__ +0 -0
  109. package/src/generators/component/files/__fileName__.module.__style__ +7 -0
  110. package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +7 -0
  111. package/src/generators/component/files/__fileName__.tsx__tmpl__ +88 -0
  112. package/src/generators/component/lib/get-component-tests.d.ts +2 -0
  113. package/src/generators/component/lib/get-component-tests.js +12 -0
  114. package/src/generators/component/lib/normalize-options.d.ts +3 -0
  115. package/src/generators/component/lib/normalize-options.js +50 -0
  116. package/src/generators/component/schema.d.ts +48 -0
  117. package/src/generators/component/schema.json +150 -0
  118. package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +13 -0
  119. package/src/generators/component-cypress-spec/component-cypress-spec.js +100 -0
  120. package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +13 -0
  121. package/src/generators/component-cypress-spec/schema.json +44 -0
  122. package/src/generators/component-story/component-story.d.ts +12 -0
  123. package/src/generators/component-story/component-story.js +72 -0
  124. package/src/generators/component-story/files/jsx/__componentFileName__.stories.jsx__tmpl__ +29 -0
  125. package/src/generators/component-story/files/tsx/__componentFileName__.stories.tsx__tmpl__ +36 -0
  126. package/src/generators/component-story/schema.json +42 -0
  127. package/src/generators/component-test/component-test.d.ts +4 -0
  128. package/src/generators/component-test/component-test.js +76 -0
  129. package/src/generators/component-test/files/__fileName__.cy__ext__ +21 -0
  130. package/src/generators/component-test/schema.d.ts +4 -0
  131. package/src/generators/component-test/schema.js +2 -0
  132. package/src/generators/component-test/schema.json +31 -0
  133. package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +10 -0
  134. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +51 -0
  135. package/src/generators/cypress-component-configuration/lib/add-files.d.ts +4 -0
  136. package/src/generators/cypress-component-configuration/lib/add-files.js +45 -0
  137. package/src/generators/cypress-component-configuration/schema.d.ts +8 -0
  138. package/src/generators/cypress-component-configuration/schema.json +54 -0
  139. package/src/generators/federate-module/federate-module.d.ts +4 -0
  140. package/src/generators/federate-module/federate-module.js +70 -0
  141. package/src/generators/federate-module/lib/utils.d.ts +23 -0
  142. package/src/generators/federate-module/lib/utils.js +100 -0
  143. package/src/generators/federate-module/schema.d.ts +13 -0
  144. package/src/generators/federate-module/schema.json +83 -0
  145. package/src/generators/hook/files/__fileName__.spec.tsx__tmpl__ +18 -0
  146. package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -0
  147. package/src/generators/hook/hook.d.ts +5 -0
  148. package/src/generators/hook/hook.js +131 -0
  149. package/src/generators/hook/schema.d.ts +24 -0
  150. package/src/generators/hook/schema.json +84 -0
  151. package/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +33 -0
  152. package/src/generators/host/files/common/src/main.js__tmpl__ +10 -0
  153. package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +19 -0
  154. package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +41 -0
  155. package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +10 -0
  156. package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +21 -0
  157. package/src/generators/host/files/module-federation/webpack.config.js__tmpl__ +12 -0
  158. package/src/generators/host/files/module-federation/webpack.config.prod.js__tmpl__ +32 -0
  159. package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +16 -0
  160. package/src/generators/host/files/module-federation-ssr/server.ts__tmpl__ +28 -0
  161. package/src/generators/host/files/module-federation-ssr/tsconfig.server.json__tmpl__ +17 -0
  162. package/src/generators/host/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
  163. package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +13 -0
  164. package/src/generators/host/files/module-federation-ssr-ts/server.ts__tmpl__ +28 -0
  165. package/src/generators/host/files/module-federation-ssr-ts/tsconfig.server.json__tmpl__ +17 -0
  166. package/src/generators/host/files/module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +12 -0
  167. package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +25 -0
  168. package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +33 -0
  169. package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +12 -0
  170. package/src/generators/host/host.d.ts +5 -0
  171. package/src/generators/host/host.js +95 -0
  172. package/src/generators/host/lib/add-module-federation-files.d.ts +6 -0
  173. package/src/generators/host/lib/add-module-federation-files.js +52 -0
  174. package/src/generators/host/lib/normalize-remote.d.ts +4 -0
  175. package/src/generators/host/lib/normalize-remote.js +28 -0
  176. package/src/generators/host/lib/setup-ssr-for-host.d.ts +6 -0
  177. package/src/generators/host/lib/setup-ssr-for-host.js +33 -0
  178. package/src/generators/host/lib/update-module-federation-e2e-project.d.ts +3 -0
  179. package/src/generators/host/lib/update-module-federation-e2e-project.js +20 -0
  180. package/src/generators/host/schema.d.ts +37 -0
  181. package/src/generators/host/schema.json +184 -0
  182. package/src/generators/init/init.d.ts +4 -0
  183. package/src/generators/init/init.js +23 -0
  184. package/src/generators/init/schema.d.ts +5 -0
  185. package/src/generators/init/schema.json +27 -0
  186. package/src/generators/library/files/common/README.md +7 -0
  187. package/src/generators/library/files/common/package.json__tmpl__ +4 -0
  188. package/src/generators/library/files/common/src/index.ts__tmpl__ +0 -0
  189. package/src/generators/library/files/common/tsconfig.lib.json__tmpl__ +14 -0
  190. package/src/generators/library/files/vite/README.md +7 -0
  191. package/src/generators/library/files/vite/package.json__tmpl__ +12 -0
  192. package/src/generators/library/files/vite/tsconfig.lib.json__tmpl__ +14 -0
  193. package/src/generators/library/lib/add-linting.d.ts +3 -0
  194. package/src/generators/library/lib/add-linting.js +36 -0
  195. package/src/generators/library/lib/add-rollup-build-target.d.ts +4 -0
  196. package/src/generators/library/lib/add-rollup-build-target.js +59 -0
  197. package/src/generators/library/lib/create-files.d.ts +3 -0
  198. package/src/generators/library/lib/create-files.js +53 -0
  199. package/src/generators/library/lib/install-common-dependencies.d.ts +3 -0
  200. package/src/generators/library/lib/install-common-dependencies.js +47 -0
  201. package/src/generators/library/lib/normalize-options.d.ts +3 -0
  202. package/src/generators/library/lib/normalize-options.js +92 -0
  203. package/src/generators/library/lib/set-defaults.d.ts +3 -0
  204. package/src/generators/library/lib/set-defaults.js +23 -0
  205. package/src/generators/library/lib/update-app-routes.d.ts +3 -0
  206. package/src/generators/library/lib/update-app-routes.js +62 -0
  207. package/src/generators/library/library.d.ts +5 -0
  208. package/src/generators/library/library.js +193 -0
  209. package/src/generators/library/schema.d.ts +45 -0
  210. package/src/generators/library/schema.json +198 -0
  211. package/src/generators/redux/files/__fileName__.slice.spec.ts__tmpl__ +56 -0
  212. package/src/generators/redux/files/__fileName__.slice.ts__tmpl__ +129 -0
  213. package/src/generators/redux/redux.d.ts +5 -0
  214. package/src/generators/redux/redux.js +143 -0
  215. package/src/generators/redux/schema.d.ts +23 -0
  216. package/src/generators/redux/schema.json +51 -0
  217. package/src/generators/remote/files/common/src/main.js__tmpl__ +1 -0
  218. package/src/generators/remote/files/common/src/remote-entry.js__tmpl__ +1 -0
  219. package/src/generators/remote/files/common-ts/src/main.ts__tmpl__ +1 -0
  220. package/src/generators/remote/files/common-ts/src/remote-entry.ts__tmpl__ +1 -0
  221. package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +9 -0
  222. package/src/generators/remote/files/module-federation/webpack.config.js__tmpl__ +12 -0
  223. package/src/generators/remote/files/module-federation/webpack.config.prod.js__tmpl__ +1 -0
  224. package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +6 -0
  225. package/src/generators/remote/files/module-federation-ssr/server.ts__tmpl__ +45 -0
  226. package/src/generators/remote/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
  227. package/src/generators/remote/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +10 -0
  228. package/src/generators/remote/files/module-federation-ssr-ts/server.ts__tmpl__ +45 -0
  229. package/src/generators/remote/files/module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +19 -0
  230. package/src/generators/remote/files/module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +12 -0
  231. package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +13 -0
  232. package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +19 -0
  233. package/src/generators/remote/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -0
  234. package/src/generators/remote/files/module-federation-ts/webpack.config.ts__tmpl__ +12 -0
  235. package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +2 -0
  236. package/src/generators/remote/lib/add-remote-to-dynamic-host.js +11 -0
  237. package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +4 -0
  238. package/src/generators/remote/lib/setup-ssr-for-remote.js +40 -0
  239. package/src/generators/remote/lib/setup-tspath-for-remote.d.ts +3 -0
  240. package/src/generators/remote/lib/setup-tspath-for-remote.js +15 -0
  241. package/src/generators/remote/lib/update-host-with-remote.d.ts +2 -0
  242. package/src/generators/remote/lib/update-host-with-remote.js +64 -0
  243. package/src/generators/remote/remote.d.ts +7 -0
  244. package/src/generators/remote/remote.js +104 -0
  245. package/src/generators/remote/schema.d.ts +34 -0
  246. package/src/generators/remote/schema.json +183 -0
  247. package/src/generators/setup-ssr/files/server.ts__tmpl__ +28 -0
  248. package/src/generators/setup-ssr/files/src/main.server.tsx__tmpl__ +47 -0
  249. package/src/generators/setup-ssr/files/tsconfig.server.json__tmpl__ +17 -0
  250. package/src/generators/setup-ssr/schema.d.ts +7 -0
  251. package/src/generators/setup-ssr/schema.json +48 -0
  252. package/src/generators/setup-ssr/setup-ssr.d.ts +4 -0
  253. package/src/generators/setup-ssr/setup-ssr.js +183 -0
  254. package/src/generators/setup-tailwind/files/postcss.config.js__tmpl__ +15 -0
  255. package/src/generators/setup-tailwind/files/tailwind.config.js__tmpl__ +17 -0
  256. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +3 -0
  257. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +36 -0
  258. package/src/generators/setup-tailwind/lib/update-project.d.ts +3 -0
  259. package/src/generators/setup-tailwind/lib/update-project.js +13 -0
  260. package/src/generators/setup-tailwind/schema.d.ts +6 -0
  261. package/src/generators/setup-tailwind/schema.js +2 -0
  262. package/src/generators/setup-tailwind/schema.json +47 -0
  263. package/src/generators/setup-tailwind/setup-tailwind.d.ts +4 -0
  264. package/src/generators/setup-tailwind/setup-tailwind.js +35 -0
  265. package/src/generators/stories/schema.json +67 -0
  266. package/src/generators/stories/stories.d.ts +15 -0
  267. package/src/generators/stories/stories.js +130 -0
  268. package/src/generators/storybook-configuration/configuration.d.ts +6 -0
  269. package/src/generators/storybook-configuration/configuration.js +74 -0
  270. package/src/generators/storybook-configuration/schema.d.ts +16 -0
  271. package/src/generators/storybook-configuration/schema.json +95 -0
  272. package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.d.ts +3 -0
  273. package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +37 -0
  274. package/src/migrations/update-15-3-0/update-rollup-executor.d.ts +3 -0
  275. package/src/migrations/update-15-3-0/update-rollup-executor.js +15 -0
  276. package/src/migrations/update-15-6-3/webpack-config-setup.d.ts +2 -0
  277. package/src/migrations/update-15-6-3/webpack-config-setup.js +103 -0
  278. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  279. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  280. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.d.ts +2 -0
  281. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +8 -0
  282. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.d.ts +2 -0
  283. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +8 -0
  284. package/src/migrations/update-16-7-0/add-babel-core.d.ts +2 -0
  285. package/src/migrations/update-16-7-0/add-babel-core.js +14 -0
  286. package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.d.ts +2 -0
  287. package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.js +57 -0
  288. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +2 -0
  289. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +26 -0
  290. package/src/module-federation/ast-utils.d.ts +8 -0
  291. package/src/module-federation/ast-utils.js +102 -0
  292. package/src/module-federation/load-config.d.ts +3 -0
  293. package/src/module-federation/load-config.js +16 -0
  294. package/src/module-federation/models.d.ts +24 -0
  295. package/src/module-federation/models.js +2 -0
  296. package/src/module-federation/package-json.d.ts +8 -0
  297. package/src/module-federation/package-json.js +13 -0
  298. package/src/module-federation/utils.d.ts +12 -0
  299. package/src/module-federation/utils.js +76 -0
  300. package/src/module-federation/with-module-federation-ssr.d.ts +2 -0
  301. package/src/module-federation/with-module-federation-ssr.js +34 -0
  302. package/src/module-federation/with-module-federation.d.ts +7 -0
  303. package/src/module-federation/with-module-federation.js +50 -0
  304. package/src/rules/add-styled-dependencies.d.ts +5 -0
  305. package/src/rules/add-styled-dependencies.js +17 -0
  306. package/src/rules/update-module-federation-project.d.ts +9 -0
  307. package/src/rules/update-module-federation-project.js +50 -0
  308. package/src/utils/add-mf-env-to-inputs.d.ts +2 -0
  309. package/src/utils/add-mf-env-to-inputs.js +24 -0
  310. package/src/utils/assertion.d.ts +1 -0
  311. package/src/utils/assertion.js +19 -0
  312. package/src/utils/ast-utils.d.ts +29 -0
  313. package/src/utils/ast-utils.js +522 -0
  314. package/src/utils/component-props.d.ts +15 -0
  315. package/src/utils/component-props.js +60 -0
  316. package/src/utils/create-ts-config.d.ts +9 -0
  317. package/src/utils/create-ts-config.js +65 -0
  318. package/src/utils/ct-utils.d.ts +14 -0
  319. package/src/utils/ct-utils.js +94 -0
  320. package/src/utils/dependencies.d.ts +7 -0
  321. package/src/utils/dependencies.js +2 -0
  322. package/src/utils/format-file.d.ts +1 -0
  323. package/src/utils/format-file.js +12 -0
  324. package/src/utils/get-in-source-vitest-tests-template.d.ts +1 -0
  325. package/src/utils/get-in-source-vitest-tests-template.js +21 -0
  326. package/src/utils/has-vite-plugin.d.ts +2 -0
  327. package/src/utils/has-vite-plugin.js +11 -0
  328. package/src/utils/has-webpack-plugin.d.ts +2 -0
  329. package/src/utils/has-webpack-plugin.js +11 -0
  330. package/src/utils/jest-utils.d.ts +1 -0
  331. package/src/utils/jest-utils.js +9 -0
  332. package/src/utils/lint.d.ts +36 -0
  333. package/src/utils/lint.js +24 -0
  334. package/src/utils/maybe-js.d.ts +3 -0
  335. package/src/utils/maybe-js.js +9 -0
  336. package/src/utils/styled.d.ts +3 -0
  337. package/src/utils/styled.js +62 -0
  338. package/src/utils/testing-generators.d.ts +3 -0
  339. package/src/utils/testing-generators.js +30 -0
  340. package/src/utils/versions.d.ts +46 -0
  341. package/src/utils/versions.js +54 -0
  342. package/tailwind.d.ts +6 -0
  343. package/tailwind.js +29 -0
  344. package/typings/cssmodule.d.ts +19 -0
  345. package/typings/image.d.ts +48 -0
  346. package/typings/style.d.ts +9 -0
  347. package/typings/styled-jsx.d.ts +8 -0
@@ -0,0 +1,17 @@
1
+ const { createGlobPatternsForDependencies } = require('@nx/react/tailwind');
2
+ const { join } = require('path');
3
+
4
+ /** @type {import('tailwindcss').Config} */
5
+ module.exports = {
6
+ content: [
7
+ join(
8
+ __dirname,
9
+ '{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}'
10
+ ),
11
+ ...createGlobPatternsForDependencies(__dirname),
12
+ ],
13
+ theme: {
14
+ extend: {},
15
+ },
16
+ plugins: [],
17
+ };
@@ -0,0 +1,3 @@
1
+ import { ProjectConfiguration, Tree } from '@nx/devkit';
2
+ import { SetupTailwindOptions } from '../schema';
3
+ export declare function addTailwindStyleImports(tree: Tree, project: ProjectConfiguration, _options: SetupTailwindOptions): void;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addTailwindStyleImports = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const knownLocations = [
6
+ // Plain React
7
+ 'src/styles.css',
8
+ 'src/styles.scss',
9
+ 'src/styles.less',
10
+ // Next.js
11
+ 'pages/styles.css',
12
+ 'pages/styles.scss',
13
+ 'pages/styles.less',
14
+ 'app/global.css',
15
+ 'app/global.scss',
16
+ 'app/global.less',
17
+ ];
18
+ function addTailwindStyleImports(tree, project, _options) {
19
+ const candidates = knownLocations.map((x) => (0, devkit_1.joinPathFragments)(project.root, x));
20
+ const stylesPath = candidates.find((x) => tree.exists(x));
21
+ if (stylesPath) {
22
+ const content = tree.read(stylesPath).toString();
23
+ tree.write(stylesPath, `@tailwind base;\n@tailwind components;\n@tailwind utilities;\n${content}`);
24
+ }
25
+ else {
26
+ devkit_1.logger.warn((0, devkit_1.stripIndents) `
27
+ Could not find stylesheet to update. Add the following imports to your stylesheet (e.g. styles.css):
28
+
29
+ @tailwind base;
30
+ @tailwind components;
31
+ @tailwind utilities;
32
+
33
+ See our guide for more details: https://nx.dev/guides/using-tailwind-css-in-react`);
34
+ }
35
+ }
36
+ exports.addTailwindStyleImports = addTailwindStyleImports;
@@ -0,0 +1,3 @@
1
+ import type { ProjectConfiguration, Tree } from '@nx/devkit';
2
+ import { SetupTailwindOptions } from '../schema';
3
+ export declare function updateProject(tree: Tree, config: ProjectConfiguration, options: SetupTailwindOptions): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateProject = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function updateProject(tree, config, options) {
6
+ if (config?.targets?.build?.executor === '@nx/webpack:webpack' ||
7
+ config?.targets?.build?.executor === '@nrwl/webpack:webpack') {
8
+ config.targets.build.options ??= {};
9
+ config.targets.build.options.postcssConfig = (0, devkit_1.joinPathFragments)(config.root, 'postcss.config.js');
10
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, config);
11
+ }
12
+ }
13
+ exports.updateProject = updateProject;
@@ -0,0 +1,6 @@
1
+ export interface SetupTailwindOptions {
2
+ project: string;
3
+ buildTarget?: string;
4
+ skipFormat?: boolean;
5
+ skipPackageJson?: boolean;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NxReactTailwindSetupGenerator",
5
+ "title": "Configures Tailwind CSS for an application or a buildable/publishable library.",
6
+ "description": "Adds the Tailwind CSS configuration files for a given React project and installs, if needed, the packages required for Tailwind CSS to work.",
7
+ "type": "object",
8
+ "examples": [
9
+ {
10
+ "command": "nx g setup-tailwind --project=my-app",
11
+ "description": "Initialize Tailwind configuration for the `my-app` project."
12
+ }
13
+ ],
14
+ "properties": {
15
+ "project": {
16
+ "type": "string",
17
+ "description": "The name of the project to add the Tailwind CSS setup for.",
18
+ "alias": "p",
19
+ "$default": {
20
+ "$source": "argv",
21
+ "index": 0
22
+ },
23
+ "x-dropdown": "projects",
24
+ "x-prompt": "What project would you like to add the Tailwind CSS setup?",
25
+ "x-priority": "important"
26
+ },
27
+ "buildTarget": {
28
+ "type": "string",
29
+ "description": "The name of the target used to build the project. This option is not needed in most cases.",
30
+ "default": "build",
31
+ "x-priority": "important"
32
+ },
33
+ "skipFormat": {
34
+ "type": "boolean",
35
+ "description": "Skips formatting the workspace after the generator completes.",
36
+ "x-priority": "internal"
37
+ },
38
+ "skipPackageJson": {
39
+ "type": "boolean",
40
+ "default": false,
41
+ "description": "Do not add dependencies to `package.json`.",
42
+ "x-priority": "internal"
43
+ }
44
+ },
45
+ "additionalProperties": false,
46
+ "required": ["project"]
47
+ }
@@ -0,0 +1,4 @@
1
+ import type { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import type { SetupTailwindOptions } from './schema';
3
+ export declare function setupTailwindGenerator(tree: Tree, options: SetupTailwindOptions): Promise<GeneratorCallback>;
4
+ export default setupTailwindGenerator;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupTailwindGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../utils/versions");
6
+ const add_tailwind_style_imports_1 = require("./lib/add-tailwind-style-imports");
7
+ const update_project_1 = require("./lib/update-project");
8
+ const path_1 = require("path");
9
+ async function setupTailwindGenerator(tree, options) {
10
+ const tasks = [];
11
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
12
+ if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'postcss.config.js')) ||
13
+ tree.exists((0, devkit_1.joinPathFragments)(project.root, 'tailwind.config.js'))) {
14
+ devkit_1.logger.info(`Skipping setup since there are existing PostCSS or Tailwind configuration files. For manual setup instructions, see https://nx.dev/guides/using-tailwind-css-in-react.`);
15
+ return;
16
+ }
17
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, {
18
+ tmpl: '',
19
+ });
20
+ (0, add_tailwind_style_imports_1.addTailwindStyleImports)(tree, project, options);
21
+ (0, update_project_1.updateProject)(tree, project, options);
22
+ if (!options.skipPackageJson) {
23
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
24
+ autoprefixer: versions_1.autoprefixerVersion,
25
+ postcss: versions_1.postcssVersion,
26
+ tailwindcss: versions_1.tailwindcssVersion,
27
+ }));
28
+ }
29
+ if (!options.skipFormat) {
30
+ await (0, devkit_1.formatFiles)(tree);
31
+ }
32
+ return (0, devkit_1.runTasksInSerial)(...tasks);
33
+ }
34
+ exports.setupTailwindGenerator = setupTailwindGenerator;
35
+ exports.default = setupTailwindGenerator;
@@ -0,0 +1,67 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NxReactStorybookStories",
5
+ "title": "Generate React Storybook stories",
6
+ "description": "Generate stories/specs for all components declared in a project.",
7
+ "type": "object",
8
+ "properties": {
9
+ "project": {
10
+ "type": "string",
11
+ "aliases": ["name", "projectName"],
12
+ "description": "Project for which to generate stories.",
13
+ "$default": {
14
+ "$source": "projectName",
15
+ "index": 0
16
+ },
17
+ "x-prompt": "For which project do you want to generate stories?",
18
+ "x-priority": "important"
19
+ },
20
+ "generateCypressSpecs": {
21
+ "type": "boolean",
22
+ "description": "Automatically generate `*.spec.ts` files in the cypress e2e app generated by the cypress-configure generator."
23
+ },
24
+ "cypressProject": {
25
+ "type": "string",
26
+ "description": "The Cypress project to generate the stories under. This is inferred from `project` by default."
27
+ },
28
+ "interactionTests": {
29
+ "type": "boolean",
30
+ "description": "Set up Storybook interaction tests.",
31
+ "x-prompt": "Do you want to set up Storybook interaction tests?",
32
+ "x-priority": "important",
33
+ "default": true
34
+ },
35
+ "js": {
36
+ "type": "boolean",
37
+ "description": "Generate JavaScript files rather than TypeScript files.",
38
+ "default": false
39
+ },
40
+ "ignorePaths": {
41
+ "type": "array",
42
+ "description": "Paths to ignore when looking for components.",
43
+ "items": {
44
+ "type": "string",
45
+ "description": "Path to ignore."
46
+ },
47
+ "default": [
48
+ "*.stories.ts,*.stories.tsx,*.stories.js,*.stories.jsx,*.stories.mdx"
49
+ ],
50
+ "examples": [
51
+ "apps/my-app/src/not-stories/**",
52
+ "**/**/src/**/not-stories/**",
53
+ "libs/my-lib/**/*.something.ts",
54
+ "**/**/src/**/*.other.*",
55
+ "libs/my-lib/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts"
56
+ ]
57
+ },
58
+ "skipFormat": {
59
+ "description": "Skip formatting files.",
60
+ "type": "boolean",
61
+ "default": false,
62
+ "x-priority": "internal"
63
+ }
64
+ },
65
+ "required": ["project"],
66
+ "examplesFile": "../../../docs/stories-examples.md"
67
+ }
@@ -0,0 +1,15 @@
1
+ import { GeneratorCallback, ProjectConfiguration, Tree } from '@nx/devkit';
2
+ export interface StorybookStoriesSchema {
3
+ project: string;
4
+ interactionTests?: boolean;
5
+ js?: boolean;
6
+ ignorePaths?: string[];
7
+ skipFormat?: boolean;
8
+ cypressProject?: string;
9
+ generateCypressSpecs?: boolean;
10
+ }
11
+ export declare function projectRootPath(tree: Tree, config: ProjectConfiguration): Promise<string>;
12
+ export declare function containsComponentDeclaration(tree: Tree, componentPath: string): boolean;
13
+ export declare function createAllStories(tree: Tree, projectName: string, interactionTests: boolean, js: boolean, projects: Map<string, ProjectConfiguration>, projectConfiguration: ProjectConfiguration, generateCypressSpecs?: boolean, cypressProject?: string, ignorePaths?: string[]): Promise<void>;
14
+ export declare function storiesGenerator(host: Tree, schema: StorybookStoriesSchema): Promise<GeneratorCallback>;
15
+ export default storiesGenerator;
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.storiesGenerator = exports.createAllStories = exports.containsComponentDeclaration = exports.projectRootPath = void 0;
4
+ const component_story_1 = require("../component-story/component-story");
5
+ const component_cypress_spec_1 = require("../component-cypress-spec/component-cypress-spec");
6
+ const ast_utils_1 = require("../../utils/ast-utils");
7
+ const devkit_1 = require("@nx/devkit");
8
+ const path_1 = require("path");
9
+ const minimatch_1 = require("minimatch");
10
+ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
11
+ const versions_1 = require("../../utils/versions");
12
+ let tsModule;
13
+ async function projectRootPath(tree, config) {
14
+ let projectDir;
15
+ if (config.projectType === 'application') {
16
+ const isNextJs = await isNextJsProject(tree, config);
17
+ if (isNextJs) {
18
+ // Next.js apps
19
+ projectDir = 'components';
20
+ }
21
+ else {
22
+ // apps/test-app/src/app
23
+ projectDir = 'app';
24
+ }
25
+ }
26
+ else if (config.projectType == 'library') {
27
+ // libs/test-lib/src/lib
28
+ projectDir = 'lib';
29
+ }
30
+ return (0, devkit_1.joinPathFragments)(config.sourceRoot, projectDir);
31
+ }
32
+ exports.projectRootPath = projectRootPath;
33
+ function containsComponentDeclaration(tree, componentPath) {
34
+ if (!tsModule) {
35
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
36
+ }
37
+ const contents = tree.read(componentPath, 'utf-8');
38
+ if (contents === null) {
39
+ throw new Error(`Failed to read ${componentPath}`);
40
+ }
41
+ const sourceFile = tsModule.createSourceFile(componentPath, contents, tsModule.ScriptTarget.Latest, true);
42
+ return !!((0, ast_utils_1.getComponentNode)(sourceFile) ||
43
+ (0, ast_utils_1.findExportDeclarationsForJsx)(sourceFile)?.length);
44
+ }
45
+ exports.containsComponentDeclaration = containsComponentDeclaration;
46
+ async function createAllStories(tree, projectName, interactionTests, js, projects, projectConfiguration, generateCypressSpecs, cypressProject, ignorePaths) {
47
+ const { isTheFileAStory } = await Promise.resolve().then(() => require('@nx/storybook/src/utils/utilities'));
48
+ const { sourceRoot, root } = projectConfiguration;
49
+ let componentPaths = [];
50
+ const projectPath = await projectRootPath(tree, projectConfiguration);
51
+ (0, devkit_1.visitNotIgnoredFiles)(tree, projectPath, (path) => {
52
+ // Ignore private files starting with "_".
53
+ if ((0, path_1.basename)(path).startsWith('_'))
54
+ return;
55
+ if (ignorePaths?.some((pattern) => (0, minimatch_1.minimatch)(path, pattern)))
56
+ return;
57
+ if ((path.endsWith('.tsx') && !path.endsWith('.spec.tsx')) ||
58
+ (path.endsWith('.js') && !path.endsWith('.spec.js')) ||
59
+ (path.endsWith('.jsx') && !path.endsWith('.spec.jsx'))) {
60
+ // Check if file is NOT a story (either ts/tsx or js/jsx)
61
+ if (!isTheFileAStory(tree, path)) {
62
+ // Since the file is not a story
63
+ // Let's see if the .stories.* file exists
64
+ const ext = path.slice(path.lastIndexOf('.'));
65
+ const storyPath = `${path.split(ext)[0]}.stories${ext}`;
66
+ if (!tree.exists(storyPath)) {
67
+ componentPaths.push(path);
68
+ }
69
+ }
70
+ }
71
+ });
72
+ const e2eProjectName = cypressProject || `${projectName}-e2e`;
73
+ const e2eProject = projects.get(e2eProjectName);
74
+ if (generateCypressSpecs && !e2eProject) {
75
+ devkit_1.logger.info(`There was no e2e project "${e2eProjectName}" found, so cypress specs will not be generated. Pass "--cypressProject" to specify a different e2e project name`);
76
+ }
77
+ await Promise.all(componentPaths.map(async (componentPath) => {
78
+ const relativeCmpDir = componentPath.replace((0, path_1.join)(sourceRoot, '/'), '');
79
+ if (!containsComponentDeclaration(tree, componentPath)) {
80
+ return;
81
+ }
82
+ await (0, component_story_1.default)(tree, {
83
+ componentPath: relativeCmpDir,
84
+ project: projectName,
85
+ skipFormat: true,
86
+ interactionTests,
87
+ });
88
+ if (generateCypressSpecs && e2eProject) {
89
+ await (0, component_cypress_spec_1.default)(tree, {
90
+ project: projectName,
91
+ componentPath: relativeCmpDir,
92
+ js,
93
+ cypressProject,
94
+ skipFormat: true,
95
+ });
96
+ }
97
+ }));
98
+ }
99
+ exports.createAllStories = createAllStories;
100
+ async function storiesGenerator(host, schema) {
101
+ const projects = (0, devkit_1.getProjects)(host);
102
+ const projectConfiguration = projects.get(schema.project);
103
+ schema.interactionTests = schema.interactionTests ?? true;
104
+ await createAllStories(host, schema.project, schema.interactionTests, schema.js, projects, projectConfiguration, schema.generateCypressSpecs, schema.cypressProject, schema.ignorePaths);
105
+ const tasks = [];
106
+ if (schema.interactionTests) {
107
+ const { interactionTestsDependencies, addInteractionsInAddons } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
108
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, interactionTestsDependencies()));
109
+ addInteractionsInAddons(host, projectConfiguration);
110
+ }
111
+ if (!schema.skipFormat) {
112
+ await (0, devkit_1.formatFiles)(host);
113
+ }
114
+ return (0, devkit_1.runTasksInSerial)(...tasks);
115
+ }
116
+ exports.storiesGenerator = storiesGenerator;
117
+ async function isNextJsProject(tree, config) {
118
+ const { findStorybookAndBuildTargetsAndCompiler } = await Promise.resolve().then(() => require('@nx/storybook/src/utils/utilities'));
119
+ const { nextBuildTarget } = findStorybookAndBuildTargetsAndCompiler(config.targets);
120
+ if (nextBuildTarget) {
121
+ return true;
122
+ }
123
+ for (const configFile of ['next.config.js', 'next.config.ts']) {
124
+ if (tree.exists((0, path_1.join)(config.root, configFile))) {
125
+ return true;
126
+ }
127
+ }
128
+ return false;
129
+ }
130
+ exports.default = storiesGenerator;
@@ -0,0 +1,6 @@
1
+ import { StorybookConfigureSchema } from './schema';
2
+ import { Tree } from '@nx/devkit';
3
+ export declare function storybookConfigurationGenerator(host: Tree, schema: StorybookConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
4
+ export declare function storybookConfigurationGeneratorInternal(host: Tree, schema: StorybookConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
5
+ export default storybookConfigurationGenerator;
6
+ export declare function findWebpackConfig(tree: Tree, projectRoot: string): string | undefined;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findWebpackConfig = exports.storybookConfigurationGeneratorInternal = exports.storybookConfigurationGenerator = void 0;
4
+ const stories_1 = require("../stories/stories");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const versions_1 = require("../../utils/versions");
7
+ async function generateStories(host, schema) {
8
+ // TODO(katerina): Nx 19 -> remove Cypress
9
+ (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
10
+ const { getE2eProjectName } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/project-name'));
11
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(host, schema.project);
12
+ const cypressProject = getE2eProjectName(schema.project, projectConfig.root, schema.cypressDirectory);
13
+ await (0, stories_1.default)(host, {
14
+ project: schema.project,
15
+ generateCypressSpecs: schema.configureCypress && schema.generateCypressSpecs,
16
+ js: schema.js,
17
+ cypressProject,
18
+ ignorePaths: schema.ignorePaths,
19
+ skipFormat: true,
20
+ interactionTests: schema.interactionTests ?? true,
21
+ });
22
+ }
23
+ function storybookConfigurationGenerator(host, schema) {
24
+ return storybookConfigurationGeneratorInternal(host, {
25
+ addPlugin: false,
26
+ ...schema,
27
+ });
28
+ }
29
+ exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
30
+ async function storybookConfigurationGeneratorInternal(host, schema) {
31
+ const nxJson = (0, devkit_1.readNxJson)(host);
32
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
33
+ nxJson.useInferencePlugins !== false;
34
+ schema.addPlugin ??= addPluginDefault;
35
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
36
+ let uiFramework = '@storybook/react-vite';
37
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(host, schema.project);
38
+ if (findWebpackConfig(host, projectConfig.root) ||
39
+ projectConfig.targets['build']?.executor === '@nx/rollup:rollup' ||
40
+ projectConfig.targets['build']?.executor === '@nrwl/rollup:rollup' ||
41
+ projectConfig.targets['build']?.executor === '@nx/expo:build') {
42
+ uiFramework = '@storybook/react-webpack5';
43
+ }
44
+ const installTask = await configurationGenerator(host, {
45
+ project: schema.project,
46
+ configureCypress: schema.configureCypress,
47
+ js: schema.js,
48
+ linter: schema.linter,
49
+ cypressDirectory: schema.cypressDirectory,
50
+ tsConfiguration: schema.tsConfiguration ?? true, // default is true
51
+ interactionTests: schema.interactionTests ?? true, // default is true
52
+ configureStaticServe: schema.configureStaticServe,
53
+ uiFramework: uiFramework, // cannot import UiFramework type dynamically
54
+ skipFormat: true,
55
+ addPlugin: schema.addPlugin,
56
+ });
57
+ if (schema.generateStories) {
58
+ await generateStories(host, schema);
59
+ }
60
+ await (0, devkit_1.formatFiles)(host);
61
+ return installTask;
62
+ }
63
+ exports.storybookConfigurationGeneratorInternal = storybookConfigurationGeneratorInternal;
64
+ exports.default = storybookConfigurationGenerator;
65
+ function findWebpackConfig(tree, projectRoot) {
66
+ const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];
67
+ for (const ext of allowsExt) {
68
+ const webpackConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, `webpack.config.${ext}`);
69
+ if (tree.exists(webpackConfigPath)) {
70
+ return webpackConfigPath;
71
+ }
72
+ }
73
+ }
74
+ exports.findWebpackConfig = findWebpackConfig;
@@ -0,0 +1,16 @@
1
+ import { Linter } from '@nx/eslint';
2
+
3
+ export interface StorybookConfigureSchema {
4
+ project: string;
5
+ interactionTests?: boolean;
6
+ generateStories?: boolean;
7
+ js?: boolean;
8
+ tsConfiguration?: boolean;
9
+ linter?: Linter;
10
+ ignorePaths?: string[];
11
+ configureStaticServe?: boolean;
12
+ configureCypress?: boolean;
13
+ generateCypressSpecs?: boolean;
14
+ cypressDirectory?: string;
15
+ addPlugin?: boolean;
16
+ }
@@ -0,0 +1,95 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NxReactStorybookConfigure",
5
+ "title": "React Storybook Configure",
6
+ "description": "Set up Storybook for a React app or library.",
7
+ "type": "object",
8
+ "properties": {
9
+ "project": {
10
+ "type": "string",
11
+ "aliases": ["name", "projectName"],
12
+ "description": "Project for which to generate Storybook configuration.",
13
+ "$default": {
14
+ "$source": "argv",
15
+ "index": 0
16
+ },
17
+ "x-prompt": "For which project do you want to generate Storybook configuration?",
18
+ "x-dropdown": "projects",
19
+ "x-priority": "important"
20
+ },
21
+ "interactionTests": {
22
+ "type": "boolean",
23
+ "description": "Set up Storybook interaction tests.",
24
+ "x-prompt": "Do you want to set up Storybook interaction tests?",
25
+ "x-priority": "important",
26
+ "alias": ["configureTestRunner"],
27
+ "default": true
28
+ },
29
+ "configureCypress": {
30
+ "type": "boolean",
31
+ "description": "Run the cypress-configure generator.",
32
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v19."
33
+ },
34
+ "generateStories": {
35
+ "type": "boolean",
36
+ "description": "Automatically generate `*.stories.ts` files for components declared in this project?",
37
+ "x-prompt": "Automatically generate *.stories.ts files for components declared in this project?",
38
+ "default": true,
39
+ "x-priority": "important"
40
+ },
41
+ "generateCypressSpecs": {
42
+ "type": "boolean",
43
+ "description": "Automatically generate test files in the Cypress E2E app generated by the `cypress-configure` generator.",
44
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v19."
45
+ },
46
+ "configureStaticServe": {
47
+ "type": "boolean",
48
+ "description": "Specifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.",
49
+ "x-prompt": "Configure a static file server for the storybook instance?",
50
+ "default": true,
51
+ "x-priority": "important"
52
+ },
53
+ "cypressDirectory": {
54
+ "type": "string",
55
+ "description": "A directory where the Cypress project will be placed. Placed at the root by default.",
56
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v19."
57
+ },
58
+ "js": {
59
+ "type": "boolean",
60
+ "description": "Generate JavaScript story files rather than TypeScript story files.",
61
+ "default": false
62
+ },
63
+ "tsConfiguration": {
64
+ "type": "boolean",
65
+ "description": "Configure your project with TypeScript. Generate main.ts and preview.ts files, instead of main.js and preview.js.",
66
+ "default": true
67
+ },
68
+ "linter": {
69
+ "description": "The tool to use for running lint checks.",
70
+ "type": "string",
71
+ "enum": ["eslint"],
72
+ "default": "eslint"
73
+ },
74
+ "ignorePaths": {
75
+ "type": "array",
76
+ "description": "Paths to ignore when looking for components.",
77
+ "items": {
78
+ "type": "string",
79
+ "description": "Path to ignore."
80
+ },
81
+ "default": [
82
+ "*.stories.ts,*.stories.tsx,*.stories.js,*.stories.jsx,*.stories.mdx"
83
+ ],
84
+ "examples": [
85
+ "apps/my-app/src/not-stories/**",
86
+ "**/**/src/**/not-stories/**",
87
+ "libs/my-lib/**/*.something.ts",
88
+ "**/**/src/**/*.other.*",
89
+ "libs/my-lib/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts"
90
+ ]
91
+ }
92
+ },
93
+ "required": ["project"],
94
+ "examplesFile": "../../../docs/storybook-configuration-examples.md"
95
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function installWebpackRollupDependencies(tree: Tree): import("@nx/devkit").GeneratorCallback;
3
+ export default installWebpackRollupDependencies;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installWebpackRollupDependencies = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../utils/versions");
6
+ function installWebpackRollupDependencies(tree) {
7
+ const projects = (0, devkit_1.getProjects)(tree);
8
+ let shouldInstall = false;
9
+ for (const [, project] of projects) {
10
+ if (project.targets?.build?.executor === '@nrwl/webpack:webpack' ||
11
+ project.targets?.build?.executor === '@nrwl/rollup:rollup' ||
12
+ project.targets?.build?.executor === '@nrwl/web:rollup') {
13
+ shouldInstall = true;
14
+ break;
15
+ }
16
+ }
17
+ if (shouldInstall) {
18
+ // These were previously dependencies of `@nrwl/react` but we've removed them
19
+ // to accommodate different bundlers and test runners.
20
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
21
+ '@babel/preset-react': '^7.14.5',
22
+ '@pmmmwh/react-refresh-webpack-plugin': '^0.5.7',
23
+ '@svgr/webpack': '^6.1.2',
24
+ 'css-loader': '^6.4.0',
25
+ 'react-refresh': '^0.10.0',
26
+ 'style-loader': '^3.3.0',
27
+ stylus: '^0.55.0',
28
+ 'stylus-loader': '^7.1.0',
29
+ 'url-loader': '^4.1.1',
30
+ webpack: '^5.75.0',
31
+ 'webpack-merge': '^5.8.0',
32
+ '@nrwl/webpack': versions_1.nxVersion,
33
+ });
34
+ }
35
+ }
36
+ exports.installWebpackRollupDependencies = installWebpackRollupDependencies;
37
+ exports.default = installWebpackRollupDependencies;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function updateRollupExecutor(tree: Tree): void;
3
+ export default updateRollupExecutor;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateRollupExecutor = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function updateRollupExecutor(tree) {
6
+ const projects = (0, devkit_1.getProjects)(tree);
7
+ for (const [name, project] of projects) {
8
+ if (project.targets?.build?.executor === '@nrwl/web:rollup') {
9
+ project.targets.build.executor = '@nrwl/rollup:rollup';
10
+ (0, devkit_1.updateProjectConfiguration)(tree, name, project);
11
+ }
12
+ }
13
+ }
14
+ exports.updateRollupExecutor = updateRollupExecutor;
15
+ exports.default = updateRollupExecutor;