@servicetitan/startup 38.0.0 → 38.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/js-yaml.js +2 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +32 -10
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +6 -0
- package/dist/cli/commands/bundle-package.d.ts.map +1 -0
- package/dist/cli/commands/bundle-package.js +59 -0
- package/dist/cli/commands/bundle-package.js.map +1 -0
- package/dist/cli/commands/bundle-vite.js +13 -4
- package/dist/cli/commands/bundle-vite.js.map +1 -1
- package/dist/cli/commands/bundle-webpack.js +13 -4
- package/dist/cli/commands/bundle-webpack.js.map +1 -1
- package/dist/cli/commands/clean.js +13 -4
- package/dist/cli/commands/clean.js.map +1 -1
- package/dist/cli/commands/command.d.ts +13 -0
- package/dist/cli/commands/command.d.ts.map +1 -0
- package/dist/cli/commands/command.js +74 -0
- package/dist/cli/commands/command.js.map +1 -0
- package/dist/cli/commands/convert-eslint-config.js +14 -7
- package/dist/cli/commands/convert-eslint-config.js.map +1 -1
- package/dist/cli/commands/eslint.js +13 -4
- package/dist/cli/commands/eslint.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +13 -5
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +14 -21
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/kendo-ui-license.js +13 -4
- package/dist/cli/commands/kendo-ui-license.js.map +1 -1
- package/dist/cli/commands/lint.js +13 -4
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/mfe-check.d.ts.map +1 -1
- package/dist/cli/commands/mfe-check.js +15 -7
- package/dist/cli/commands/mfe-check.js.map +1 -1
- package/dist/cli/commands/mfe-generate-metadata.js +13 -4
- package/dist/cli/commands/mfe-generate-metadata.js.map +1 -1
- package/dist/cli/commands/mfe-list.js +13 -4
- package/dist/cli/commands/mfe-list.js.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +13 -4
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +13 -4
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-package-rollback.js +13 -4
- package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
- package/dist/cli/commands/mfe-publish.js +13 -4
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/mfe-purge-cache.js +13 -4
- package/dist/cli/commands/mfe-purge-cache.js.map +1 -1
- package/dist/cli/commands/prepare-package.js +13 -4
- package/dist/cli/commands/prepare-package.js.map +1 -1
- package/dist/cli/commands/registry/build.d.ts +1 -1
- package/dist/cli/commands/registry/build.d.ts.map +1 -1
- package/dist/cli/commands/registry/build.js +3 -5
- package/dist/cli/commands/registry/build.js.map +1 -1
- package/dist/cli/commands/registry/bundle-package.d.ts +41 -0
- package/dist/cli/commands/registry/bundle-package.d.ts.map +1 -0
- package/dist/cli/commands/registry/bundle-package.js +54 -0
- package/dist/cli/commands/registry/bundle-package.js.map +1 -0
- package/dist/cli/commands/registry/command-registry.d.ts +42 -18
- package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
- package/dist/cli/commands/registry/command-registry.js +10 -19
- package/dist/cli/commands/registry/command-registry.js.map +1 -1
- package/dist/cli/commands/registry/install.d.ts +0 -16
- package/dist/cli/commands/registry/install.d.ts.map +1 -1
- package/dist/cli/commands/registry/install.js +1 -17
- package/dist/cli/commands/registry/install.js.map +1 -1
- package/dist/cli/commands/registry/start.d.ts +1 -1
- package/dist/cli/commands/registry/start.d.ts.map +1 -1
- package/dist/cli/commands/registry/start.js +3 -5
- package/dist/cli/commands/registry/start.js.map +1 -1
- package/dist/cli/commands/review/review.js +14 -7
- package/dist/cli/commands/review/review.js.map +1 -1
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js +1 -3
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js.map +1 -1
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js +1 -3
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js.map +1 -1
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js +1 -3
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js.map +1 -1
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js +5 -12
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js.map +1 -1
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js +5 -12
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js.map +1 -1
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js +1 -3
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js.map +1 -1
- package/dist/cli/commands/review/rules/require-one-collection-version.js +1 -3
- package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js +1 -3
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js.map +1 -1
- package/dist/cli/commands/review/rules/require-tsconfig-references.js +1 -3
- package/dist/cli/commands/review/rules/require-tsconfig-references.js.map +1 -1
- package/dist/cli/commands/review/utils/compare-version.js +8 -19
- package/dist/cli/commands/review/utils/compare-version.js.map +1 -1
- package/dist/cli/commands/run-task.d.ts +1 -0
- package/dist/cli/commands/run-task.d.ts.map +1 -1
- package/dist/cli/commands/run-task.js +20 -6
- package/dist/cli/commands/run-task.js.map +1 -1
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +37 -14
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/stylelint.js +13 -4
- package/dist/cli/commands/stylelint.js.map +1 -1
- package/dist/cli/commands/styles-check.js +13 -4
- package/dist/cli/commands/styles-check.js.map +1 -1
- package/dist/cli/commands/test/runners/jest.js +1 -3
- package/dist/cli/commands/test/runners/jest.js.map +1 -1
- package/dist/cli/commands/test/tests.js +13 -4
- package/dist/cli/commands/test/tests.js.map +1 -1
- package/dist/cli/commands/types.d.ts +1 -6
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/types.js +2 -20
- package/dist/cli/commands/types.js.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.js +17 -13
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/tasks/cli-task.d.ts +3 -0
- package/dist/cli/tasks/cli-task.d.ts.map +1 -1
- package/dist/cli/tasks/cli-task.js +41 -9
- package/dist/cli/tasks/cli-task.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts +9 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js +18 -2
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts +3 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.js +17 -3
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.js.map +1 -1
- package/dist/cli/tasks/task.d.ts +2 -1
- package/dist/cli/tasks/task.d.ts.map +1 -1
- package/dist/cli/tasks/task.js +6 -3
- package/dist/cli/tasks/task.js.map +1 -1
- package/dist/cli/tasks/tsc-compile/tsc-compile.js +1 -3
- package/dist/cli/tasks/tsc-compile/tsc-compile.js.map +1 -1
- package/dist/cli/utils/cli-git.d.ts +7 -0
- package/dist/cli/utils/cli-git.d.ts.map +1 -1
- package/dist/cli/utils/cli-git.js +30 -0
- package/dist/cli/utils/cli-git.js.map +1 -1
- package/dist/cli/utils/cli-npm.d.ts.map +1 -1
- package/dist/cli/utils/cli-npm.js +8 -1
- package/dist/cli/utils/cli-npm.js.map +1 -1
- package/dist/cli/utils/cli-os.d.ts +7 -1
- package/dist/cli/utils/cli-os.d.ts.map +1 -1
- package/dist/cli/utils/cli-os.js +42 -0
- package/dist/cli/utils/cli-os.js.map +1 -1
- package/dist/cli/utils/compile.d.ts.map +1 -1
- package/dist/cli/utils/compile.js +7 -4
- package/dist/cli/utils/compile.js.map +1 -1
- package/dist/cli/utils/copy-files.js +1 -0
- package/dist/cli/utils/copy-files.js.map +1 -1
- package/dist/cli/utils/index.d.ts +1 -1
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +1 -1
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/process-tree.js +2 -6
- package/dist/cli/utils/process-tree.js.map +1 -1
- package/dist/cli/utils/resolve-bundler.d.ts.map +1 -1
- package/dist/cli/utils/resolve-bundler.js +2 -1
- package/dist/cli/utils/resolve-bundler.js.map +1 -1
- package/dist/cli/utils/ts-config.d.ts +1 -1
- package/dist/cli/utils/ts-config.d.ts.map +1 -1
- package/dist/cli/utils/ts-config.js +1 -3
- package/dist/cli/utils/ts-config.js.map +1 -1
- package/dist/cli/utils/with-exponential-backoff.d.ts +7 -0
- package/dist/cli/utils/with-exponential-backoff.d.ts.map +1 -0
- package/dist/cli/utils/with-exponential-backoff.js +28 -0
- package/dist/cli/utils/with-exponential-backoff.js.map +1 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +6 -1
- package/dist/core/constants.js.map +1 -1
- package/dist/postinstall.js +118 -0
- package/dist/scripts/generate-bin-wrappers.js +203 -0
- package/dist/storybook-config/swc.d.ts +6 -0
- package/dist/storybook-config/swc.d.ts.map +1 -1
- package/dist/storybook-config/webpack-final.d.ts.map +1 -1
- package/dist/storybook-config/webpack-final.js +2 -1
- package/dist/storybook-config/webpack-final.js.map +1 -1
- package/dist/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +21 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/telemetry.d.ts +15 -0
- package/dist/telemetry/telemetry.d.ts.map +1 -0
- package/dist/telemetry/telemetry.js +176 -0
- package/dist/telemetry/telemetry.js.map +1 -0
- package/dist/utils/exit-when-parent-exits.d.ts +6 -0
- package/dist/utils/exit-when-parent-exits.d.ts.map +1 -0
- package/dist/utils/exit-when-parent-exits.js +37 -0
- package/dist/utils/exit-when-parent-exits.js.map +1 -0
- package/dist/utils/find-up.d.ts +1 -1
- package/dist/utils/find-up.d.ts.map +1 -1
- package/dist/utils/find-up.js +2 -2
- package/dist/utils/find-up.js.map +1 -1
- package/dist/utils/get-configuration.d.ts +6 -3
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +10 -2
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/log.js +1 -3
- package/dist/utils/log.js.map +1 -1
- package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
- package/dist/vite/build-shared-dependencies.js +2 -0
- package/dist/vite/build-shared-dependencies.js.map +1 -1
- package/dist/vite/config/base-config.d.ts.map +1 -1
- package/dist/vite/config/base-config.js +12 -1
- package/dist/vite/config/base-config.js.map +1 -1
- package/dist/vite/config/create-filtering-logger.d.ts.map +1 -1
- package/dist/vite/config/create-filtering-logger.js +6 -2
- package/dist/vite/config/create-filtering-logger.js.map +1 -1
- package/dist/vite/config/create-vite-config.js +7 -2
- package/dist/vite/config/create-vite-config.js.map +1 -1
- package/dist/vite/config/load-config-file.js +8 -19
- package/dist/vite/config/load-config-file.js.map +1 -1
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.html +2 -2
- package/dist/vite/index.js +16 -0
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugins/chain-source-maps-plugin.js +1 -1
- package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -1
- package/dist/vite/plugins/clean-plugin.js +1 -1
- package/dist/vite/plugins/clean-plugin.js.map +1 -1
- package/dist/vite/plugins/css-injector-plugin.js +1 -1
- package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
- package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/design-system-guard-plugin.js +10 -5
- package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.js +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.js.map +1 -1
- package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/externals-plugin.js +11 -5
- package/dist/vite/plugins/externals-plugin.js.map +1 -1
- package/dist/vite/plugins/html-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/html-plugin.js +5 -3
- package/dist/vite/plugins/html-plugin.js.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.d.ts +2 -2
- package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.js +36 -24
- package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/index.d.ts +3 -0
- package/dist/vite/plugins/index.d.ts.map +1 -1
- package/dist/vite/plugins/index.js +3 -0
- package/dist/vite/plugins/index.js.map +1 -1
- package/dist/vite/plugins/less-tilde-plugin.d.ts +8 -0
- package/dist/vite/plugins/less-tilde-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/less-tilde-plugin.js +53 -0
- package/dist/vite/plugins/less-tilde-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +1 -1
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -1
- package/dist/vite/plugins/metadata-plugin.js +1 -1
- package/dist/vite/plugins/metadata-plugin.js.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.js +30 -14
- package/dist/vite/plugins/moment-locales-plugin.js.map +1 -1
- package/dist/vite/plugins/react-refresh-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/react-refresh-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/index.js +20 -0
- package/dist/vite/plugins/react-refresh-plugin/index.js.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts +4 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js +143 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js +14 -11
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -1
- package/dist/vite/plugins/style-urls-plugin.js +1 -1
- package/dist/vite/plugins/style-urls-plugin.js.map +1 -1
- package/dist/vite/plugins/virtual-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/virtual-modules-plugin.js +9 -6
- package/dist/vite/plugins/virtual-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/window-externals-plugin.d.ts +22 -0
- package/dist/vite/plugins/window-externals-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/window-externals-plugin.js +74 -0
- package/dist/vite/plugins/window-externals-plugin.js.map +1 -0
- package/dist/webpack/bundle-webpack.d.ts.map +1 -1
- package/dist/webpack/bundle-webpack.js +6 -1
- package/dist/webpack/bundle-webpack.js.map +1 -1
- package/dist/webpack/configs/optimization-config.js +17 -12
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.js +1 -1
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +1 -3
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
- package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/configuration.expose-loader.js +13 -0
- package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/index.js +1 -0
- package/dist/webpack/utils/index.d.ts +1 -0
- package/dist/webpack/utils/index.d.ts.map +1 -1
- package/dist/webpack/utils/index.js +1 -0
- package/dist/webpack/utils/index.js.map +1 -1
- package/dist/webpack/utils/normalize-proxy-config.d.ts +6 -0
- package/dist/webpack/utils/normalize-proxy-config.d.ts.map +1 -0
- package/dist/webpack/utils/normalize-proxy-config.js +52 -0
- package/dist/webpack/utils/normalize-proxy-config.js.map +1 -0
- package/package.json +32 -26
- package/src/cli/commands/__tests__/build.test.ts +81 -20
- package/src/cli/commands/__tests__/bundle-package.test.ts +65 -0
- package/src/cli/commands/__tests__/command.test.ts +154 -0
- package/src/cli/commands/__tests__/init.test.ts +1 -1
- package/src/cli/commands/__tests__/install.test.ts +5 -72
- package/src/cli/commands/__tests__/mfe-check.test.ts +26 -5
- package/src/cli/commands/__tests__/run-task.test.ts +20 -1
- package/src/cli/commands/__tests__/start.test.ts +77 -16
- package/src/cli/commands/build.ts +15 -6
- package/src/cli/commands/bundle-package.ts +20 -0
- package/src/cli/commands/command.ts +64 -0
- package/src/cli/commands/init.ts +0 -1
- package/src/cli/commands/install.ts +5 -21
- package/src/cli/commands/mfe-check.ts +6 -10
- package/src/cli/commands/registry/build.ts +3 -2
- package/src/cli/commands/registry/bundle-package.ts +22 -0
- package/src/cli/commands/registry/command-registry.ts +2 -0
- package/src/cli/commands/registry/install.ts +1 -6
- package/src/cli/commands/registry/start.ts +3 -2
- package/src/cli/commands/run-task.ts +8 -2
- package/src/cli/commands/start.ts +17 -6
- package/src/cli/commands/types.ts +2 -6
- package/src/cli/index.ts +3 -0
- package/src/cli/tasks/__tests__/cli-task.test.ts +181 -69
- package/src/cli/tasks/__tests__/task.test.ts +40 -45
- package/src/cli/tasks/cli-task.ts +43 -2
- package/src/cli/tasks/swc-compile-package/__tests__/get-swc-options.test.ts +46 -4
- package/src/cli/tasks/swc-compile-package/__tests__/swc-compile-package.test.ts +25 -4
- package/src/cli/tasks/swc-compile-package/get-swc-options.ts +14 -1
- package/src/cli/tasks/swc-compile-package/swc-compile-package.ts +6 -2
- package/src/cli/tasks/task.ts +8 -2
- package/src/cli/tasks/tsc-compile/__tests__/tsc-compile.test.ts +8 -32
- package/src/cli/tasks/tsc-compile-package/__tests__/tsc-compile-package.test.ts +10 -19
- package/src/cli/utils/__tests__/cli-git.test.ts +54 -3
- package/src/cli/utils/__tests__/cli-npm.test.ts +33 -0
- package/src/cli/utils/__tests__/cli-os.test.ts +183 -4
- package/src/cli/utils/__tests__/compile.test.ts +37 -2
- package/src/cli/utils/__tests__/copy-files.test.ts +1 -1
- package/src/cli/utils/__tests__/with-exponential-backoff.test.ts +119 -0
- package/src/cli/utils/cli-git.ts +27 -1
- package/src/cli/utils/cli-npm.ts +19 -4
- package/src/cli/utils/cli-os.ts +44 -0
- package/src/cli/utils/compile.ts +8 -1
- package/src/cli/utils/copy-files.ts +1 -1
- package/src/cli/utils/index.ts +1 -1
- package/src/cli/utils/resolve-bundler.ts +2 -1
- package/src/cli/utils/ts-config.ts +1 -1
- package/src/cli/utils/with-exponential-backoff.ts +28 -0
- package/src/core/constants.ts +2 -0
- package/src/storybook-config/__tests__/vite-final.test.ts +6 -0
- package/src/storybook-config/__tests__/webpack-final.test.ts +26 -12
- package/src/storybook-config/webpack-final.ts +10 -4
- package/src/telemetry/__tests__/telemetry.test.ts +326 -0
- package/src/telemetry/index.ts +2 -0
- package/src/telemetry/telemetry.ts +134 -0
- package/src/utils/__tests__/exit-when-parent-exits.test.ts +87 -0
- package/src/utils/__tests__/find-up.test.ts +49 -0
- package/src/utils/__tests__/get-configuration.test.ts +62 -0
- package/src/utils/exit-when-parent-exits.ts +33 -0
- package/src/utils/find-up.ts +2 -2
- package/src/utils/get-configuration.ts +14 -5
- package/src/utils/index.ts +1 -0
- package/src/vite/__tests__/build-shared-dependencies.test.ts +39 -5
- package/src/vite/build-shared-dependencies.ts +2 -1
- package/src/vite/config/__tests__/base-config.test.ts +12 -4
- package/src/vite/config/__tests__/create-css-config.test.ts +2 -6
- package/src/vite/config/__tests__/create-filtering-logger.test.ts +3 -2
- package/src/vite/config/__tests__/create-vite-config.test.ts +6 -3
- package/src/vite/config/base-config.ts +13 -1
- package/src/vite/config/create-filtering-logger.ts +8 -2
- package/src/vite/config/create-vite-config.ts +6 -3
- package/src/vite/index.html +2 -2
- package/src/vite/index.ts +2 -0
- package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/clean-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +15 -3
- package/src/vite/plugins/__tests__/dev-server-routing-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/externals-plugin.test.ts +24 -3
- package/src/vite/plugins/__tests__/html-plugin.test.ts +10 -3
- package/src/vite/plugins/__tests__/html-template.test.ts +10 -2
- package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +30 -6
- package/src/vite/plugins/__tests__/less-tilde-plugin.test.ts +91 -0
- package/src/vite/plugins/__tests__/metadata-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +35 -25
- package/src/vite/plugins/__tests__/style-urls-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/virtual-modules-plugin.test.ts +20 -9
- package/src/vite/plugins/__tests__/window-externals-plugin.test.ts +128 -0
- package/src/vite/plugins/chain-source-maps-plugin.ts +1 -1
- package/src/vite/plugins/clean-plugin.ts +1 -1
- package/src/vite/plugins/css-injector-plugin.ts +1 -1
- package/src/vite/plugins/design-system-guard-plugin.ts +11 -8
- package/src/vite/plugins/dev-server-routing-plugin.ts +1 -1
- package/src/vite/plugins/externals-plugin.ts +15 -6
- package/src/vite/plugins/html-plugin.ts +4 -2
- package/src/vite/plugins/ignore-modules-plugin.ts +32 -23
- package/src/vite/plugins/index.ts +3 -0
- package/src/vite/plugins/less-tilde-plugin.ts +64 -0
- package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +1 -1
- package/src/vite/plugins/metadata-plugin.ts +1 -1
- package/src/vite/plugins/moment-locales-plugin.ts +24 -14
- package/src/vite/plugins/react-refresh-plugin/README.md +165 -0
- package/src/vite/plugins/react-refresh-plugin/__tests__/react-refresh-plugin.test.ts +366 -0
- package/src/vite/plugins/react-refresh-plugin/__tests__/refresh-runtime.test.ts +193 -0
- package/src/vite/plugins/react-refresh-plugin/index.ts +1 -0
- package/src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts +144 -0
- package/src/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/shared-dependencies-plugin.test.ts +21 -16
- package/src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts +13 -12
- package/src/vite/plugins/style-urls-plugin.ts +1 -1
- package/src/vite/plugins/virtual-modules-plugin.ts +8 -7
- package/src/vite/plugins/window-externals-plugin.ts +94 -0
- package/src/webpack/__tests__/bundle-webpack.test.ts +32 -0
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +27 -1
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +17 -5
- package/src/webpack/__tests__/create-webpack-config.test.ts +10 -6
- package/src/webpack/bundle-webpack.ts +7 -1
- package/src/webpack/configs/optimization-config.ts +22 -11
- package/src/webpack/configs/output-config.ts +1 -1
- package/src/webpack/utils/__tests__/normalize-proxy-config.test.ts +121 -0
- package/src/webpack/utils/index.ts +1 -0
- package/src/webpack/utils/normalize-proxy-config.ts +59 -0
- package/tsconfig/types.d.ts +10 -0
- package/dist/cli/utils/get-bundle-command.d.ts +0 -3
- package/dist/cli/utils/get-bundle-command.d.ts.map +0 -1
- package/dist/cli/utils/get-bundle-command.js +0 -16
- package/dist/cli/utils/get-bundle-command.js.map +0 -1
- package/src/cli/utils/__tests__/get-bundle-command.test.ts +0 -23
- package/src/cli/utils/get-bundle-command.ts +0 -5
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
import { exitWhenParentExits, getFolders, log, readJsonSafe } from '../../../utils';
|
|
3
|
+
import { killProcessTree, pipeStdout, watchStdout } from '../../utils';
|
|
3
4
|
import { CliTask, Indicators } from '../cli-task';
|
|
4
5
|
|
|
5
|
-
jest.mock('execa', () =>
|
|
6
|
-
|
|
7
|
-
Object.assign(Promise.resolve(), {
|
|
8
|
-
stdout: {
|
|
9
|
-
on: jest.fn(),
|
|
10
|
-
},
|
|
11
|
-
})
|
|
12
|
-
)
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
jest.mock('../../utils', () => ({
|
|
16
|
-
pipeStdout: jest.fn(),
|
|
17
|
-
watchStdout: jest.fn(),
|
|
18
|
-
}));
|
|
6
|
+
jest.mock('execa', () => jest.fn());
|
|
7
|
+
jest.mock('../../utils');
|
|
19
8
|
|
|
20
9
|
jest.mock('../../../utils', () => ({
|
|
21
10
|
...jest.requireActual('../../../utils'),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
destination: 'dist',
|
|
25
|
-
}),
|
|
11
|
+
exitWhenParentExits: jest.fn(),
|
|
12
|
+
getFolders: jest.fn(),
|
|
26
13
|
log: { info: jest.fn() },
|
|
27
|
-
readJsonSafe: jest.fn()
|
|
14
|
+
readJsonSafe: jest.fn(),
|
|
28
15
|
}));
|
|
29
16
|
|
|
30
17
|
const taskName = 'cli-task-impl';
|
|
@@ -35,7 +22,11 @@ const indicators: Required<Indicators> = {
|
|
|
35
22
|
};
|
|
36
23
|
|
|
37
24
|
class CliTaskImpl extends CliTask {
|
|
38
|
-
constructor(
|
|
25
|
+
constructor(
|
|
26
|
+
private command: string,
|
|
27
|
+
private args: string[],
|
|
28
|
+
{ watch }: { watch: boolean }
|
|
29
|
+
) {
|
|
39
30
|
super({ name: taskName, global: false, watch, indicators });
|
|
40
31
|
}
|
|
41
32
|
|
|
@@ -44,83 +35,204 @@ class CliTaskImpl extends CliTask {
|
|
|
44
35
|
}
|
|
45
36
|
|
|
46
37
|
async execute(): Promise<void> {
|
|
47
|
-
await this.runChildProcess(
|
|
38
|
+
await this.runChildProcess(this.command, this.args);
|
|
48
39
|
}
|
|
49
40
|
}
|
|
50
41
|
|
|
51
|
-
describe(`[startup] ${CliTask.name}
|
|
42
|
+
describe(`[startup] ${CliTask.name}`, () => {
|
|
43
|
+
const command = 'foo';
|
|
44
|
+
const args = ['bar'];
|
|
45
|
+
|
|
52
46
|
beforeEach(() => {
|
|
53
|
-
globalThis.performance.clearMarks();
|
|
54
|
-
globalThis.performance.clearMeasures();
|
|
55
47
|
jest.clearAllMocks();
|
|
48
|
+
jest.mocked(readJsonSafe).mockReturnValue({});
|
|
56
49
|
});
|
|
57
50
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const subject = () => new CliTaskImpl({ watch }).execute();
|
|
51
|
+
describe('watchForParentExit', () => {
|
|
52
|
+
const subject = () => new CliTaskImpl(command, args, { watch: true }).watchForParentExit();
|
|
61
53
|
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
test('does not watch for the parent process to exit', () => {
|
|
55
|
+
subject();
|
|
64
56
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
);
|
|
57
|
+
expect(exitWhenParentExits).not.toHaveBeenCalled();
|
|
58
|
+
});
|
|
68
59
|
});
|
|
69
60
|
|
|
70
|
-
describe('
|
|
71
|
-
|
|
61
|
+
describe('runChildProcess', () => {
|
|
62
|
+
const childPid = 4321;
|
|
63
|
+
let watch = false;
|
|
64
|
+
|
|
65
|
+
beforeEach(() => {
|
|
66
|
+
globalThis.performance.clearMarks();
|
|
67
|
+
globalThis.performance.clearMeasures();
|
|
68
|
+
jest.mocked(getFolders).mockReturnValue({ source: 'src', destination: 'dist' });
|
|
69
|
+
jest.mocked(execa).mockReturnValue(
|
|
70
|
+
Object.assign(Promise.resolve(), {
|
|
71
|
+
pid: childPid,
|
|
72
|
+
stdout: { on: jest.fn() },
|
|
73
|
+
}) as any
|
|
74
|
+
);
|
|
75
|
+
});
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
const subject = () => new CliTaskImpl(command, args, { watch }).execute();
|
|
78
|
+
|
|
79
|
+
test('runs command', async () => {
|
|
80
|
+
await subject();
|
|
81
|
+
|
|
82
|
+
expect(execa).toHaveBeenCalledWith(command, args, { stdio: 'inherit' });
|
|
76
83
|
});
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
test('logs completion message', async () => {
|
|
86
|
+
await subject();
|
|
80
87
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
expect(log.info).toHaveBeenCalledWith(
|
|
89
|
+
expect.stringContaining(`${taskName} task completed in`)
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('in watch mode', () => {
|
|
94
|
+
const originalPlatform = process.platform;
|
|
95
|
+
let onceSpy: jest.SpyInstance;
|
|
96
|
+
let killSpy: jest.SpyInstance;
|
|
97
|
+
|
|
98
|
+
beforeEach(() => {
|
|
99
|
+
watch = true;
|
|
100
|
+
onceSpy = jest.spyOn(process, 'once');
|
|
101
|
+
killSpy = jest.spyOn(process, 'kill').mockImplementation(jest.fn());
|
|
102
|
+
});
|
|
87
103
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
104
|
+
afterEach(() => {
|
|
105
|
+
process.removeAllListeners('SIGINT');
|
|
106
|
+
process.removeAllListeners('SIGTERM');
|
|
107
|
+
});
|
|
91
108
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
109
|
+
function mockPlatform(platform: NodeJS.Platform) {
|
|
110
|
+
Object.defineProperty(process, 'platform', {
|
|
111
|
+
value: platform,
|
|
112
|
+
configurable: true,
|
|
95
113
|
});
|
|
96
114
|
}
|
|
97
115
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
onDataHandler(indicators[event]!);
|
|
116
|
+
test('pipes stdout and conditionally runs command in own process', async () => {
|
|
117
|
+
await subject();
|
|
101
118
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
119
|
+
expect(execa).toHaveBeenCalledWith(command, args, {
|
|
120
|
+
stdio: ['inherit', 'pipe', 'inherit'],
|
|
121
|
+
detached: process.platform !== 'win32',
|
|
105
122
|
});
|
|
106
|
-
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('calls pipeStdout', () => {
|
|
126
|
+
subject();
|
|
107
127
|
|
|
108
|
-
|
|
128
|
+
expect(pipeStdout).toHaveBeenCalled();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('watches for the parent process to exit', () => {
|
|
132
|
+
subject();
|
|
133
|
+
|
|
134
|
+
expect(exitWhenParentExits).toHaveBeenCalledWith(taskName, expect.any(Function));
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe('on POSIX', () => {
|
|
138
|
+
beforeEach(() => mockPlatform('darwin'));
|
|
139
|
+
|
|
140
|
+
afterEach(() => mockPlatform(originalPlatform));
|
|
141
|
+
|
|
142
|
+
describe.each<NodeJS.Signals>(['SIGINT', 'SIGTERM'])(
|
|
143
|
+
'when the process receives %s',
|
|
144
|
+
signal => {
|
|
145
|
+
beforeEach(() => {
|
|
146
|
+
subject();
|
|
147
|
+
onceSpy.mock.calls.find(([registered]) => registered === signal);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test(`forwards ${signal} to the child process tree`, () => {
|
|
153
|
+
expect(killProcessTree).toHaveBeenCalledWith(childPid, signal);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test(`re-raises ${signal}`, () => {
|
|
157
|
+
expect(killSpy).toHaveBeenCalledWith(process.pid, signal);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('on Windows', () => {
|
|
164
|
+
beforeEach(() => mockPlatform('win32'));
|
|
165
|
+
|
|
166
|
+
afterEach(() => mockPlatform(originalPlatform));
|
|
167
|
+
|
|
168
|
+
test('does not intercept signals', () => {
|
|
169
|
+
subject();
|
|
170
|
+
|
|
171
|
+
expect(onceSpy).not.toHaveBeenCalled();
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe('when the parent process exits', () => {
|
|
176
|
+
const triggerParentExit = () =>
|
|
177
|
+
jest.mocked(exitWhenParentExits).mock.calls[0][1]!();
|
|
109
178
|
|
|
110
|
-
describe('when subsequent build starts after initial build ends', () => {
|
|
111
179
|
beforeEach(() => {
|
|
112
|
-
|
|
113
|
-
|
|
180
|
+
subject();
|
|
181
|
+
triggerParentExit();
|
|
114
182
|
});
|
|
115
183
|
|
|
116
|
-
|
|
117
|
-
|
|
184
|
+
test('kills the child process tree', () => {
|
|
185
|
+
expect(killProcessTree).toHaveBeenCalledWith(childPid);
|
|
186
|
+
});
|
|
118
187
|
});
|
|
119
188
|
|
|
120
|
-
describe('
|
|
121
|
-
beforeEach(() =>
|
|
189
|
+
describe('onData handler', () => {
|
|
190
|
+
beforeEach(() => subject());
|
|
191
|
+
|
|
192
|
+
const onDataHandler = (data: string) => {
|
|
193
|
+
const handler = jest
|
|
194
|
+
.mocked(watchStdout)
|
|
195
|
+
.mock.calls.find(([_process, indicator]) => indicator === data)![2];
|
|
196
|
+
handler(1);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
function itLogsInitialBuild(event: keyof Indicators) {
|
|
200
|
+
test('logs duration of initial build', () => {
|
|
201
|
+
onDataHandler(indicators[event]);
|
|
202
|
+
|
|
203
|
+
expect(log.info).toHaveBeenCalledWith(
|
|
204
|
+
expect.stringContaining(`Initial ${taskName} task completed in`)
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function itLogsSubsequentBuild(event: keyof Indicators) {
|
|
210
|
+
test('logs duration of subsequent build', () => {
|
|
211
|
+
onDataHandler(indicators[event]!);
|
|
212
|
+
|
|
213
|
+
expect(log.info).toHaveBeenCalledWith(
|
|
214
|
+
expect.stringContaining(`Subsequent ${taskName} task completed in`)
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
itLogsInitialBuild('end');
|
|
220
|
+
|
|
221
|
+
describe('when subsequent build starts after initial build ends', () => {
|
|
222
|
+
beforeEach(() => {
|
|
223
|
+
onDataHandler(indicators.end);
|
|
224
|
+
onDataHandler(indicators.watchStart);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
itLogsSubsequentBuild('end');
|
|
228
|
+
itLogsSubsequentBuild('watchEnd');
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
describe('when subsequent build starts before initial build ends', () => {
|
|
232
|
+
beforeEach(() => onDataHandler(indicators.watchStart));
|
|
122
233
|
|
|
123
|
-
|
|
234
|
+
itLogsSubsequentBuild('watchEnd');
|
|
235
|
+
});
|
|
124
236
|
});
|
|
125
237
|
});
|
|
126
238
|
});
|
|
@@ -1,88 +1,83 @@
|
|
|
1
|
-
import { readJsonSafe } from '../../../utils';
|
|
1
|
+
import { exitWhenParentExits, readJsonSafe } from '../../../utils';
|
|
2
2
|
import { Task } from '../task';
|
|
3
3
|
|
|
4
4
|
jest.mock('../../../utils', () => ({
|
|
5
5
|
readJsonSafe: jest.fn().mockReturnValue({}),
|
|
6
|
+
exitWhenParentExits: jest.fn(),
|
|
6
7
|
}));
|
|
7
8
|
|
|
8
|
-
class
|
|
9
|
-
constructor() {
|
|
10
|
-
super({ name: 'GlobalTask', watch: false, global: true });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
description() {
|
|
14
|
-
return '';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
execute() {
|
|
18
|
-
return Promise.resolve();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
class PackageTask extends Task {
|
|
23
|
-
constructor() {
|
|
24
|
-
super({ name: 'PackageTask', watch: false, global: false });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
description() {
|
|
28
|
-
return '';
|
|
29
|
-
}
|
|
30
|
-
|
|
9
|
+
class MockTask extends Task {
|
|
31
10
|
execute() {
|
|
32
11
|
return Promise.resolve();
|
|
33
12
|
}
|
|
34
13
|
}
|
|
35
14
|
|
|
36
15
|
describe(`[startup] ${Task.name} entity`, () => {
|
|
16
|
+
let args: ConstructorParameters<typeof MockTask>[0];
|
|
17
|
+
|
|
37
18
|
beforeEach(() => {
|
|
38
19
|
globalThis.performance.clearMarks();
|
|
39
20
|
globalThis.performance.clearMeasures();
|
|
40
21
|
jest.clearAllMocks();
|
|
22
|
+
|
|
23
|
+
args = { name: 'mock-task', watch: false, global: false };
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const subject = () => new MockTask(args);
|
|
27
|
+
|
|
28
|
+
test('runs from the package directory', () => {
|
|
29
|
+
expect(subject).not.toThrow();
|
|
41
30
|
});
|
|
42
31
|
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
test("doesn't run from the workspace root directory", () => {
|
|
33
|
+
jest.mocked(readJsonSafe).mockReturnValueOnce({ workspaces: ['packages/*'] });
|
|
34
|
+
|
|
35
|
+
expect(subject).toThrow();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("doesn't run from an arbitrary directory", () => {
|
|
39
|
+
jest.mocked(readJsonSafe).mockReturnValueOnce(undefined);
|
|
40
|
+
|
|
41
|
+
expect(subject).toThrow();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('with global: true', () => {
|
|
45
|
+
beforeEach(() => (args.global = true));
|
|
45
46
|
|
|
46
47
|
test('runs from the workspace root directory', () => {
|
|
47
|
-
jest.mocked(readJsonSafe).mockReturnValueOnce({
|
|
48
|
-
workspaces: ['packages/*'],
|
|
49
|
-
});
|
|
48
|
+
jest.mocked(readJsonSafe).mockReturnValueOnce({ workspaces: ['packages/*'] });
|
|
50
49
|
|
|
51
50
|
expect(subject).not.toThrow();
|
|
52
51
|
});
|
|
53
52
|
|
|
54
53
|
test("doesn't run from the package directory", () => {
|
|
55
|
-
jest.mocked(readJsonSafe).mockReturnValueOnce({});
|
|
56
|
-
|
|
57
54
|
expect(subject).toThrow();
|
|
58
55
|
});
|
|
59
56
|
|
|
60
|
-
test("doesn't run from
|
|
57
|
+
test("doesn't run from an arbitrary directory", () => {
|
|
61
58
|
jest.mocked(readJsonSafe).mockReturnValueOnce(undefined);
|
|
62
59
|
|
|
63
60
|
expect(subject).toThrow();
|
|
64
61
|
});
|
|
65
62
|
});
|
|
66
63
|
|
|
67
|
-
describe('
|
|
68
|
-
const subject = () => new
|
|
64
|
+
describe('watchForParentExit', () => {
|
|
65
|
+
const subject = () => new MockTask(args).watchForParentExit();
|
|
69
66
|
|
|
70
|
-
test('
|
|
71
|
-
|
|
67
|
+
test('does not watch for the parent process to exit', () => {
|
|
68
|
+
subject();
|
|
72
69
|
|
|
73
|
-
expect(
|
|
70
|
+
expect(exitWhenParentExits).not.toHaveBeenCalled();
|
|
74
71
|
});
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
expect(subject).toThrow();
|
|
80
|
-
});
|
|
73
|
+
describe('with watch: true', () => {
|
|
74
|
+
beforeEach(() => (args.watch = true));
|
|
81
75
|
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
test('watches for the parent process to exit', () => {
|
|
77
|
+
subject();
|
|
84
78
|
|
|
85
|
-
|
|
79
|
+
expect(exitWhenParentExits).toHaveBeenCalledWith(args.name);
|
|
80
|
+
});
|
|
86
81
|
});
|
|
87
82
|
});
|
|
88
83
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import execa from 'execa';
|
|
2
|
-
import {
|
|
1
|
+
import execa, { ExecaChildProcess } from 'execa';
|
|
2
|
+
import { exitWhenParentExits, log } from '../../utils';
|
|
3
|
+
import { killProcessTree, pipeStdout, watchStdout } from '../utils';
|
|
3
4
|
import { Task, TaskParameters } from './task';
|
|
4
5
|
|
|
5
6
|
export interface Indicators {
|
|
@@ -20,6 +21,10 @@ export abstract class CliTask extends Task {
|
|
|
20
21
|
this.indicators = indicators;
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
watchForParentExit(): void {
|
|
25
|
+
// No-op: this task exits automatically when its child process ends
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
protected async runChildProcess(command: string, args: string[]) {
|
|
24
29
|
const childProcess = execa(
|
|
25
30
|
command,
|
|
@@ -27,6 +32,11 @@ export abstract class CliTask extends Task {
|
|
|
27
32
|
this.watch
|
|
28
33
|
? {
|
|
29
34
|
stdio: ['inherit', 'pipe', 'inherit'],
|
|
35
|
+
/*
|
|
36
|
+
* Put the child in its own process group so we can take down bin
|
|
37
|
+
* wrappers that fork children of their own. Not needed on Windows.
|
|
38
|
+
*/
|
|
39
|
+
detached: process.platform !== 'win32',
|
|
30
40
|
}
|
|
31
41
|
: {
|
|
32
42
|
stdio: 'inherit',
|
|
@@ -53,6 +63,37 @@ export abstract class CliTask extends Task {
|
|
|
53
63
|
this.logCompletionResults(this.taskTimer.end());
|
|
54
64
|
});
|
|
55
65
|
|
|
66
|
+
this.killOnParentExit(childProcess);
|
|
67
|
+
// Forward CTRL-C when signalled, rather than wait for killOnParentExit's slower poll.
|
|
68
|
+
this.forwardSignalToChild(childProcess);
|
|
69
|
+
|
|
56
70
|
await childProcess;
|
|
57
71
|
}
|
|
72
|
+
|
|
73
|
+
private forwardSignalToChild(childProcess: ExecaChildProcess) {
|
|
74
|
+
if (process.platform === 'win32') {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const forward = (signal: NodeJS.Signals) => {
|
|
79
|
+
if (childProcess.pid) {
|
|
80
|
+
log.info(`${this.name} forwarding signal to child process tree`);
|
|
81
|
+
killProcessTree(childProcess.pid, signal);
|
|
82
|
+
}
|
|
83
|
+
// Re-raise to get Node's default behavior
|
|
84
|
+
process.kill(process.pid, signal);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
process.once('SIGINT', () => forward('SIGINT'));
|
|
88
|
+
process.once('SIGTERM', () => forward('SIGTERM'));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private killOnParentExit(childProcess: ExecaChildProcess) {
|
|
92
|
+
exitWhenParentExits(this.name, () => {
|
|
93
|
+
if (childProcess.pid) {
|
|
94
|
+
log.info(`${this.name} killing child process tree`);
|
|
95
|
+
killProcessTree(childProcess.pid);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
58
99
|
}
|
|
@@ -1,36 +1,43 @@
|
|
|
1
1
|
import { fs, vol } from 'memfs';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
import { TSConfig } from '../../../utils';
|
|
3
4
|
import { getSwcOptions } from '../get-swc-options';
|
|
4
5
|
|
|
5
6
|
jest.mock('fs', () => fs);
|
|
6
7
|
|
|
7
8
|
describe(`[startup] ${getSwcOptions.name}`, () => {
|
|
9
|
+
let options: Parameters<typeof getSwcOptions>[1];
|
|
10
|
+
const tsConfigPath = 'tsconfig.json';
|
|
11
|
+
|
|
8
12
|
let tsConfig: TSConfig;
|
|
9
13
|
|
|
10
14
|
function setTsConfig(config: Record<string, any> = {}) {
|
|
11
15
|
return vol.fromJSON({
|
|
12
|
-
|
|
16
|
+
[tsConfigPath]: JSON.stringify(config),
|
|
13
17
|
});
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
beforeEach(() => {
|
|
17
|
-
|
|
21
|
+
options = undefined;
|
|
22
|
+
tsConfig = new TSConfig(tsConfigPath);
|
|
18
23
|
setTsConfig();
|
|
19
24
|
});
|
|
20
25
|
|
|
21
26
|
afterEach(() => vol.reset());
|
|
22
27
|
|
|
23
|
-
const subject = () => getSwcOptions(tsConfig);
|
|
28
|
+
const subject = () => getSwcOptions(tsConfig, options);
|
|
24
29
|
|
|
25
30
|
test('returns default options', () => {
|
|
26
31
|
expect(subject()).toEqual({
|
|
27
32
|
jsc: {
|
|
28
33
|
parser: { syntax: 'typescript', tsx: true, decorators: true },
|
|
29
34
|
target: undefined,
|
|
35
|
+
baseUrl: undefined,
|
|
36
|
+
paths: undefined,
|
|
30
37
|
transform: {
|
|
31
38
|
decoratorMetadata: undefined,
|
|
32
39
|
legacyDecorator: undefined,
|
|
33
|
-
react: { runtime: 'automatic' },
|
|
40
|
+
react: { runtime: 'automatic', refresh: false, development: false },
|
|
34
41
|
},
|
|
35
42
|
},
|
|
36
43
|
module: { type: 'es6' },
|
|
@@ -62,6 +69,41 @@ describe(`[startup] ${getSwcOptions.name}`, () => {
|
|
|
62
69
|
});
|
|
63
70
|
});
|
|
64
71
|
|
|
72
|
+
describe('when reactRefresh is true', () => {
|
|
73
|
+
beforeEach(() => (options = { reactRefresh: true }));
|
|
74
|
+
|
|
75
|
+
test('enables react refresh and development mode', () => {
|
|
76
|
+
expect(subject().jsc.transform!.react).toEqual(
|
|
77
|
+
expect.objectContaining({
|
|
78
|
+
development: true,
|
|
79
|
+
refresh: true,
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('when tsconfig contains "compilerOptions.paths"', () => {
|
|
86
|
+
beforeEach(() => setTsConfig({ compilerOptions: { paths: { foo: ['./bar'] } } }));
|
|
87
|
+
|
|
88
|
+
test('forwards paths', () => {
|
|
89
|
+
expect(subject()).toEqual(
|
|
90
|
+
expect.objectContaining({
|
|
91
|
+
jsc: expect.objectContaining({ paths: { foo: ['./bar'] } }),
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('defaults baseUrl to the tsconfig directory', () => {
|
|
97
|
+
expect(subject()).toEqual(
|
|
98
|
+
expect.objectContaining({
|
|
99
|
+
jsc: expect.objectContaining({
|
|
100
|
+
baseUrl: path.resolve(path.dirname(tsConfigPath)),
|
|
101
|
+
}),
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
65
107
|
describe.each(['commonjs', 'commonJS', 'nodenext', 'NodeNext'])(
|
|
66
108
|
'when compilerOptions.module is "%s"',
|
|
67
109
|
module => {
|
|
@@ -3,7 +3,7 @@ import deepmerge from 'deepmerge';
|
|
|
3
3
|
import { fs, vol } from 'memfs';
|
|
4
4
|
import { getSwcCompilePackageConfiguration, log } from '../../../../utils';
|
|
5
5
|
import { TSConfig } from '../../../utils';
|
|
6
|
-
import
|
|
6
|
+
import * as getSwcOptionsModule from '../get-swc-options';
|
|
7
7
|
import { SwcCompilePackage } from '../swc-compile-package';
|
|
8
8
|
|
|
9
9
|
jest.mock('fs', () => fs);
|
|
@@ -45,11 +45,15 @@ describe(`[startup] ${SwcCompilePackage.name} task`, () => {
|
|
|
45
45
|
volumeFromJSON();
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
afterEach(() =>
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
jest.restoreAllMocks();
|
|
50
|
+
vol.reset();
|
|
51
|
+
});
|
|
49
52
|
|
|
53
|
+
let reactRefresh = false;
|
|
50
54
|
let watch = false;
|
|
51
55
|
|
|
52
|
-
const subject = () => new SwcCompilePackage({ watch }).execute();
|
|
56
|
+
const subject = () => new SwcCompilePackage({ reactRefresh, watch }).execute();
|
|
53
57
|
|
|
54
58
|
const onSuccessHandlerParams = {
|
|
55
59
|
duration: 10,
|
|
@@ -90,7 +94,12 @@ describe(`[startup] ${SwcCompilePackage.name} task`, () => {
|
|
|
90
94
|
'**/*.stories.*',
|
|
91
95
|
],
|
|
92
96
|
},
|
|
93
|
-
swcOptions: getSwcOptions(
|
|
97
|
+
swcOptions: getSwcOptionsModule.getSwcOptions(
|
|
98
|
+
new TSConfig('tsconfig.json'),
|
|
99
|
+
{
|
|
100
|
+
reactRefresh,
|
|
101
|
+
}
|
|
102
|
+
),
|
|
94
103
|
callbacks: {
|
|
95
104
|
onSuccess: expect.any(Function),
|
|
96
105
|
onFail: expect.any(Function),
|
|
@@ -270,4 +279,16 @@ describe(`[startup] ${SwcCompilePackage.name} task`, () => {
|
|
|
270
279
|
);
|
|
271
280
|
});
|
|
272
281
|
});
|
|
282
|
+
|
|
283
|
+
describe('when reactRefresh is true', () => {
|
|
284
|
+
beforeEach(() => (reactRefresh = true));
|
|
285
|
+
|
|
286
|
+
test('passes react refresh to getSwcOptions', () => {
|
|
287
|
+
const getSwcOptionsSpy = jest.spyOn(getSwcOptionsModule, 'getSwcOptions');
|
|
288
|
+
|
|
289
|
+
subject();
|
|
290
|
+
|
|
291
|
+
expect(getSwcOptionsSpy).toHaveBeenCalledWith(expect.any(TSConfig), { reactRefresh });
|
|
292
|
+
});
|
|
293
|
+
});
|
|
273
294
|
});
|