@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,14 +1,23 @@
|
|
|
1
1
|
import type { SwcOptions } from '@swc/cli';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
import { TSConfig } from '../../utils';
|
|
3
4
|
|
|
4
5
|
type JscConfig = NonNullable<SwcOptions['jsc']>;
|
|
5
6
|
|
|
6
|
-
export function getSwcOptions(tsConfig: TSConfig) {
|
|
7
|
+
export function getSwcOptions(tsConfig: TSConfig, { reactRefresh = false } = {}) {
|
|
7
8
|
const target = tsConfig.getValue<JscConfig['target']>('compilerOptions.target');
|
|
8
9
|
const legacyDecorator = tsConfig.getValue<boolean>('compilerOptions.experimentalDecorators');
|
|
9
10
|
const decoratorMetadata = tsConfig.getValue<boolean>('compilerOptions.emitDecoratorMetadata');
|
|
10
11
|
const sourceMaps = tsConfig.getValue<SwcOptions['sourceMaps']>('compilerOptions.sourceMap');
|
|
11
12
|
const module = tsConfig.getValue<string>('compilerOptions.module')?.toLowerCase();
|
|
13
|
+
const paths = tsConfig.getValue<JscConfig['paths']>('compilerOptions.paths');
|
|
14
|
+
/*
|
|
15
|
+
* `compilerOptions.baseUrl` is deprecated in TypeScript, so it's not read here.
|
|
16
|
+
* TS resolves `paths` relative to the tsconfig directory; SWC requires an
|
|
17
|
+
* absolute `jsc.baseUrl` whenever `jsc.paths` is set.
|
|
18
|
+
*/
|
|
19
|
+
const baseUrl =
|
|
20
|
+
paths !== undefined ? path.resolve(path.dirname(tsConfig.configPath)) : undefined;
|
|
12
21
|
|
|
13
22
|
return {
|
|
14
23
|
jsc: {
|
|
@@ -18,11 +27,15 @@ export function getSwcOptions(tsConfig: TSConfig) {
|
|
|
18
27
|
decorators: true,
|
|
19
28
|
},
|
|
20
29
|
target,
|
|
30
|
+
baseUrl,
|
|
31
|
+
paths,
|
|
21
32
|
transform: {
|
|
22
33
|
legacyDecorator,
|
|
23
34
|
decoratorMetadata,
|
|
24
35
|
react: {
|
|
25
36
|
runtime: 'automatic',
|
|
37
|
+
refresh: reactRefresh,
|
|
38
|
+
development: reactRefresh,
|
|
26
39
|
},
|
|
27
40
|
},
|
|
28
41
|
},
|
|
@@ -7,6 +7,7 @@ import { Task } from '../task';
|
|
|
7
7
|
import { getSwcOptions } from './get-swc-options';
|
|
8
8
|
|
|
9
9
|
interface Args {
|
|
10
|
+
reactRefresh?: boolean;
|
|
10
11
|
watch?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -15,8 +16,11 @@ function overwriteMerge(_destinationArray: unknown[], sourceArray: unknown[]) {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export class SwcCompilePackage extends Task {
|
|
18
|
-
|
|
19
|
+
private readonly reactRefresh: boolean | undefined;
|
|
20
|
+
|
|
21
|
+
constructor({ reactRefresh, watch }: Args) {
|
|
19
22
|
super({ name: 'swc-compile-package', global: false, watch });
|
|
23
|
+
this.reactRefresh = reactRefresh;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
async execute(): Promise<void> {
|
|
@@ -60,7 +64,7 @@ export class SwcCompilePackage extends Task {
|
|
|
60
64
|
return deepmerge(
|
|
61
65
|
{
|
|
62
66
|
cliOptions: getCliOptions(tsConfig, { watch: this.watch }),
|
|
63
|
-
swcOptions: getSwcOptions(tsConfig),
|
|
67
|
+
swcOptions: getSwcOptions(tsConfig, { reactRefresh: this.reactRefresh }),
|
|
64
68
|
},
|
|
65
69
|
packageConfig,
|
|
66
70
|
{ arrayMerge: overwriteMerge, clone: false }
|
package/src/cli/tasks/task.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatDuration, log, readJsonSafe } from '../../utils';
|
|
1
|
+
import { exitWhenParentExits, formatDuration, log, readJsonSafe } from '../../utils';
|
|
2
2
|
|
|
3
3
|
class TaskTimer {
|
|
4
4
|
private counter = 0;
|
|
@@ -65,7 +65,7 @@ export interface TaskParameters {
|
|
|
65
65
|
export abstract class Task {
|
|
66
66
|
protected readonly watch: boolean;
|
|
67
67
|
protected readonly taskTimer: TaskTimer;
|
|
68
|
-
|
|
68
|
+
protected readonly name: string;
|
|
69
69
|
private readonly global: boolean;
|
|
70
70
|
|
|
71
71
|
constructor({ name, watch, global }: TaskParameters) {
|
|
@@ -76,6 +76,12 @@ export abstract class Task {
|
|
|
76
76
|
this.checkRunLocation();
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
watchForParentExit(): void {
|
|
80
|
+
if (this.watch) {
|
|
81
|
+
exitWhenParentExits(this.name);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
79
85
|
protected logCompletionResults({
|
|
80
86
|
measure,
|
|
81
87
|
counter,
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import execa from 'execa';
|
|
2
1
|
import { fs, vol } from 'memfs';
|
|
3
2
|
import path from 'path';
|
|
4
|
-
import {
|
|
3
|
+
import { CliTask } from '../../cli-task';
|
|
5
4
|
import { TscCompile } from '../tsc-compile';
|
|
6
5
|
|
|
7
6
|
jest.mock('fs', () => fs);
|
|
8
|
-
jest.mock('execa', () =>
|
|
9
|
-
jest.fn().mockReturnValue(
|
|
10
|
-
Object.assign(Promise.resolve(), {
|
|
11
|
-
stdout: {
|
|
12
|
-
on: jest.fn(),
|
|
13
|
-
},
|
|
14
|
-
})
|
|
15
|
-
)
|
|
16
|
-
);
|
|
17
7
|
|
|
18
8
|
describe(`[startup] ${TscCompile.name} task`, () => {
|
|
19
9
|
let options: ConstructorParameters<typeof TscCompile>[0];
|
|
10
|
+
let runChildProcessSpy: jest.SpyInstance;
|
|
20
11
|
|
|
21
12
|
beforeEach(() => {
|
|
22
13
|
vol.fromJSON({
|
|
@@ -46,8 +37,9 @@ describe(`[startup] ${TscCompile.name} task`, () => {
|
|
|
46
37
|
}),
|
|
47
38
|
'package.json': JSON.stringify({ workspaces: ['packages/*'] }),
|
|
48
39
|
});
|
|
49
|
-
jest
|
|
50
|
-
|
|
40
|
+
runChildProcessSpy = jest
|
|
41
|
+
.spyOn(CliTask.prototype as any, 'runChildProcess')
|
|
42
|
+
.mockResolvedValue(undefined);
|
|
51
43
|
options = {};
|
|
52
44
|
});
|
|
53
45
|
|
|
@@ -55,20 +47,12 @@ describe(`[startup] ${TscCompile.name} task`, () => {
|
|
|
55
47
|
|
|
56
48
|
function itRunsTsc(
|
|
57
49
|
caption: string,
|
|
58
|
-
{
|
|
59
|
-
watch = false,
|
|
60
|
-
tsConfigs,
|
|
61
|
-
stdio,
|
|
62
|
-
}: {
|
|
63
|
-
watch?: boolean;
|
|
64
|
-
tsConfigs: string[];
|
|
65
|
-
stdio: string | string[];
|
|
66
|
-
}
|
|
50
|
+
{ watch = false, tsConfigs }: { watch?: boolean; tsConfigs: string[] }
|
|
67
51
|
) {
|
|
68
52
|
test(`runs tsc ${caption}`, () => {
|
|
69
53
|
subject();
|
|
70
54
|
|
|
71
|
-
expect(
|
|
55
|
+
expect(runChildProcessSpy).toHaveBeenCalledWith(
|
|
72
56
|
'tsc',
|
|
73
57
|
expect.arrayContaining(
|
|
74
58
|
[
|
|
@@ -79,10 +63,7 @@ describe(`[startup] ${TscCompile.name} task`, () => {
|
|
|
79
63
|
'--emitDeclarationOnly',
|
|
80
64
|
...tsConfigs.map(config => expect.stringContaining(path.normalize(config))),
|
|
81
65
|
].filter(item => item !== undefined)
|
|
82
|
-
)
|
|
83
|
-
{
|
|
84
|
-
stdio,
|
|
85
|
-
}
|
|
66
|
+
)
|
|
86
67
|
);
|
|
87
68
|
});
|
|
88
69
|
}
|
|
@@ -91,7 +72,6 @@ describe(`[startup] ${TscCompile.name} task`, () => {
|
|
|
91
72
|
|
|
92
73
|
itRunsTsc('', {
|
|
93
74
|
tsConfigs: ['foo/tsconfig.json', 'bar/tsconfig.json'],
|
|
94
|
-
stdio: 'inherit',
|
|
95
75
|
});
|
|
96
76
|
|
|
97
77
|
describe('in watch mode', () => {
|
|
@@ -100,7 +80,6 @@ describe(`[startup] ${TscCompile.name} task`, () => {
|
|
|
100
80
|
itRunsTsc('in watch mode', {
|
|
101
81
|
watch: true,
|
|
102
82
|
tsConfigs: ['foo/tsconfig.json', 'bar/tsconfig.json'],
|
|
103
|
-
stdio: ['inherit', 'pipe', 'inherit'],
|
|
104
83
|
});
|
|
105
84
|
});
|
|
106
85
|
|
|
@@ -109,7 +88,6 @@ describe(`[startup] ${TscCompile.name} task`, () => {
|
|
|
109
88
|
|
|
110
89
|
itRunsTsc('with only specified package', {
|
|
111
90
|
tsConfigs: ['foo/tsconfig.json'],
|
|
112
|
-
stdio: 'inherit',
|
|
113
91
|
});
|
|
114
92
|
});
|
|
115
93
|
|
|
@@ -118,7 +96,6 @@ describe(`[startup] ${TscCompile.name} task`, () => {
|
|
|
118
96
|
|
|
119
97
|
itRunsTsc('without specified package', {
|
|
120
98
|
tsConfigs: ['baz/tsconfig.json', 'bar/tsconfig.json'],
|
|
121
|
-
stdio: 'inherit',
|
|
122
99
|
});
|
|
123
100
|
});
|
|
124
101
|
|
|
@@ -127,7 +104,6 @@ describe(`[startup] ${TscCompile.name} task`, () => {
|
|
|
127
104
|
|
|
128
105
|
itRunsTsc('with combined filters', {
|
|
129
106
|
tsConfigs: ['baz/tsconfig.json'],
|
|
130
|
-
stdio: 'inherit',
|
|
131
107
|
});
|
|
132
108
|
});
|
|
133
109
|
});
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CliTask } from '../../cli-task';
|
|
2
2
|
import { TscCompilePackage } from '../tsc-compile-package';
|
|
3
3
|
|
|
4
|
-
jest.mock('execa', () =>
|
|
5
|
-
jest.fn().mockReturnValue(
|
|
6
|
-
Object.assign(Promise.resolve(), {
|
|
7
|
-
stdout: {
|
|
8
|
-
on: jest.fn(),
|
|
9
|
-
},
|
|
10
|
-
})
|
|
11
|
-
)
|
|
12
|
-
);
|
|
13
|
-
|
|
14
4
|
const tsConfig = 'tsconfig.build.json';
|
|
15
5
|
|
|
16
6
|
const tscOptions = [
|
|
@@ -41,33 +31,34 @@ jest.mock('../../../../utils', () => ({
|
|
|
41
31
|
}));
|
|
42
32
|
|
|
43
33
|
describe(`[startup] ${TscCompilePackage.name} task`, () => {
|
|
34
|
+
let runChildProcessSpy: jest.SpyInstance;
|
|
35
|
+
|
|
44
36
|
beforeEach(() => {
|
|
45
37
|
globalThis.performance.clearMarks();
|
|
46
38
|
globalThis.performance.clearMeasures();
|
|
47
39
|
jest.clearAllMocks();
|
|
40
|
+
runChildProcessSpy = jest
|
|
41
|
+
.spyOn(CliTask.prototype as any, 'runChildProcess')
|
|
42
|
+
.mockResolvedValue(undefined);
|
|
48
43
|
});
|
|
49
44
|
|
|
50
45
|
let watch = false;
|
|
51
46
|
|
|
52
47
|
const subject = () => new TscCompilePackage({ watch }).execute();
|
|
53
48
|
|
|
54
|
-
test('calls
|
|
49
|
+
test('calls runChildProcess', () => {
|
|
55
50
|
subject();
|
|
56
51
|
|
|
57
|
-
expect(
|
|
58
|
-
stdio: 'inherit',
|
|
59
|
-
});
|
|
52
|
+
expect(runChildProcessSpy).toHaveBeenCalledWith('tsc', tscOptions);
|
|
60
53
|
});
|
|
61
54
|
|
|
62
55
|
describe('in watch mode', () => {
|
|
63
56
|
beforeEach(() => (watch = true));
|
|
64
57
|
|
|
65
|
-
test('calls
|
|
58
|
+
test('calls runChildProcess', () => {
|
|
66
59
|
subject();
|
|
67
60
|
|
|
68
|
-
expect(
|
|
69
|
-
stdio: ['inherit', 'pipe', 'inherit'],
|
|
70
|
-
});
|
|
61
|
+
expect(runChildProcessSpy).toHaveBeenCalledWith('tsc', ['-w', ...tscOptions]);
|
|
71
62
|
});
|
|
72
63
|
});
|
|
73
64
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { gitGetBranch, gitGetCommitHash } from '../cli-git';
|
|
2
|
-
import { runCommandOutput } from '../cli-os';
|
|
1
|
+
import { gitGetBranch, gitGetCommitHash, gitGetContext } from '../cli-git';
|
|
2
|
+
import { runCommandOutput, runCommandOutputAsync } from '../cli-os';
|
|
3
3
|
|
|
4
|
-
jest.mock('../cli-os', () => ({ runCommandOutput: jest.fn() }));
|
|
4
|
+
jest.mock('../cli-os', () => ({ runCommandOutput: jest.fn(), runCommandOutputAsync: jest.fn() }));
|
|
5
5
|
|
|
6
6
|
describe('[startup] Cli Utils (Git)', () => {
|
|
7
7
|
beforeEach(() => {
|
|
@@ -26,4 +26,55 @@ describe('[startup] Cli Utils (Git)', () => {
|
|
|
26
26
|
describe(gitGetCommitHash.name, () => {
|
|
27
27
|
itRunsCommand(gitGetCommitHash, 'git rev-parse --short HEAD');
|
|
28
28
|
});
|
|
29
|
+
|
|
30
|
+
describe(gitGetContext.name, () => {
|
|
31
|
+
const root = '/repos/monolith';
|
|
32
|
+
const context = {
|
|
33
|
+
repo: 'monolith',
|
|
34
|
+
branch: 'main',
|
|
35
|
+
userEmail: 'dev@st.com',
|
|
36
|
+
userName: 'dev',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
let output: Record<string, string | undefined>;
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
output = {
|
|
43
|
+
'rev-parse': `${context.branch}\n${root}`,
|
|
44
|
+
'user.email': context.userEmail,
|
|
45
|
+
'user.name': context.userName,
|
|
46
|
+
};
|
|
47
|
+
jest.mocked(runCommandOutputAsync).mockImplementation(command => {
|
|
48
|
+
const key = Object.keys(output).find(entry => String(command).includes(entry));
|
|
49
|
+
return Promise.resolve(key ? output[key] : undefined);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const subject = () => gitGetContext();
|
|
54
|
+
|
|
55
|
+
test('collects the repo, branch, and user', async () => {
|
|
56
|
+
expect(await subject()).toEqual(context);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('when one command fails', () => {
|
|
60
|
+
beforeEach(() => (output['user.email'] = undefined));
|
|
61
|
+
|
|
62
|
+
test('leaves only that field undefined', async () => {
|
|
63
|
+
expect(await subject()).toEqual({ ...context, userEmail: undefined });
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('when every command fails', () => {
|
|
68
|
+
beforeEach(() => (output = {}));
|
|
69
|
+
|
|
70
|
+
test('leaves the fields undefined', async () => {
|
|
71
|
+
expect(await subject()).toEqual({
|
|
72
|
+
repo: undefined,
|
|
73
|
+
branch: undefined,
|
|
74
|
+
userEmail: undefined,
|
|
75
|
+
userName: undefined,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
29
80
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { log } from '../../../utils';
|
|
1
2
|
import {
|
|
2
3
|
npmGetPackageVersions,
|
|
3
4
|
npmGetPackageVersionsDetails,
|
|
@@ -20,6 +21,7 @@ jest.mock('../../../utils', () => ({
|
|
|
20
21
|
log: {
|
|
21
22
|
info: jest.fn(),
|
|
22
23
|
error: jest.fn(),
|
|
24
|
+
warning: jest.fn(),
|
|
23
25
|
},
|
|
24
26
|
}));
|
|
25
27
|
|
|
@@ -230,6 +232,37 @@ describe('[startup] Cli Utils (Npm)', () => {
|
|
|
230
232
|
'npm dist-tag --registry={registry} add {packageName}@{packageVersion} {tag}'
|
|
231
233
|
);
|
|
232
234
|
});
|
|
235
|
+
|
|
236
|
+
describe('when the command fails once then succeeds', () => {
|
|
237
|
+
beforeEach(() => {
|
|
238
|
+
jest.useFakeTimers();
|
|
239
|
+
jest.mocked(runCommand)
|
|
240
|
+
.mockRejectedValueOnce(new Error('{error}'))
|
|
241
|
+
.mockResolvedValue(undefined);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
afterEach(() => jest.useRealTimers());
|
|
245
|
+
|
|
246
|
+
const subjectAfterRetry = async () => {
|
|
247
|
+
const promise = subject();
|
|
248
|
+
await jest.advanceTimersByTimeAsync(100000);
|
|
249
|
+
return promise;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
test('retries the command', async () => {
|
|
253
|
+
await subjectAfterRetry();
|
|
254
|
+
|
|
255
|
+
expect(runCommand).toHaveBeenCalledTimes(2);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
test('logs a warning', async () => {
|
|
259
|
+
await subjectAfterRetry();
|
|
260
|
+
|
|
261
|
+
expect(log.warning).toHaveBeenCalledWith(
|
|
262
|
+
'Failed to tag {packageName}@{packageVersion} with "{tag}", retrying in 500ms...'
|
|
263
|
+
);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
233
266
|
});
|
|
234
267
|
|
|
235
268
|
describe(npmRemoveTag.name, () => {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { execSync, spawn } from 'child_process';
|
|
1
|
+
import { exec, execFileSync, execSync, spawn } from 'child_process';
|
|
2
2
|
import { log } from '../../../utils';
|
|
3
|
-
import { runCommand, runCommandOutput } from '../cli-os';
|
|
4
|
-
|
|
5
|
-
jest.mock('child_process', () => ({
|
|
3
|
+
import { killProcessTree, runCommand, runCommandOutput, runCommandOutputAsync } from '../cli-os';
|
|
4
|
+
|
|
5
|
+
jest.mock('child_process', () => ({
|
|
6
|
+
exec: jest.fn(),
|
|
7
|
+
execFileSync: jest.fn(),
|
|
8
|
+
execSync: jest.fn(),
|
|
9
|
+
spawn: jest.fn(),
|
|
10
|
+
}));
|
|
6
11
|
jest.mock('../../../utils', () => ({ log: { info: jest.fn() } })); // suppress log output
|
|
7
12
|
|
|
8
13
|
describe('[startup] Cli Utils (OS)', () => {
|
|
@@ -138,4 +143,178 @@ describe('[startup] Cli Utils (OS)', () => {
|
|
|
138
143
|
expect(logInfoSpy).not.toHaveBeenCalled();
|
|
139
144
|
});
|
|
140
145
|
});
|
|
146
|
+
|
|
147
|
+
describe(`${runCommandOutputAsync.name}`, () => {
|
|
148
|
+
// promisify(exec) resolves with { stdout, stderr }; the mock supplies that shape.
|
|
149
|
+
const mockExec = (
|
|
150
|
+
impl: (callback: (error: Error | null, result?: { stdout: string }) => void) => void
|
|
151
|
+
) =>
|
|
152
|
+
jest
|
|
153
|
+
.mocked(exec)
|
|
154
|
+
.mockImplementation(((
|
|
155
|
+
_command: string,
|
|
156
|
+
_options: unknown,
|
|
157
|
+
callback: (error: Error | null, result?: { stdout: string }) => void
|
|
158
|
+
) => impl(callback)) as unknown as typeof exec);
|
|
159
|
+
|
|
160
|
+
let command: string;
|
|
161
|
+
let options: NonNullable<Parameters<typeof runCommandOutputAsync>[1]>;
|
|
162
|
+
|
|
163
|
+
beforeEach(() => {
|
|
164
|
+
jest.clearAllMocks();
|
|
165
|
+
command = 'foo';
|
|
166
|
+
options = {};
|
|
167
|
+
mockExec(callback => callback(null, { stdout: 'result\n' }));
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const subject = () => runCommandOutputAsync(command, options);
|
|
171
|
+
|
|
172
|
+
test('resolves with the trimmed result', async () => {
|
|
173
|
+
await expect(subject()).resolves.toBe('result');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('runs the command', async () => {
|
|
177
|
+
await subject();
|
|
178
|
+
|
|
179
|
+
expect(exec).toHaveBeenCalledWith(command, options, expect.any(Function));
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe('when the output is empty', () => {
|
|
183
|
+
beforeEach(() => mockExec(callback => callback(null, { stdout: ' ' })));
|
|
184
|
+
|
|
185
|
+
test('resolves with undefined', async () => {
|
|
186
|
+
await expect(subject()).resolves.toBeUndefined();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('with options', () => {
|
|
191
|
+
beforeEach(() => (options.timeout = 10000));
|
|
192
|
+
|
|
193
|
+
test('passes them through', async () => {
|
|
194
|
+
await subject();
|
|
195
|
+
|
|
196
|
+
expect(exec).toHaveBeenCalledWith(command, options, expect.any(Function));
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('logs the command', async () => {
|
|
201
|
+
const logInfoSpy = jest.spyOn(log, 'info');
|
|
202
|
+
await subject();
|
|
203
|
+
|
|
204
|
+
expect(logInfoSpy).toHaveBeenCalledWith(`Running: ${command}`);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('logs the result', async () => {
|
|
208
|
+
const logInfoSpy = jest.spyOn(log, 'info');
|
|
209
|
+
await subject();
|
|
210
|
+
|
|
211
|
+
expect(logInfoSpy).toHaveBeenCalledWith('command finished', 'result');
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
describe('with quiet', () => {
|
|
215
|
+
beforeEach(() => (options.quiet = true));
|
|
216
|
+
|
|
217
|
+
test('suppresses output', async () => {
|
|
218
|
+
const logInfoSpy = jest.spyOn(log, 'info');
|
|
219
|
+
await subject();
|
|
220
|
+
|
|
221
|
+
expect(logInfoSpy).not.toHaveBeenCalled();
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe('when the command fails', () => {
|
|
226
|
+
beforeEach(() => mockExec(callback => callback(new Error('boom'))));
|
|
227
|
+
|
|
228
|
+
test('rejects', async () => {
|
|
229
|
+
await expect(subject()).rejects.toThrow('boom');
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
describe('with ignoreErrors', () => {
|
|
233
|
+
beforeEach(() => (options.ignoreErrors = true));
|
|
234
|
+
|
|
235
|
+
test('resolves with undefined', async () => {
|
|
236
|
+
await expect(subject()).resolves.toBeUndefined();
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
describe(`${killProcessTree.name}`, () => {
|
|
243
|
+
const pid = 1234;
|
|
244
|
+
const originalPlatform = process.platform;
|
|
245
|
+
let signal: Parameters<typeof killProcessTree>[1];
|
|
246
|
+
let killSpy: jest.SpyInstance;
|
|
247
|
+
|
|
248
|
+
function mockPlatform(platform: NodeJS.Platform) {
|
|
249
|
+
Object.defineProperty(process, 'platform', { value: platform, configurable: true });
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
beforeEach(() => {
|
|
253
|
+
jest.clearAllMocks();
|
|
254
|
+
killSpy = jest.spyOn(process, 'kill').mockImplementation(jest.fn());
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
afterEach(() => mockPlatform(originalPlatform));
|
|
258
|
+
|
|
259
|
+
const subject = () => killProcessTree(pid, signal);
|
|
260
|
+
|
|
261
|
+
describe('on POSIX', () => {
|
|
262
|
+
beforeEach(() => mockPlatform('darwin'));
|
|
263
|
+
|
|
264
|
+
test('sends SIGKILL to the process tree', () => {
|
|
265
|
+
subject();
|
|
266
|
+
|
|
267
|
+
expect(killSpy).toHaveBeenCalledWith(-pid, 'SIGKILL');
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
describe('with a signal', () => {
|
|
271
|
+
beforeEach(() => (signal = 'SIGTERM'));
|
|
272
|
+
|
|
273
|
+
test('send the signal to the process tree', () => {
|
|
274
|
+
subject();
|
|
275
|
+
expect(killSpy).toHaveBeenCalledWith(-pid, signal);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
describe('when the process is already gone', () => {
|
|
280
|
+
beforeEach(() => {
|
|
281
|
+
killSpy.mockImplementation(() => {
|
|
282
|
+
throw new Error('ESRCH');
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test('does not throw', () => {
|
|
287
|
+
expect(() => killProcessTree(pid)).not.toThrow();
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
describe('on Windows', () => {
|
|
293
|
+
beforeEach(() => mockPlatform('win32'));
|
|
294
|
+
|
|
295
|
+
test('runs taskkill /F /T on the process tree', () => {
|
|
296
|
+
subject();
|
|
297
|
+
|
|
298
|
+
expect(execFileSync).toHaveBeenCalledWith('taskkill', [
|
|
299
|
+
'/pid',
|
|
300
|
+
String(pid),
|
|
301
|
+
'/t',
|
|
302
|
+
'/f',
|
|
303
|
+
]);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
describe('when the process is already gone', () => {
|
|
307
|
+
beforeEach(() => {
|
|
308
|
+
jest.mocked(execFileSync).mockImplementation(() => {
|
|
309
|
+
throw new Error('not found');
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
test('does not throw', () => {
|
|
314
|
+
subject();
|
|
315
|
+
expect(() => killProcessTree(pid)).not.toThrow();
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
});
|
|
141
320
|
});
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { log } from '../../../utils';
|
|
2
2
|
import { compile } from '../compile';
|
|
3
3
|
import { lernaExec } from '../lerna-exec';
|
|
4
|
+
import { resolveBundler } from '../resolve-bundler';
|
|
4
5
|
|
|
5
6
|
jest.mock('../lerna-exec', () => ({
|
|
6
7
|
lernaExec: jest.fn(),
|
|
7
8
|
}));
|
|
8
9
|
|
|
10
|
+
jest.mock('../resolve-bundler', () => ({
|
|
11
|
+
resolveBundler: jest.fn(() => 'webpack'),
|
|
12
|
+
}));
|
|
13
|
+
|
|
9
14
|
describe('[startup] Cli Utils', () => {
|
|
10
15
|
const packages = ['foo', 'bar'];
|
|
11
16
|
let args: Parameters<typeof compile>[0];
|
|
@@ -13,17 +18,25 @@ describe('[startup] Cli Utils', () => {
|
|
|
13
18
|
beforeEach(() => {
|
|
14
19
|
jest.clearAllMocks();
|
|
15
20
|
jest.spyOn(log, 'info').mockImplementation(jest.fn()); // suppress output
|
|
21
|
+
jest.mocked(resolveBundler).mockReturnValue('webpack');
|
|
16
22
|
args = { packages };
|
|
17
23
|
});
|
|
18
24
|
|
|
19
|
-
function itRunsSwcCompilePackage({
|
|
25
|
+
function itRunsSwcCompilePackage({
|
|
26
|
+
reactRefresh,
|
|
27
|
+
watch,
|
|
28
|
+
}: { reactRefresh?: boolean; watch?: boolean } = {}) {
|
|
29
|
+
const options = [watch && '--watch', watch && reactRefresh && '--react-refresh'].filter(
|
|
30
|
+
option => typeof option === 'string'
|
|
31
|
+
);
|
|
32
|
+
|
|
20
33
|
expect(lernaExec).toHaveBeenCalledWith({
|
|
21
34
|
cmd: 'startup task swc-compile-package',
|
|
22
35
|
parallel: true,
|
|
23
36
|
scope: packages,
|
|
24
37
|
stream: true,
|
|
25
38
|
stdio: watch ? ['inherit', 'pipe', 'inherit'] : 'inherit',
|
|
26
|
-
...(
|
|
39
|
+
...(options.length ? { '--': options } : {}),
|
|
27
40
|
});
|
|
28
41
|
}
|
|
29
42
|
|
|
@@ -44,6 +57,28 @@ describe('[startup] Cli Utils', () => {
|
|
|
44
57
|
|
|
45
58
|
itRunsSwcCompilePackage({ watch: true });
|
|
46
59
|
});
|
|
60
|
+
|
|
61
|
+
describe('when bundler is vite', () => {
|
|
62
|
+
beforeEach(() => jest.mocked(resolveBundler).mockReturnValue('vite'));
|
|
63
|
+
|
|
64
|
+
test('enables react refresh and watch', async () => {
|
|
65
|
+
await subject();
|
|
66
|
+
|
|
67
|
+
itRunsSwcCompilePackage({ reactRefresh: true, watch: true });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('with "useTsc"', () => {
|
|
71
|
+
beforeEach(() => (args.useTsc = true));
|
|
72
|
+
|
|
73
|
+
test('does not enable react refresh', async () => {
|
|
74
|
+
await subject();
|
|
75
|
+
|
|
76
|
+
expect(lernaExec).toHaveBeenCalledWith(
|
|
77
|
+
expect.objectContaining({ '--': ['--watch'] })
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
47
82
|
});
|
|
48
83
|
|
|
49
84
|
describe('with "useTsc"', () => {
|
|
@@ -68,7 +68,7 @@ describe(`[startup] cli utils (${copyFiles.name})`, () => {
|
|
|
68
68
|
|
|
69
69
|
const subject = async () => copyFiles(options);
|
|
70
70
|
|
|
71
|
-
test('copies
|
|
71
|
+
test('copies supported files from source to destination', async () => {
|
|
72
72
|
await subject();
|
|
73
73
|
|
|
74
74
|
expect(cpx.copySync).toHaveBeenCalledWith(files, destination);
|