@nrwl/react 14.8.8 → 14.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/LICENSE +22 -22
- package/README.md +5 -26
- package/babel.d.ts +16 -1
- package/babel.js +4 -3
- package/babel.js.map +1 -1
- package/executors.json +10 -0
- package/generators.json +14 -0
- package/index.d.ts +4 -1
- package/index.js +8 -1
- package/index.js.map +1 -1
- package/migrations.json +160 -0
- package/module-federation.d.ts +2 -2
- package/module-federation.js +4 -4
- package/module-federation.js.map +1 -1
- package/package.json +9 -26
- package/plugins/bundle-rollup.js +20 -0
- package/plugins/bundle-rollup.js.map +1 -1
- package/plugins/component-testing/index.d.ts +13 -5
- package/plugins/component-testing/index.js +31 -44
- package/plugins/component-testing/index.js.map +1 -1
- package/plugins/component-testing/webpack-fallback.js +2 -2
- package/plugins/component-testing/webpack-fallback.js.map +1 -1
- package/plugins/jest.js +10 -6
- package/plugins/jest.js.map +1 -1
- package/plugins/storybook/index.d.ts +0 -4
- package/plugins/storybook/index.js +24 -74
- package/plugins/storybook/index.js.map +1 -1
- package/plugins/storybook/merge-plugins.d.ts +2 -2
- package/plugins/storybook/merge-plugins.js.map +1 -1
- package/plugins/webpack.d.ts +3 -2
- package/plugins/webpack.js +10 -72
- package/plugins/webpack.js.map +1 -1
- package/plugins/with-react.d.ts +12 -0
- package/plugins/with-react.js +82 -0
- package/plugins/with-react.js.map +1 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +6 -2
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +11 -7
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js.map +1 -1
- package/src/executors/module-federation-dev-server/schema.json +18 -4
- package/src/executors/module-federation-ssr-dev-server/compat.d.ts +2 -0
- package/src/executors/module-federation-ssr-dev-server/compat.js +6 -0
- package/src/executors/module-federation-ssr-dev-server/compat.js.map +1 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +9 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +71 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js.map +1 -0
- package/src/executors/module-federation-ssr-dev-server/schema.json +48 -0
- package/src/generators/application/application.js +85 -25
- package/src/generators/application/application.js.map +1 -1
- package/src/generators/application/files/base-vite/index.html__tmpl__ +16 -0
- package/src/generators/application/files/base-vite/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
- package/src/generators/application/files/{common → base-vite}/tsconfig.app.json__tmpl__ +2 -2
- package/src/generators/application/files/base-webpack/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
- package/src/generators/application/files/base-webpack/src/favicon.ico +0 -0
- package/src/generators/application/files/base-webpack/src/main.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +14 -0
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +9 -0
- package/src/generators/application/files/{common → nx-welcome}/src/app/nx-welcome.tsx +30 -8
- package/src/generators/application/files/{css-module → style-css-module}/src/app/__fileName__.tsx__tmpl__ +11 -0
- package/src/generators/application/files/{global-css → style-global-css}/src/app/__fileName__.tsx__tmpl__ +11 -0
- package/src/generators/application/files/{none → style-none}/src/app/__fileName__.tsx__tmpl__ +11 -0
- package/src/generators/application/files/{styled-jsx → style-styled-jsx}/src/app/__fileName__.tsx__tmpl__ +4 -1
- package/src/generators/application/files/{styled-module → style-styled-module}/src/app/__fileName__.tsx__tmpl__ +11 -0
- package/src/generators/application/lib/add-cypress.d.ts +1 -1
- package/src/generators/application/lib/add-cypress.js +4 -2
- package/src/generators/application/lib/add-cypress.js.map +1 -1
- package/src/generators/application/lib/add-jest.d.ts +2 -2
- package/src/generators/application/lib/add-jest.js +4 -2
- package/src/generators/application/lib/add-jest.js.map +1 -1
- package/src/generators/application/lib/add-project.js +13 -8
- package/src/generators/application/lib/add-project.js.map +1 -1
- package/src/generators/application/lib/add-routing.js +10 -3
- package/src/generators/application/lib/add-routing.js.map +1 -1
- package/src/generators/application/lib/create-application-files.d.ts +1 -1
- package/src/generators/application/lib/create-application-files.js +21 -18
- package/src/generators/application/lib/create-application-files.js.map +1 -1
- package/src/generators/application/lib/get-app-tests.d.ts +2 -0
- package/src/generators/application/lib/get-app-tests.js +22 -0
- package/src/generators/application/lib/get-app-tests.js.map +1 -0
- package/src/generators/application/lib/install-common-dependencies.d.ts +3 -0
- package/src/generators/application/lib/install-common-dependencies.js +29 -0
- package/src/generators/application/lib/install-common-dependencies.js.map +1 -0
- package/src/generators/application/lib/normalize-options.d.ts +1 -1
- package/src/generators/application/lib/normalize-options.js +28 -14
- package/src/generators/application/lib/normalize-options.js.map +1 -1
- package/src/generators/application/lib/set-defaults.js +11 -9
- package/src/generators/application/lib/set-defaults.js.map +1 -1
- package/src/generators/application/lib/update-jest-config.d.ts +1 -1
- package/src/generators/application/lib/update-jest-config.js +7 -4
- package/src/generators/application/lib/update-jest-config.js.map +1 -1
- package/src/generators/application/schema.d.ts +9 -4
- package/src/generators/application/schema.json +42 -10
- package/src/generators/component/component.js +15 -7
- package/src/generators/component/component.js.map +1 -1
- package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +1 -4
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +4 -2
- package/src/generators/component/get-component-tests.d.ts +2 -0
- package/src/generators/component/get-component-tests.js +13 -0
- package/src/generators/component/get-component-tests.js.map +1 -0
- package/src/generators/component/noramlized-schema.d.ts +8 -0
- package/src/generators/component/noramlized-schema.js +3 -0
- package/src/generators/component/noramlized-schema.js.map +1 -0
- package/src/generators/component/schema.d.ts +1 -0
- package/src/generators/component/schema.json +13 -4
- package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +1 -1
- package/src/generators/component-cypress-spec/component-cypress-spec.js +12 -5
- package/src/generators/component-cypress-spec/component-cypress-spec.js.map +1 -1
- package/src/generators/component-cypress-spec/schema.json +4 -2
- package/src/generators/component-story/component-story.d.ts +1 -1
- package/src/generators/component-story/component-story.js +6 -2
- package/src/generators/component-story/component-story.js.map +1 -1
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +6 -7
- package/src/generators/component-story/schema.json +4 -2
- package/src/generators/component-test/component-test.d.ts +1 -1
- package/src/generators/component-test/component-test.js +21 -12
- package/src/generators/component-test/component-test.js.map +1 -1
- package/src/generators/component-test/files/__fileName__.cy__ext__ +2 -3
- package/src/generators/component-test/schema.json +6 -3
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +5 -4
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js.map +1 -1
- package/src/generators/cypress-component-configuration/files/cypress/support/commands.ts__tpl__ +42 -0
- package/src/generators/cypress-component-configuration/files/cypress.config.ts__tpl__ +3 -1
- package/src/generators/cypress-component-configuration/lib/add-files.d.ts +2 -1
- package/src/generators/cypress-component-configuration/lib/add-files.js +52 -16
- package/src/generators/cypress-component-configuration/lib/add-files.js.map +1 -1
- package/src/generators/cypress-component-configuration/lib/update-configs.d.ts +6 -2
- package/src/generators/cypress-component-configuration/lib/update-configs.js +8 -4
- package/src/generators/cypress-component-configuration/lib/update-configs.js.map +1 -1
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- package/src/generators/cypress-component-configuration/schema.json +15 -4
- package/src/generators/hook/hook.js +6 -2
- package/src/generators/hook/hook.js.map +1 -1
- package/src/generators/hook/schema.json +7 -4
- package/src/generators/host/files/common/src/app/__fileName__.tsx__tmpl__ +4 -0
- package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +5 -12
- package/src/generators/host/files/module-federation/webpack.config.js__tmpl__ +7 -8
- package/src/generators/host/files/module-federation/webpack.config.prod.js__tmpl__ +11 -12
- package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +13 -0
- package/src/generators/host/files/module-federation-ssr/server.ts__tmpl__ +28 -0
- package/src/generators/host/files/module-federation-ssr/tsconfig.server.json__tmpl__ +15 -0
- package/src/generators/host/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
- package/src/generators/host/host.d.ts +2 -2
- package/src/generators/host/host.js +21 -2
- package/src/generators/host/host.js.map +1 -1
- package/src/generators/host/lib/add-module-federation-files.js +1 -1
- package/src/generators/host/lib/add-module-federation-files.js.map +1 -1
- package/src/generators/host/lib/setup-ssr-for-host.d.ts +6 -0
- package/src/generators/host/lib/setup-ssr-for-host.js +27 -0
- package/src/generators/host/lib/setup-ssr-for-host.js.map +1 -0
- package/src/generators/host/schema.d.ts +16 -14
- package/src/generators/host/schema.json +27 -8
- package/src/generators/init/init.js +45 -22
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/init/schema.d.ts +6 -1
- package/src/generators/init/schema.json +16 -0
- package/src/generators/library/files/common/src/index.ts__tmpl__ +0 -0
- package/src/generators/library/files/common/tsconfig.lib.json__tmpl__ +14 -0
- package/src/generators/library/files/vite/README.md +7 -0
- package/src/generators/library/files/vite/package.json__tmpl__ +12 -0
- package/src/generators/library/files/{lib → vite}/tsconfig.lib.json__tmpl__ +1 -1
- package/src/generators/library/lib/add-linting.d.ts +3 -0
- package/src/generators/library/lib/add-linting.js +37 -0
- package/src/generators/library/lib/add-linting.js.map +1 -0
- package/src/generators/library/lib/add-rollup-build-target.d.ts +3 -0
- package/src/generators/library/lib/add-rollup-build-target.js +59 -0
- package/src/generators/library/lib/add-rollup-build-target.js.map +1 -0
- package/src/generators/library/lib/create-files.d.ts +3 -0
- package/src/generators/library/lib/create-files.js +26 -0
- package/src/generators/library/lib/create-files.js.map +1 -0
- package/src/generators/library/lib/install-common-dependencies.d.ts +3 -0
- package/src/generators/library/lib/install-common-dependencies.js +30 -0
- package/src/generators/library/lib/install-common-dependencies.js.map +1 -0
- package/src/generators/library/lib/maybe-js.d.ts +2 -0
- package/src/generators/library/lib/maybe-js.js +10 -0
- package/src/generators/library/lib/maybe-js.js.map +1 -0
- package/src/generators/library/lib/normalize-options.d.ts +3 -0
- package/src/generators/library/lib/normalize-options.js +57 -0
- package/src/generators/library/lib/normalize-options.js.map +1 -0
- package/src/generators/library/lib/set-defaults.d.ts +3 -0
- package/src/generators/library/lib/set-defaults.js +16 -0
- package/src/generators/library/lib/set-defaults.js.map +1 -0
- package/src/generators/library/lib/update-app-routes.d.ts +3 -0
- package/src/generators/library/lib/update-app-routes.js +63 -0
- package/src/generators/library/lib/update-app-routes.js.map +1 -0
- package/src/generators/library/library.d.ts +0 -10
- package/src/generators/library/library.js +76 -214
- package/src/generators/library/library.js.map +1 -1
- package/src/generators/library/schema.d.ts +34 -16
- package/src/generators/library/schema.json +41 -10
- package/src/generators/redux/redux.js +13 -6
- package/src/generators/redux/redux.js.map +1 -1
- package/src/generators/redux/schema.json +6 -3
- package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +1 -8
- package/src/generators/remote/files/module-federation/webpack.config.js__tmpl__ +7 -8
- package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +6 -0
- package/src/generators/remote/files/module-federation-ssr/server.ts__tmpl__ +45 -0
- package/src/generators/remote/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +4 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.js +32 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.js.map +1 -0
- package/src/generators/remote/lib/update-host-with-remote.js +8 -4
- package/src/generators/remote/lib/update-host-with-remote.js.map +1 -1
- package/src/generators/remote/remote.d.ts +2 -2
- package/src/generators/remote/remote.js +20 -3
- package/src/generators/remote/remote.js.map +1 -1
- package/src/generators/remote/schema.d.ts +14 -13
- package/src/generators/remote/schema.json +22 -8
- package/src/generators/setup-ssr/files/server.ts__tmpl__ +28 -0
- package/src/generators/setup-ssr/files/src/main.server.tsx__tmpl__ +47 -0
- package/src/generators/setup-ssr/files/tsconfig.server.json__tmpl__ +15 -0
- package/src/generators/setup-ssr/schema.d.ts +7 -0
- package/src/generators/setup-ssr/schema.json +48 -0
- package/src/generators/setup-ssr/setup-ssr.d.ts +5 -0
- package/src/generators/setup-ssr/setup-ssr.js +162 -0
- package/src/generators/setup-ssr/setup-ssr.js.map +1 -0
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +2 -2
- package/src/generators/setup-tailwind/schema.json +8 -4
- package/src/generators/setup-tailwind/setup-tailwind.js +1 -2
- package/src/generators/setup-tailwind/setup-tailwind.js.map +1 -1
- package/src/generators/stories/schema.json +4 -2
- package/src/generators/stories/stories.d.ts +1 -1
- package/src/generators/stories/stories.js +29 -21
- package/src/generators/stories/stories.js.map +1 -1
- package/src/generators/storybook-configuration/configuration.d.ts +1 -1
- package/src/generators/storybook-configuration/configuration.js +24 -6
- package/src/generators/storybook-configuration/configuration.js.map +1 -1
- package/src/generators/storybook-configuration/schema.d.ts +2 -0
- package/src/generators/storybook-configuration/schema.json +25 -8
- package/src/migrations/update-13-0-0/webpack5-changes-utils.js +3 -3
- package/src/migrations/update-13-0-0/webpack5-changes-utils.js.map +1 -1
- package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js +3 -3
- package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js.map +1 -1
- package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js +1 -1
- package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js.map +1 -1
- package/src/migrations/update-14-6-0/add-preset-jest-config.js +1 -1
- package/src/migrations/update-14-6-0/add-preset-jest-config.js.map +1 -1
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.d.ts +3 -0
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +39 -0
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js.map +1 -0
- package/src/migrations/update-15-3-0/update-rollup-executor.d.ts +3 -0
- package/src/migrations/update-15-3-0/update-rollup-executor.js +17 -0
- package/src/migrations/update-15-3-0/update-rollup-executor.js.map +1 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.d.ts +2 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.js +108 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.js.map +1 -0
- package/src/module-federation/ast-utils.d.ts +1 -1
- package/src/module-federation/ast-utils.js +10 -6
- package/src/module-federation/ast-utils.js.map +1 -1
- package/src/module-federation/load-config.js +1 -1
- package/src/module-federation/load-config.js.map +1 -1
- package/src/module-federation/models.d.ts +4 -4
- package/src/module-federation/utils.d.ts +10 -0
- package/src/module-federation/utils.js +38 -0
- package/src/module-federation/utils.js.map +1 -0
- package/src/module-federation/with-module-federation-ssr.d.ts +2 -0
- package/src/module-federation/with-module-federation-ssr.js +48 -0
- package/src/module-federation/with-module-federation-ssr.js.map +1 -0
- package/src/module-federation/with-module-federation.d.ts +7 -2
- package/src/module-federation/with-module-federation.js +15 -158
- package/src/module-federation/with-module-federation.js.map +1 -1
- package/src/rules/update-module-federation-project.d.ts +2 -2
- package/src/rules/update-module-federation-project.js +2 -0
- package/src/rules/update-module-federation-project.js.map +1 -1
- package/src/utils/ast-utils.d.ts +2 -1
- package/src/utils/ast-utils.js +132 -65
- package/src/utils/ast-utils.js.map +1 -1
- package/src/utils/component-props.d.ts +1 -1
- package/src/utils/component-props.js +13 -6
- package/src/utils/component-props.js.map +1 -1
- package/src/utils/create-ts-config.d.ts +9 -0
- package/src/utils/create-ts-config.js +64 -0
- package/src/utils/create-ts-config.js.map +1 -0
- package/src/utils/get-in-source-vitest-tests-template.d.ts +1 -0
- package/src/utils/get-in-source-vitest-tests-template.js +22 -0
- package/src/utils/get-in-source-vitest-tests-template.js.map +1 -0
- package/src/utils/lint.d.ts +26 -0
- package/src/utils/lint.js +10 -1
- package/src/utils/lint.js.map +1 -1
- package/src/utils/versions.d.ts +32 -18
- package/src/utils/versions.js +36 -19
- package/src/utils/versions.js.map +1 -1
- package/tailwind.js +1 -1
- package/tailwind.js.map +1 -1
- package/src/generators/application/files/common/.browserslistrc__tmpl__ +0 -16
- package/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ +0 -26
- package/src/generators/application/files/common/src/polyfills.ts__tmpl__ +0 -7
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +0 -17
- package/src/generators/library/files/lib/tsconfig.json__tmpl__ +0 -17
- package/src/migrations/utils/rules.d.ts +0 -2
- package/src/migrations/utils/rules.js +0 -15
- package/src/migrations/utils/rules.js.map +0 -1
- package/src/migrations/utils/testing.d.ts +0 -6
- package/src/migrations/utils/testing.js +0 -76
- package/src/migrations/utils/testing.js.map +0 -1
- package/src/module-federation/webpack-utils.d.ts +0 -9
- package/src/module-federation/webpack-utils.js +0 -76
- package/src/module-federation/webpack-utils.js.map +0 -1
- package/src/utils/async-iterator.d.ts +0 -5
- package/src/utils/async-iterator.js +0 -76
- package/src/utils/async-iterator.js.map +0 -1
- /package/src/generators/application/files/{common/src → base-vite/public}/favicon.ico +0 -0
- /package/src/generators/application/files/{common → base-vite}/src/assets/.gitkeep +0 -0
- /package/src/generators/application/files/{common → base-vite}/src/environments/environment.prod.ts__tmpl__ +0 -0
- /package/src/generators/application/files/{common → base-vite}/src/environments/environment.ts__tmpl__ +0 -0
- /package/src/generators/application/files/{common → base-vite}/src/main.tsx__tmpl__ +0 -0
- /package/src/generators/application/files/{common → base-webpack}/.babelrc__tmpl__ +0 -0
- /package/src/generators/{library/files/lib/src/index.ts__tmpl__ → application/files/base-webpack/src/assets/.gitkeep} +0 -0
- /package/src/generators/application/files/{common → base-webpack}/src/index.html +0 -0
- /package/src/generators/application/files/{css-module → style-css-module}/src/app/__fileName__.module.__style__ +0 -0
- /package/src/generators/application/files/{css-module → style-css-module}/src/styles.__style__ +0 -0
- /package/src/generators/application/files/{global-css → style-global-css}/src/app/__fileName__.__style__ +0 -0
- /package/src/generators/application/files/{global-css → style-global-css}/src/styles.__style__ +0 -0
- /package/src/generators/library/files/{lib → common}/.babelrc__tmpl__ +0 -0
- /package/src/generators/library/files/{lib → common}/README.md +0 -0
- /package/src/generators/library/files/{lib → common}/package.json__tmpl__ +0 -0
|
@@ -14,13 +14,15 @@
|
|
|
14
14
|
"$source": "projectName",
|
|
15
15
|
"index": 0
|
|
16
16
|
},
|
|
17
|
-
"x-prompt": "What's name of the project for which to generate tests?"
|
|
17
|
+
"x-prompt": "What's name of the project for which to generate tests?",
|
|
18
|
+
"x-priority": "important"
|
|
18
19
|
},
|
|
19
20
|
"componentPath": {
|
|
20
21
|
"type": "string",
|
|
21
22
|
"description": "Relative path to the component file from the library root?",
|
|
22
23
|
"examples": ["lib/components"],
|
|
23
|
-
"x-prompt": "What's path of the component relative to the project's lib root for which to generate a test?"
|
|
24
|
+
"x-prompt": "What's path of the component relative to the project's lib root for which to generate a test?",
|
|
25
|
+
"x-priority": "important"
|
|
24
26
|
},
|
|
25
27
|
"js": {
|
|
26
28
|
"type": "boolean",
|
|
@@ -3,10 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.componentStorySchematic = exports.componentStoryGenerator = exports.findPropsAndGenerateFile = exports.createComponentStoriesFile = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
-
const ts = require("typescript");
|
|
7
6
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
8
7
|
const component_props_1 = require("../../utils/component-props");
|
|
8
|
+
const ensure_typescript_1 = require("@nrwl/js/src/utils/typescript/ensure-typescript");
|
|
9
|
+
let tsModule;
|
|
9
10
|
function createComponentStoriesFile(host, { project, componentPath }) {
|
|
11
|
+
if (!tsModule) {
|
|
12
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
13
|
+
}
|
|
10
14
|
const proj = (0, devkit_1.getProjects)(host).get(project);
|
|
11
15
|
const sourceRoot = proj.sourceRoot;
|
|
12
16
|
const componentFilePath = (0, devkit_1.joinPathFragments)(sourceRoot, componentPath);
|
|
@@ -29,7 +33,7 @@ function createComponentStoriesFile(host, { project, componentPath }) {
|
|
|
29
33
|
if (contents === null) {
|
|
30
34
|
throw new Error(`Failed to read ${componentFilePath}`);
|
|
31
35
|
}
|
|
32
|
-
const sourceFile =
|
|
36
|
+
const sourceFile = tsModule.createSourceFile(componentFilePath, contents, tsModule.ScriptTarget.Latest, true);
|
|
33
37
|
const cmpDeclaration = (0, ast_utils_1.getComponentNode)(sourceFile);
|
|
34
38
|
if (!cmpDeclaration) {
|
|
35
39
|
const componentNodes = (0, ast_utils_1.findExportDeclarationsForJsx)(sourceFile);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-story.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/component-story/component-story.ts"],"names":[],"mappings":";;;;AAAA,yCAQsB;
|
|
1
|
+
{"version":3,"file":"component-story.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/component-story/component-story.ts"],"names":[],"mappings":";;;;AAAA,yCAQsB;AAEtB,qDAG+B;AAC/B,iEAAsE;AACtE,uFAAmF;AAEnF,IAAI,QAAqC,CAAC;AAO1C,SAAgB,0BAA0B,CACxC,IAAU,EACV,EAAE,OAAO,EAAE,aAAa,EAAoC;IAE5D,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAA,oCAAgB,GAAE,CAAC;KAC/B;IACD,MAAM,IAAI,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IAEnC,MAAM,iBAAiB,GAAG,IAAA,0BAAiB,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAEvE,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,OAAO,CAClD,iBAAiB,CAAC,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAC3D,EAAE,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MC;AAED,kBAAe,uBAAuB,CAAC;AAC1B,QAAA,uBAAuB,GAAG,IAAA,2BAAkB,EACvD,uBAAuB,CACxB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<% if ( !isPlainJs ) { %>import {
|
|
1
|
+
<% if ( !isPlainJs ) { %>import type { Meta } from '@storybook/react';<% } %>
|
|
2
2
|
import<% if ( !isPlainJs ) { %> { <% } %> <%= componentName %> <% if ( !isPlainJs ) { %> } <% } %> from './<%= componentImportFileName %>';
|
|
3
3
|
|
|
4
4
|
<% if ( isPlainJs ) { %>
|
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
<% if ( !isPlainJs ) { %>
|
|
17
|
-
const Story:
|
|
17
|
+
const Story: Meta<typeof <%= componentName %>> = {
|
|
18
18
|
component: <%= componentName %>,
|
|
19
19
|
title: '<%= componentName %>',<% if ( argTypes && argTypes.length > 0 ) { %>
|
|
20
20
|
argTypes: {<% for (let argType of argTypes) { %>
|
|
@@ -25,9 +25,8 @@ const Story: ComponentMeta<typeof <%= componentName %>> = {
|
|
|
25
25
|
export default Story;
|
|
26
26
|
<% } %>
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
export const Primary = Template.bind({})
|
|
31
|
-
Primary.args = {<% for (let prop of props) { %>
|
|
28
|
+
export const Primary = {
|
|
29
|
+
args: {<% for (let prop of props) { %>
|
|
32
30
|
<%= prop.name %>: <%- prop.defaultValue %>,<% } %>
|
|
33
|
-
}
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
"$source": "projectName",
|
|
16
16
|
"index": 0
|
|
17
17
|
},
|
|
18
|
-
"x-prompt": "What's name of the project where the component lives?"
|
|
18
|
+
"x-prompt": "What's name of the project where the component lives?",
|
|
19
|
+
"x-priority": "important"
|
|
19
20
|
},
|
|
20
21
|
"componentPath": {
|
|
21
22
|
"type": "string",
|
|
22
23
|
"description": "Relative path to the component file from the library root.",
|
|
23
24
|
"examples": ["lib/components"],
|
|
24
|
-
"x-prompt": "What's path of the component relative to the project's lib root?"
|
|
25
|
+
"x-prompt": "What's path of the component relative to the project's lib root?",
|
|
26
|
+
"x-priority": "important"
|
|
25
27
|
}
|
|
26
28
|
},
|
|
27
29
|
"required": ["project", "componentPath"]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Tree } from '@nrwl/devkit';
|
|
2
2
|
import { ComponentTestSchema } from './schema';
|
|
3
|
-
export declare function componentTestGenerator(tree: Tree, options: ComponentTestSchema): void
|
|
3
|
+
export declare function componentTestGenerator(tree: Tree, options: ComponentTestSchema): Promise<void>;
|
|
4
4
|
export default componentTestGenerator;
|
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.componentTestGenerator = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const ts = require("typescript");
|
|
8
7
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
9
8
|
const component_props_1 = require("../../utils/component-props");
|
|
9
|
+
const versions_1 = require("../../utils/versions");
|
|
10
|
+
const ensure_typescript_1 = require("@nrwl/js/src/utils/typescript/ensure-typescript");
|
|
11
|
+
let tsModule;
|
|
10
12
|
function componentTestGenerator(tree, options) {
|
|
11
|
-
(0,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
(0, devkit_1.ensurePackage)('@nrwl/cypress', versions_1.nxVersion);
|
|
15
|
+
const { assertMinimumCypressVersion } = yield Promise.resolve().then(() => require('@nrwl/cypress/src/utils/cypress-version'));
|
|
16
|
+
assertMinimumCypressVersion(10);
|
|
17
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
18
|
+
const normalizedPath = options.componentPath.startsWith(projectConfig.sourceRoot)
|
|
19
|
+
? (0, path_1.relative)(projectConfig.sourceRoot, options.componentPath)
|
|
20
|
+
: options.componentPath;
|
|
21
|
+
const componentPath = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, normalizedPath);
|
|
22
|
+
if (tree.exists(componentPath)) {
|
|
23
|
+
generateSpecsForComponents(tree, componentPath);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
20
26
|
}
|
|
21
27
|
exports.componentTestGenerator = componentTestGenerator;
|
|
22
28
|
function generateSpecsForComponents(tree, filePath) {
|
|
23
|
-
|
|
29
|
+
if (!tsModule) {
|
|
30
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
31
|
+
}
|
|
32
|
+
const sourceFile = tsModule.createSourceFile(filePath, tree.read(filePath, 'utf-8'), tsModule.ScriptTarget.Latest, true);
|
|
24
33
|
const cmpNodes = (0, ast_utils_1.findExportDeclarationsForJsx)(sourceFile);
|
|
25
34
|
const componentDir = (0, path_1.dirname)(filePath);
|
|
26
35
|
const ext = (0, path_1.extname)(filePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-test.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/component-test/component-test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component-test.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/component-test/component-test.ts"],"names":[],"mappings":";;;;AAAA,yCAMsB;AACtB,+BAA4D;AAC5D,qDAG+B;AAC/B,iEAAsE;AACtE,mDAAiD;AAEjD,uFAAmF;AAEnF,IAAI,QAAqC,CAAC;AAE1C,SAAsB,sBAAsB,CAC1C,IAAU,EACV,OAA4B;;QAE5B,IAAA,sBAAa,EAAC,eAAe,EAAE,oBAAS,CAAC,CAAC;QAC1C,MAAM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AC,CAAC,OAAO,YAAY,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAEzD,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,0BAAiB,EAAC,SAAS,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE;YACvE,QAAQ;YACR,UAAU;YACV,eAAe,EAAE,aAAa;gBAC5B,CAAC,CAAC,UACG,aAAqB,CAAC,IAAI,CAAC,IAC9B,GAAG,oBAAoB,YAAY,QAAQ,GAAG;gBAChD,CAAC,CAAC,YAAY,YAAY,cAAc,QAAQ,GAAG;YACrD,GAAG;SACJ,CAAC,CAAC;KACJ;AACH,CAAC;AAED,kBAAe,sBAAsB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import { mount } from 'cypress/react'
|
|
3
2
|
<%- importStatement %>
|
|
4
3
|
|
|
5
4
|
<% for (let cmp of components) { %>
|
|
@@ -13,10 +12,10 @@ describe(<%= cmp.name %>.name, () => {<% if (cmp.typeName) { %>
|
|
|
13
12
|
})
|
|
14
13
|
|
|
15
14
|
it('renders', () => {
|
|
16
|
-
mount(<<%= cmp.name %> {...props}/>)
|
|
15
|
+
cy.mount(<<%= cmp.name %> {...props}/>)
|
|
17
16
|
})<% } else { %>
|
|
18
17
|
it('renders', () => {
|
|
19
|
-
mount(<<%= cmp.name %> />)
|
|
18
|
+
cy.mount(<<%= cmp.name %> />)
|
|
20
19
|
})<% } %>
|
|
21
20
|
})
|
|
22
21
|
<% } %>
|
|
@@ -16,13 +16,16 @@
|
|
|
16
16
|
"type": "string",
|
|
17
17
|
"description": "The name of the project the component is apart of",
|
|
18
18
|
"x-dropdown": "projects",
|
|
19
|
-
"x-prompt": "What project is this component apart of?"
|
|
19
|
+
"x-prompt": "What project is this component apart of?",
|
|
20
|
+
"x-priority": "important"
|
|
20
21
|
},
|
|
21
22
|
"componentPath": {
|
|
22
23
|
"type": "string",
|
|
23
24
|
"description": "Path to component, from the project source root",
|
|
24
|
-
"x-prompt": "What is the path to the component?"
|
|
25
|
+
"x-prompt": "What is the path to the component?",
|
|
26
|
+
"x-priority": "important"
|
|
25
27
|
}
|
|
26
28
|
},
|
|
27
|
-
"required": ["project", "componentPath"]
|
|
29
|
+
"required": ["project", "componentPath"],
|
|
30
|
+
"examplesFile": "../../../docs/component-test-examples.md"
|
|
28
31
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cypressComponentConfigGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const cypress_1 = require("@nrwl/cypress");
|
|
6
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
7
|
const add_files_1 = require("./lib/add-files");
|
|
8
8
|
const update_configs_1 = require("./lib/update-configs");
|
|
9
9
|
/**
|
|
@@ -13,13 +13,14 @@ const update_configs_1 = require("./lib/update-configs");
|
|
|
13
13
|
*/
|
|
14
14
|
function cypressComponentConfigGenerator(tree, options) {
|
|
15
15
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const { cypressComponentProject } = (0, devkit_1.ensurePackage)('@nrwl/cypress', versions_1.nxVersion);
|
|
16
17
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
17
|
-
const installTask = yield
|
|
18
|
+
const installTask = yield cypressComponentProject(tree, {
|
|
18
19
|
project: options.project,
|
|
19
20
|
skipFormat: true,
|
|
20
21
|
});
|
|
21
|
-
yield (0, update_configs_1.updateProjectConfig)(tree, options);
|
|
22
|
-
(0, add_files_1.addFiles)(tree, projectConfig, options);
|
|
22
|
+
const found = yield (0, update_configs_1.updateProjectConfig)(tree, options);
|
|
23
|
+
yield (0, add_files_1.addFiles)(tree, projectConfig, options, found);
|
|
23
24
|
if (options.skipFormat) {
|
|
24
25
|
yield (0, devkit_1.formatFiles)(tree);
|
|
25
26
|
}
|
package/src/generators/cypress-component-configuration/cypress-component-configuration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cypress-component-configuration.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/cypress-component-configuration/cypress-component-configuration.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"cypress-component-configuration.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/cypress-component-configuration/cypress-component-configuration.ts"],"names":[],"mappings":";;;;AAAA,yCAKsB;AACtB,mDAAiD;AACjD,+CAA2C;AAC3C,yDAAwE;AAGxE;;;;GAIG;AACH,SAAsB,+BAA+B,CACnD,IAAU,EACV,OAA4C;;QAE5C,MAAM,EAAE,uBAAuB,EAAE,GAAG,IAAA,sBAAa,EAAC,eAAe,EAAE,oBAAS,CAAC,CAAC;QAC9E,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACtE,MAAM,WAAW,GAAG,MAAM,uBAAuB,CAAC,IAAI,EAAE;YACtD,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,MAAM,KAAK,GAAgB,MAAM,IAAA,oCAAmB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpE,MAAM,IAAA,oBAAQ,EAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACpD,IAAI,OAAO,CAAC,UAAU,EAAE;YACtB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,GAAG,EAAE;YACV,WAAW,EAAE,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;CAAA;AApBD,0EAoBC;AAED,kBAAe,+BAA+B,CAAC"}
|
package/src/generators/cypress-component-configuration/files/cypress/support/commands.ts__tpl__
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
import { mount } from 'cypress/react18'
|
|
3
|
+
|
|
4
|
+
// ***********************************************
|
|
5
|
+
// This example commands.ts shows you how to
|
|
6
|
+
// create various custom commands and overwrite
|
|
7
|
+
// existing commands.
|
|
8
|
+
//
|
|
9
|
+
// For more comprehensive examples of custom
|
|
10
|
+
// commands please read more here:
|
|
11
|
+
// https://on.cypress.io/custom-commands
|
|
12
|
+
// ***********************************************
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
16
|
+
namespace Cypress {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
|
+
interface Chainable<Subject> {
|
|
19
|
+
login(email: string, password: string): void;
|
|
20
|
+
mount: typeof mount;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Cypress.Commands.add('mount', mount)
|
|
26
|
+
|
|
27
|
+
//
|
|
28
|
+
// -- This is a parent command --
|
|
29
|
+
Cypress.Commands.add('login', (email, password) => {
|
|
30
|
+
console.log('Custom command example: Login', email, password);
|
|
31
|
+
});
|
|
32
|
+
//
|
|
33
|
+
// -- This is a child command --
|
|
34
|
+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
35
|
+
//
|
|
36
|
+
//
|
|
37
|
+
// -- This is a dual command --
|
|
38
|
+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
39
|
+
//
|
|
40
|
+
//
|
|
41
|
+
// -- This will overwrite an existing command --
|
|
42
|
+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
|
@@ -2,5 +2,7 @@ import { defineConfig } from 'cypress';
|
|
|
2
2
|
import { nxComponentTestingPreset } from '@nrwl/react/plugins/component-testing';
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
|
-
component: nxComponentTestingPreset(__filename
|
|
5
|
+
component: nxComponentTestingPreset(__filename, {
|
|
6
|
+
bundler: '<%= bundler %>'
|
|
7
|
+
}),
|
|
6
8
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ProjectConfiguration, Tree } from '@nrwl/devkit';
|
|
2
2
|
import { CypressComponentConfigurationSchema } from '../schema';
|
|
3
|
-
|
|
3
|
+
import { FoundTarget } from './update-configs';
|
|
4
|
+
export declare function addFiles(tree: Tree, projectConfig: ProjectConfiguration, options: CypressComponentConfigurationSchema, found: FoundTarget): Promise<void>;
|
|
@@ -1,38 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addFiles = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
-
const
|
|
6
|
+
const versions_1 = require("nx/src/utils/versions");
|
|
6
7
|
const ast_utils_1 = require("../../../utils/ast-utils");
|
|
7
8
|
const component_test_1 = require("../../component-test/component-test");
|
|
9
|
+
const ensure_typescript_1 = require("@nrwl/js/src/utils/typescript/ensure-typescript");
|
|
10
|
+
let tsModule;
|
|
8
11
|
const allowedFileExt = new RegExp(/\.[jt]sx?/g);
|
|
9
12
|
const isSpecFile = new RegExp(/(spec|test)\./g);
|
|
10
|
-
function addFiles(tree, projectConfig, options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
function addFiles(tree, projectConfig, options, found) {
|
|
14
|
+
var _a;
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const cypressConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
|
|
17
|
+
if (tree.exists(cypressConfigPath)) {
|
|
18
|
+
tree.delete(cypressConfigPath);
|
|
19
|
+
}
|
|
20
|
+
const actualBundler = yield getBundler(found, tree);
|
|
21
|
+
if (options.bundler && options.bundler !== actualBundler) {
|
|
22
|
+
devkit_1.logger.warn(`You have specified ${options.bundler} as the bundler but this project is configured to use ${actualBundler}.
|
|
23
|
+
This may cause errors. If you are seeing errors, try removing the --bundler option.`);
|
|
24
|
+
}
|
|
25
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'), projectConfig.root, {
|
|
26
|
+
tpl: '',
|
|
27
|
+
bundler: (_a = options.bundler) !== null && _a !== void 0 ? _a : actualBundler,
|
|
28
|
+
});
|
|
29
|
+
if (options.bundler === 'webpack' ||
|
|
30
|
+
(!options.bundler && actualBundler === 'webpack')) {
|
|
31
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nrwl/webpack': versions_1.nxVersion });
|
|
32
|
+
}
|
|
33
|
+
if (options.generateTests) {
|
|
34
|
+
const filePaths = [];
|
|
35
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.sourceRoot, (filePath) => {
|
|
36
|
+
if (isComponent(tree, filePath)) {
|
|
37
|
+
filePaths.push(filePath);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
for (const filePath of filePaths) {
|
|
41
|
+
yield (0, component_test_1.componentTestGenerator)(tree, {
|
|
22
42
|
project: options.project,
|
|
23
43
|
componentPath: filePath,
|
|
24
44
|
});
|
|
25
45
|
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
28
48
|
}
|
|
29
49
|
exports.addFiles = addFiles;
|
|
50
|
+
function getBundler(found, tree) {
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (found.target && ((_a = found.config) === null || _a === void 0 ? void 0 : _a.executor)) {
|
|
54
|
+
return found.config.executor === '@nrwl/vite:build' ? 'vite' : 'webpack';
|
|
55
|
+
}
|
|
56
|
+
const { target, project } = (0, devkit_1.parseTargetString)(found.target, yield (0, devkit_1.createProjectGraphAsync)());
|
|
57
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
58
|
+
return ((_c = (_b = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.targets) === null || _b === void 0 ? void 0 : _b[target]) === null || _c === void 0 ? void 0 : _c.executor) === '@nrwl/vite:build'
|
|
59
|
+
? 'vite'
|
|
60
|
+
: 'webpack';
|
|
61
|
+
});
|
|
62
|
+
}
|
|
30
63
|
function isComponent(tree, filePath) {
|
|
64
|
+
if (!tsModule) {
|
|
65
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
66
|
+
}
|
|
31
67
|
if (isSpecFile.test(filePath) || !allowedFileExt.test(filePath)) {
|
|
32
68
|
return false;
|
|
33
69
|
}
|
|
34
70
|
const content = tree.read(filePath, 'utf-8');
|
|
35
|
-
const sourceFile =
|
|
71
|
+
const sourceFile = tsModule.createSourceFile(filePath, content, tsModule.ScriptTarget.Latest, true);
|
|
36
72
|
const cmpDeclaration = (0, ast_utils_1.getComponentNode)(sourceFile);
|
|
37
73
|
return !!cmpDeclaration;
|
|
38
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-files.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/cypress-component-configuration/lib/add-files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-files.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/cypress-component-configuration/lib/add-files.ts"],"names":[],"mappings":";;;;AAAA,yCAYsB;AACtB,oDAAkD;AAClD,wDAA4D;AAC5D,wEAA6E;AAG7E,uFAAmF;AAEnF,IAAI,QAAqC,CAAC;AAE1C,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;AAChD,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEhD,SAAsB,QAAQ,CAC5B,IAA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AO,EACP,QAAQ,CAAC,YAAY,CAAC,MAAM,EAC5B,IAAI,CACL,CAAC;IAEF,MAAM,cAAc,GAAG,IAAA,4BAAgB,EAAC,UAAU,CAAC,CAAC;IACpD,OAAO,CAAC,CAAC,cAAc,CAAC;AAC1B,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { Tree } from '@nrwl/devkit';
|
|
1
|
+
import { TargetConfiguration, Tree } from '@nrwl/devkit';
|
|
2
2
|
import { CypressComponentConfigurationSchema } from '../schema';
|
|
3
|
-
export
|
|
3
|
+
export interface FoundTarget {
|
|
4
|
+
config?: TargetConfiguration;
|
|
5
|
+
target: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function updateProjectConfig(tree: Tree, options: CypressComponentConfigurationSchema): Promise<FoundTarget>;
|
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateProjectConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const find_target_options_1 = require("@nrwl/cypress/src/utils/find-target-options");
|
|
6
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
7
6
|
function updateProjectConfig(tree, options) {
|
|
8
7
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
const
|
|
8
|
+
const { findBuildConfig } = yield Promise.resolve().then(() => require('@nrwl/cypress/src/utils/find-target-options'));
|
|
9
|
+
const found = yield findBuildConfig(tree, {
|
|
10
10
|
project: options.project,
|
|
11
11
|
buildTarget: options.buildTarget,
|
|
12
|
-
validExecutorNames: new Set([
|
|
12
|
+
validExecutorNames: new Set([
|
|
13
|
+
'@nrwl/webpack:webpack',
|
|
14
|
+
'@nrwl/vite:build',
|
|
15
|
+
]),
|
|
13
16
|
});
|
|
14
|
-
assetValidConfig(found.config);
|
|
17
|
+
assetValidConfig(found === null || found === void 0 ? void 0 : found.config);
|
|
15
18
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
16
19
|
projectConfig.targets['component-test'].options = Object.assign(Object.assign({}, projectConfig.targets['component-test'].options), { devServerTarget: found.target, skipServe: true });
|
|
17
20
|
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
21
|
+
return found;
|
|
18
22
|
});
|
|
19
23
|
}
|
|
20
24
|
exports.updateProjectConfig = updateProjectConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-configs.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/cypress-component-configuration/lib/update-configs.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"update-configs.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/cypress-component-configuration/lib/update-configs.ts"],"names":[],"mappings":";;;;AAAA,yCAKsB;AAQtB,SAAsB,mBAAmB,CACvC,IAAU,EACV,OAA4C;;QAE5C,MAAM,EAAE,eAAe,EAAE,GAAG,2CAC1B,6CAA6C,EAC9C,CAAC;QACF,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE;YACxC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,kBAAkB,EAAE,IAAI,GAAG,CAAS;gBAClC,uBAAuB;gBACvB,kBAAkB;aACnB,CAAC;SACH,CAAC,CAAC;QAEH,gBAAgB,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAC,CAAC;QAEhC,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACtE,aAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,mCAC1C,aAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,KAClD,eAAe,EAAE,KAAK,CAAC,MAAM,EAC7B,SAAS,EAAE,IAAI,GAChB,CAAC;QACF,IAAA,mCAA0B,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAEjE,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AA3BD,kDA2BC;AAED,SAAS,gBAAgB,CAAC,MAAe;IACvC,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,0IAA0I,CAC3I,CAAC;KACH;AACH,CAAC"}
|
|
@@ -20,13 +20,15 @@
|
|
|
20
20
|
"type": "string",
|
|
21
21
|
"description": "The name of the project to add cypress component testing configuration to",
|
|
22
22
|
"x-dropdown": "projects",
|
|
23
|
-
"x-prompt": "What project should we add Cypress component testing to?"
|
|
23
|
+
"x-prompt": "What project should we add Cypress component testing to?",
|
|
24
|
+
"x-priority": "important"
|
|
24
25
|
},
|
|
25
26
|
"generateTests": {
|
|
26
27
|
"type": "boolean",
|
|
27
28
|
"description": "Generate default component tests for existing components in the project",
|
|
28
29
|
"x-prompt": "Automatically generate tests for components declared in this project?",
|
|
29
|
-
"default": false
|
|
30
|
+
"default": false,
|
|
31
|
+
"x-priority": "important"
|
|
30
32
|
},
|
|
31
33
|
"buildTarget": {
|
|
32
34
|
"type": "string",
|
|
@@ -36,8 +38,17 @@
|
|
|
36
38
|
"skipFormat": {
|
|
37
39
|
"type": "boolean",
|
|
38
40
|
"description": "Skip formatting files",
|
|
39
|
-
"default": false
|
|
41
|
+
"default": false,
|
|
42
|
+
"x-priority": "internal"
|
|
43
|
+
},
|
|
44
|
+
"bundler": {
|
|
45
|
+
"description": "The bundler to use for Cypress Component Testing.",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"enum": ["vite", "webpack"],
|
|
48
|
+
"hidden": true,
|
|
49
|
+
"x-priority": "internal"
|
|
40
50
|
}
|
|
41
51
|
},
|
|
42
|
-
"required": ["project"]
|
|
52
|
+
"required": ["project"],
|
|
53
|
+
"examplesFile": "../../../docs/cypress-component-configuration-examples.md"
|
|
43
54
|
}
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.hookSchematic = exports.hookGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
// TODO(jack): Remove inline renderHook function when RTL releases with its own version
|
|
6
|
-
const ts = require("typescript");
|
|
7
6
|
const devkit_1 = require("@nrwl/devkit");
|
|
8
7
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
8
|
+
const ensure_typescript_1 = require("@nrwl/js/src/utils/typescript/ensure-typescript");
|
|
9
9
|
function hookGenerator(host, schema) {
|
|
10
10
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
11
|
const options = yield normalizeOptions(host, schema);
|
|
@@ -31,14 +31,18 @@ function createFiles(host, options) {
|
|
|
31
31
|
(0, devkit_1.toJS)(host);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
let tsModule;
|
|
34
35
|
function addExportsToBarrel(host, options) {
|
|
36
|
+
if (!tsModule) {
|
|
37
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
38
|
+
}
|
|
35
39
|
const workspace = (0, devkit_1.getProjects)(host);
|
|
36
40
|
const isApp = workspace.get(options.project).projectType === 'application';
|
|
37
41
|
if (options.export && !isApp) {
|
|
38
42
|
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
|
|
39
43
|
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
40
44
|
if (indexSource !== null) {
|
|
41
|
-
const indexSourceFile =
|
|
45
|
+
const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
|
|
42
46
|
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export * from './${options.directory}/${options.fileName}';`));
|
|
43
47
|
host.write(indexFilePath, changes);
|
|
44
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/hook/hook.ts"],"names":[],"mappings":";;;;AAAA,uFAAuF;AACvF,
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/hook/hook.ts"],"names":[],"mappings":";;;;AAAA,uFAAuF;AACvF,yCAWsB;AAGtB,qDAAkD;AAClD,uFAAmF;AASnF,SAAsB,aAAa,CAAC,IAAU,EAAE,MAAc;;QAC5D,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAErD,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3B,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAElC,OAAO,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CAAA;AAPD,sCAOC;AAED,SAAS,WAAW,CAAC,IAAU,EAAE,OAAyB;IACxD,MAAM,OAAO,GAAG,IAAA,0BAAiB,EAC/B,OAAO,CAAC,iBAAiB,EACzB,OAAO,CAAC,SAAS,CAClB,CAAC;IAEF,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,0BAAiB,EAAC,SAAS,EAAE,SAAS,CAAC,EAAE,OAAO,kCAC/D,OAAO,KACV,IAAI,EAAE,EAAE,IACR,CAAC;IAEH,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;QAClC,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,IAAI,OAAO,CAAC,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;YACjD,UAAU,GAAG,IAAI,CAAC;SACnB;QAED,IAAI,UAAU,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SACrB;KACF;IAED,IAAI,OAAO,CAAC,EAAE,EAAE;QACd,IAAA,aAAI,EAAC,IAAI,CAAC,CAAC;KACZ;AACH,CAAC;AAED,IAAI,QAAqC,CAAC;AAC1C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rB,UAAU,GAAG,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC;aACtD;YACD,MAAM,IAAI,KAAK,CACb,UAAU,CAAC,iFAAiF,IAAI,gBAAgB,UAAU,MAAM,CACjI,CAAC;SACH;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,aAAa,CAAC;AAEhB,QAAA,aAAa,GAAG,IAAA,2BAAkB,EAAC,aAAa,CAAC,CAAC"}
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"$default": {
|
|
20
20
|
"$source": "projectName"
|
|
21
21
|
},
|
|
22
|
-
"x-prompt": "What is the name of the project for this hook?"
|
|
22
|
+
"x-prompt": "What is the name of the project for this hook?",
|
|
23
|
+
"x-priority": "important"
|
|
23
24
|
},
|
|
24
25
|
"name": {
|
|
25
26
|
"type": "string",
|
|
@@ -28,7 +29,8 @@
|
|
|
28
29
|
"$source": "argv",
|
|
29
30
|
"index": 0
|
|
30
31
|
},
|
|
31
|
-
"x-prompt": "What name would you like to use for the hook?"
|
|
32
|
+
"x-prompt": "What name would you like to use for the hook?",
|
|
33
|
+
"x-priority": "important"
|
|
32
34
|
},
|
|
33
35
|
"js": {
|
|
34
36
|
"type": "boolean",
|
|
@@ -38,12 +40,13 @@
|
|
|
38
40
|
"skipTests": {
|
|
39
41
|
"type": "boolean",
|
|
40
42
|
"description": "When true, does not create `spec.ts` test files for the new hook.",
|
|
41
|
-
"default": false
|
|
43
|
+
"default": false,
|
|
44
|
+
"x-priority": "internal"
|
|
42
45
|
},
|
|
43
46
|
"directory": {
|
|
44
47
|
"type": "string",
|
|
45
48
|
"description": "Create the hook under this directory (can be nested).",
|
|
46
|
-
"
|
|
49
|
+
"x-priority": "important"
|
|
47
50
|
},
|
|
48
51
|
"flat": {
|
|
49
52
|
"type": "boolean",
|