@servicetitan/startup 37.0.2 → 38.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (433) hide show
  1. package/bin/js-yaml.js +2 -2
  2. package/dist/cli/commands/build.d.ts.map +1 -1
  3. package/dist/cli/commands/build.js +22 -9
  4. package/dist/cli/commands/build.js.map +1 -1
  5. package/dist/cli/commands/bundle-package.d.ts +6 -0
  6. package/dist/cli/commands/bundle-package.d.ts.map +1 -0
  7. package/dist/cli/commands/bundle-package.js +59 -0
  8. package/dist/cli/commands/bundle-package.js.map +1 -0
  9. package/dist/cli/commands/bundle-vite.js +13 -4
  10. package/dist/cli/commands/bundle-vite.js.map +1 -1
  11. package/dist/cli/commands/bundle-webpack.js +13 -4
  12. package/dist/cli/commands/bundle-webpack.js.map +1 -1
  13. package/dist/cli/commands/clean.js +13 -4
  14. package/dist/cli/commands/clean.js.map +1 -1
  15. package/dist/cli/commands/command.d.ts +9 -0
  16. package/dist/cli/commands/command.d.ts.map +1 -0
  17. package/dist/cli/commands/command.js +35 -0
  18. package/dist/cli/commands/command.js.map +1 -0
  19. package/dist/cli/commands/convert-eslint-config.js +14 -7
  20. package/dist/cli/commands/convert-eslint-config.js.map +1 -1
  21. package/dist/cli/commands/eslint.js +13 -4
  22. package/dist/cli/commands/eslint.js.map +1 -1
  23. package/dist/cli/commands/init.js +13 -4
  24. package/dist/cli/commands/init.js.map +1 -1
  25. package/dist/cli/commands/install.js +13 -4
  26. package/dist/cli/commands/install.js.map +1 -1
  27. package/dist/cli/commands/kendo-ui-license.js +13 -4
  28. package/dist/cli/commands/kendo-ui-license.js.map +1 -1
  29. package/dist/cli/commands/lint.js +13 -4
  30. package/dist/cli/commands/lint.js.map +1 -1
  31. package/dist/cli/commands/mfe-check.d.ts.map +1 -1
  32. package/dist/cli/commands/mfe-check.js +15 -7
  33. package/dist/cli/commands/mfe-check.js.map +1 -1
  34. package/dist/cli/commands/mfe-generate-metadata.js +13 -4
  35. package/dist/cli/commands/mfe-generate-metadata.js.map +1 -1
  36. package/dist/cli/commands/mfe-list.js +13 -4
  37. package/dist/cli/commands/mfe-list.js.map +1 -1
  38. package/dist/cli/commands/mfe-package-clean.js +13 -4
  39. package/dist/cli/commands/mfe-package-clean.js.map +1 -1
  40. package/dist/cli/commands/mfe-package-publish.js +13 -4
  41. package/dist/cli/commands/mfe-package-publish.js.map +1 -1
  42. package/dist/cli/commands/mfe-package-rollback.js +13 -4
  43. package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
  44. package/dist/cli/commands/mfe-publish.js +13 -4
  45. package/dist/cli/commands/mfe-publish.js.map +1 -1
  46. package/dist/cli/commands/mfe-purge-cache.js +13 -4
  47. package/dist/cli/commands/mfe-purge-cache.js.map +1 -1
  48. package/dist/cli/commands/prepare-package.js +13 -4
  49. package/dist/cli/commands/prepare-package.js.map +1 -1
  50. package/dist/cli/commands/registry/build.d.ts +1 -1
  51. package/dist/cli/commands/registry/build.d.ts.map +1 -1
  52. package/dist/cli/commands/registry/build.js +3 -5
  53. package/dist/cli/commands/registry/build.js.map +1 -1
  54. package/dist/cli/commands/registry/bundle-package.d.ts +41 -0
  55. package/dist/cli/commands/registry/bundle-package.d.ts.map +1 -0
  56. package/dist/cli/commands/registry/bundle-package.js +54 -0
  57. package/dist/cli/commands/registry/bundle-package.js.map +1 -0
  58. package/dist/cli/commands/registry/command-registry.d.ts +42 -2
  59. package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
  60. package/dist/cli/commands/registry/command-registry.js +10 -19
  61. package/dist/cli/commands/registry/command-registry.js.map +1 -1
  62. package/dist/cli/commands/registry/start.d.ts +1 -1
  63. package/dist/cli/commands/registry/start.d.ts.map +1 -1
  64. package/dist/cli/commands/registry/start.js +3 -5
  65. package/dist/cli/commands/registry/start.js.map +1 -1
  66. package/dist/cli/commands/review/review.js +14 -7
  67. package/dist/cli/commands/review/review.js.map +1 -1
  68. package/dist/cli/commands/review/rules/no-deprecated-content-base.js +1 -3
  69. package/dist/cli/commands/review/rules/no-deprecated-content-base.js.map +1 -1
  70. package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js +1 -3
  71. package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js.map +1 -1
  72. package/dist/cli/commands/review/rules/no-typescript-entry-point.js +1 -3
  73. package/dist/cli/commands/review/rules/no-typescript-entry-point.js.map +1 -1
  74. package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js +5 -12
  75. package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js.map +1 -1
  76. package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js +5 -12
  77. package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js.map +1 -1
  78. package/dist/cli/commands/review/rules/require-explicit-side-effects.js +1 -3
  79. package/dist/cli/commands/review/rules/require-explicit-side-effects.js.map +1 -1
  80. package/dist/cli/commands/review/rules/require-one-collection-version.js +1 -3
  81. package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
  82. package/dist/cli/commands/review/rules/require-servicetitan-scope.js +1 -3
  83. package/dist/cli/commands/review/rules/require-servicetitan-scope.js.map +1 -1
  84. package/dist/cli/commands/review/rules/require-tsconfig-references.js +1 -3
  85. package/dist/cli/commands/review/rules/require-tsconfig-references.js.map +1 -1
  86. package/dist/cli/commands/review/types.d.ts.map +1 -1
  87. package/dist/cli/commands/review/types.js.map +1 -1
  88. package/dist/cli/commands/review/utils/compare-version.js +8 -19
  89. package/dist/cli/commands/review/utils/compare-version.js.map +1 -1
  90. package/dist/cli/commands/run-task.d.ts +1 -0
  91. package/dist/cli/commands/run-task.d.ts.map +1 -1
  92. package/dist/cli/commands/run-task.js +20 -6
  93. package/dist/cli/commands/run-task.js.map +1 -1
  94. package/dist/cli/commands/start.d.ts.map +1 -1
  95. package/dist/cli/commands/start.js +28 -13
  96. package/dist/cli/commands/start.js.map +1 -1
  97. package/dist/cli/commands/stylelint.js +13 -4
  98. package/dist/cli/commands/stylelint.js.map +1 -1
  99. package/dist/cli/commands/styles-check.js +13 -4
  100. package/dist/cli/commands/styles-check.js.map +1 -1
  101. package/dist/cli/commands/test/runners/jest.js +1 -3
  102. package/dist/cli/commands/test/runners/jest.js.map +1 -1
  103. package/dist/cli/commands/test/tests.js +13 -4
  104. package/dist/cli/commands/test/tests.js.map +1 -1
  105. package/dist/cli/commands/types.d.ts +1 -6
  106. package/dist/cli/commands/types.d.ts.map +1 -1
  107. package/dist/cli/commands/types.js +2 -20
  108. package/dist/cli/commands/types.js.map +1 -1
  109. package/dist/cli/commands/upload-sourcemaps.js +17 -13
  110. package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
  111. package/dist/cli/index.js +1 -0
  112. package/dist/cli/index.js.map +1 -1
  113. package/dist/cli/tasks/cli-task.d.ts +3 -0
  114. package/dist/cli/tasks/cli-task.d.ts.map +1 -1
  115. package/dist/cli/tasks/cli-task.js +41 -9
  116. package/dist/cli/tasks/cli-task.js.map +1 -1
  117. package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts +9 -1
  118. package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts.map +1 -1
  119. package/dist/cli/tasks/swc-compile-package/get-swc-options.js +18 -2
  120. package/dist/cli/tasks/swc-compile-package/get-swc-options.js.map +1 -1
  121. package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts +3 -1
  122. package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts.map +1 -1
  123. package/dist/cli/tasks/swc-compile-package/swc-compile-package.js +17 -3
  124. package/dist/cli/tasks/swc-compile-package/swc-compile-package.js.map +1 -1
  125. package/dist/cli/tasks/task.d.ts +2 -1
  126. package/dist/cli/tasks/task.d.ts.map +1 -1
  127. package/dist/cli/tasks/task.js +6 -3
  128. package/dist/cli/tasks/task.js.map +1 -1
  129. package/dist/cli/tasks/tsc-compile/tsc-compile.js +1 -3
  130. package/dist/cli/tasks/tsc-compile/tsc-compile.js.map +1 -1
  131. package/dist/cli/utils/cli-npm.d.ts.map +1 -1
  132. package/dist/cli/utils/cli-npm.js +8 -1
  133. package/dist/cli/utils/cli-npm.js.map +1 -1
  134. package/dist/cli/utils/cli-os.d.ts +1 -0
  135. package/dist/cli/utils/cli-os.d.ts.map +1 -1
  136. package/dist/cli/utils/cli-os.js +20 -0
  137. package/dist/cli/utils/cli-os.js.map +1 -1
  138. package/dist/cli/utils/compile.d.ts.map +1 -1
  139. package/dist/cli/utils/compile.js +7 -4
  140. package/dist/cli/utils/compile.js.map +1 -1
  141. package/dist/cli/utils/copy-files.js +1 -0
  142. package/dist/cli/utils/copy-files.js.map +1 -1
  143. package/dist/cli/utils/index.d.ts +1 -1
  144. package/dist/cli/utils/index.d.ts.map +1 -1
  145. package/dist/cli/utils/index.js +1 -1
  146. package/dist/cli/utils/index.js.map +1 -1
  147. package/dist/cli/utils/process-tree.js +2 -6
  148. package/dist/cli/utils/process-tree.js.map +1 -1
  149. package/dist/cli/utils/resolve-bundler.d.ts.map +1 -1
  150. package/dist/cli/utils/resolve-bundler.js +2 -1
  151. package/dist/cli/utils/resolve-bundler.js.map +1 -1
  152. package/dist/cli/utils/ts-config.d.ts +1 -1
  153. package/dist/cli/utils/ts-config.d.ts.map +1 -1
  154. package/dist/cli/utils/ts-config.js +1 -3
  155. package/dist/cli/utils/ts-config.js.map +1 -1
  156. package/dist/cli/utils/with-exponential-backoff.d.ts +7 -0
  157. package/dist/cli/utils/with-exponential-backoff.d.ts.map +1 -0
  158. package/dist/cli/utils/with-exponential-backoff.js +28 -0
  159. package/dist/cli/utils/with-exponential-backoff.js.map +1 -0
  160. package/dist/core/constants.d.ts +2 -0
  161. package/dist/core/constants.d.ts.map +1 -1
  162. package/dist/core/constants.js +6 -1
  163. package/dist/core/constants.js.map +1 -1
  164. package/dist/cypress/config/vite-config.d.ts.map +1 -1
  165. package/dist/cypress/config/vite-config.js +23 -3
  166. package/dist/cypress/config/vite-config.js.map +1 -1
  167. package/dist/cypress/config/webpack-config.d.ts.map +1 -1
  168. package/dist/cypress/config/webpack-config.js +5 -0
  169. package/dist/cypress/config/webpack-config.js.map +1 -1
  170. package/dist/postinstall.js +118 -0
  171. package/dist/scripts/generate-bin-wrappers.js +203 -0
  172. package/dist/storybook-config/swc.d.ts +6 -0
  173. package/dist/storybook-config/swc.d.ts.map +1 -1
  174. package/dist/storybook-config/vite-final.d.ts.map +1 -1
  175. package/dist/storybook-config/vite-final.js +32 -6
  176. package/dist/storybook-config/vite-final.js.map +1 -1
  177. package/dist/storybook-config/webpack-final.d.ts.map +1 -1
  178. package/dist/storybook-config/webpack-final.js +3 -1
  179. package/dist/storybook-config/webpack-final.js.map +1 -1
  180. package/dist/utils/exit-when-parent-exits.d.ts +6 -0
  181. package/dist/utils/exit-when-parent-exits.d.ts.map +1 -0
  182. package/dist/utils/exit-when-parent-exits.js +37 -0
  183. package/dist/utils/exit-when-parent-exits.js.map +1 -0
  184. package/dist/utils/find-up.d.ts +1 -1
  185. package/dist/utils/find-up.d.ts.map +1 -1
  186. package/dist/utils/find-up.js +2 -2
  187. package/dist/utils/find-up.js.map +1 -1
  188. package/dist/utils/get-configuration.d.ts +6 -3
  189. package/dist/utils/get-configuration.d.ts.map +1 -1
  190. package/dist/utils/get-configuration.js +10 -2
  191. package/dist/utils/get-configuration.js.map +1 -1
  192. package/dist/utils/index.d.ts +1 -0
  193. package/dist/utils/index.d.ts.map +1 -1
  194. package/dist/utils/index.js +1 -0
  195. package/dist/utils/index.js.map +1 -1
  196. package/dist/utils/log.js +1 -3
  197. package/dist/utils/log.js.map +1 -1
  198. package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
  199. package/dist/vite/build-shared-dependencies.js +2 -0
  200. package/dist/vite/build-shared-dependencies.js.map +1 -1
  201. package/dist/vite/config/base-config.d.ts.map +1 -1
  202. package/dist/vite/config/base-config.js +14 -1
  203. package/dist/vite/config/base-config.js.map +1 -1
  204. package/dist/vite/config/create-filtering-logger.d.ts.map +1 -1
  205. package/dist/vite/config/create-filtering-logger.js +12 -1
  206. package/dist/vite/config/create-filtering-logger.js.map +1 -1
  207. package/dist/vite/config/create-vite-build-context.d.ts.map +1 -1
  208. package/dist/vite/config/create-vite-build-context.js +4 -1
  209. package/dist/vite/config/create-vite-build-context.js.map +1 -1
  210. package/dist/vite/config/create-vite-config.js +7 -2
  211. package/dist/vite/config/create-vite-config.js.map +1 -1
  212. package/dist/vite/config/load-config-file.js +8 -19
  213. package/dist/vite/config/load-config-file.js.map +1 -1
  214. package/dist/vite/index.d.ts +2 -0
  215. package/dist/vite/index.d.ts.map +1 -1
  216. package/dist/vite/index.html +2 -2
  217. package/dist/vite/index.js +16 -0
  218. package/dist/vite/index.js.map +1 -1
  219. package/dist/vite/plugins/chain-source-maps-plugin.js +1 -1
  220. package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -1
  221. package/dist/vite/plugins/clean-plugin.js +1 -1
  222. package/dist/vite/plugins/clean-plugin.js.map +1 -1
  223. package/dist/vite/plugins/css-injector-plugin.js +1 -1
  224. package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
  225. package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -1
  226. package/dist/vite/plugins/design-system-guard-plugin.js +10 -5
  227. package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -1
  228. package/dist/vite/plugins/dev-server-routing-plugin.d.ts +1 -1
  229. package/dist/vite/plugins/dev-server-routing-plugin.d.ts.map +1 -1
  230. package/dist/vite/plugins/dev-server-routing-plugin.js +4 -3
  231. package/dist/vite/plugins/dev-server-routing-plugin.js.map +1 -1
  232. package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
  233. package/dist/vite/plugins/externals-plugin.js +11 -5
  234. package/dist/vite/plugins/externals-plugin.js.map +1 -1
  235. package/dist/vite/plugins/html-plugin.d.ts.map +1 -1
  236. package/dist/vite/plugins/html-plugin.js +5 -3
  237. package/dist/vite/plugins/html-plugin.js.map +1 -1
  238. package/dist/vite/plugins/ignore-modules-plugin.d.ts +2 -2
  239. package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
  240. package/dist/vite/plugins/ignore-modules-plugin.js +36 -24
  241. package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
  242. package/dist/vite/plugins/index.d.ts +3 -0
  243. package/dist/vite/plugins/index.d.ts.map +1 -1
  244. package/dist/vite/plugins/index.js +3 -0
  245. package/dist/vite/plugins/index.js.map +1 -1
  246. package/dist/vite/plugins/istanbul-plugin.d.ts.map +1 -1
  247. package/dist/vite/plugins/istanbul-plugin.js +33 -1
  248. package/dist/vite/plugins/istanbul-plugin.js.map +1 -1
  249. package/dist/vite/plugins/less-tilde-plugin.d.ts +8 -0
  250. package/dist/vite/plugins/less-tilde-plugin.d.ts.map +1 -0
  251. package/dist/vite/plugins/less-tilde-plugin.js +53 -0
  252. package/dist/vite/plugins/less-tilde-plugin.js.map +1 -0
  253. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +1 -1
  254. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -1
  255. package/dist/vite/plugins/metadata-plugin.js +1 -1
  256. package/dist/vite/plugins/metadata-plugin.js.map +1 -1
  257. package/dist/vite/plugins/moment-locales-plugin.d.ts +1 -1
  258. package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -1
  259. package/dist/vite/plugins/moment-locales-plugin.js +30 -14
  260. package/dist/vite/plugins/moment-locales-plugin.js.map +1 -1
  261. package/dist/vite/plugins/react-refresh-plugin/index.d.ts +2 -0
  262. package/dist/vite/plugins/react-refresh-plugin/index.d.ts.map +1 -0
  263. package/dist/vite/plugins/react-refresh-plugin/index.js +20 -0
  264. package/dist/vite/plugins/react-refresh-plugin/index.js.map +1 -0
  265. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts +4 -0
  266. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts.map +1 -0
  267. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js +143 -0
  268. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js.map +1 -0
  269. package/dist/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
  270. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -1
  271. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js +14 -11
  272. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -1
  273. package/dist/vite/plugins/style-urls-plugin.js +1 -1
  274. package/dist/vite/plugins/style-urls-plugin.js.map +1 -1
  275. package/dist/vite/plugins/virtual-modules-plugin.d.ts.map +1 -1
  276. package/dist/vite/plugins/virtual-modules-plugin.js +9 -6
  277. package/dist/vite/plugins/virtual-modules-plugin.js.map +1 -1
  278. package/dist/vite/plugins/window-externals-plugin.d.ts +22 -0
  279. package/dist/vite/plugins/window-externals-plugin.d.ts.map +1 -0
  280. package/dist/vite/plugins/window-externals-plugin.js +74 -0
  281. package/dist/vite/plugins/window-externals-plugin.js.map +1 -0
  282. package/dist/vite/types.d.ts +4 -1
  283. package/dist/vite/types.d.ts.map +1 -1
  284. package/dist/webpack/bundle-webpack.d.ts.map +1 -1
  285. package/dist/webpack/bundle-webpack.js +6 -1
  286. package/dist/webpack/bundle-webpack.js.map +1 -1
  287. package/dist/webpack/configs/optimization-config.js +4 -4
  288. package/dist/webpack/configs/optimization-config.js.map +1 -1
  289. package/dist/webpack/configs/output-config.js +1 -1
  290. package/dist/webpack/configs/output-config.js.map +1 -1
  291. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +1 -3
  292. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
  293. package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/configuration.expose-loader.js +13 -0
  294. package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/index.js +1 -0
  295. package/dist/webpack/utils/index.d.ts +1 -0
  296. package/dist/webpack/utils/index.d.ts.map +1 -1
  297. package/dist/webpack/utils/index.js +1 -0
  298. package/dist/webpack/utils/index.js.map +1 -1
  299. package/dist/webpack/utils/normalize-proxy-config.d.ts +6 -0
  300. package/dist/webpack/utils/normalize-proxy-config.d.ts.map +1 -0
  301. package/dist/webpack/utils/normalize-proxy-config.js +52 -0
  302. package/dist/webpack/utils/normalize-proxy-config.js.map +1 -0
  303. package/package.json +25 -22
  304. package/src/cli/commands/__tests__/build.test.ts +33 -19
  305. package/src/cli/commands/__tests__/bundle-package.test.ts +65 -0
  306. package/src/cli/commands/__tests__/bundle-vite.test.ts +1 -0
  307. package/src/cli/commands/__tests__/command.test.ts +42 -0
  308. package/src/cli/commands/__tests__/mfe-check.test.ts +26 -5
  309. package/src/cli/commands/__tests__/run-task.test.ts +20 -1
  310. package/src/cli/commands/__tests__/start.test.ts +35 -15
  311. package/src/cli/commands/build.ts +6 -5
  312. package/src/cli/commands/bundle-package.ts +20 -0
  313. package/src/cli/commands/command.ts +14 -0
  314. package/src/cli/commands/mfe-check.ts +6 -10
  315. package/src/cli/commands/registry/build.ts +3 -2
  316. package/src/cli/commands/registry/bundle-package.ts +22 -0
  317. package/src/cli/commands/registry/command-registry.ts +2 -0
  318. package/src/cli/commands/registry/start.ts +3 -2
  319. package/src/cli/commands/review/types.ts +1 -3
  320. package/src/cli/commands/run-task.ts +8 -2
  321. package/src/cli/commands/start.ts +9 -5
  322. package/src/cli/commands/types.ts +2 -6
  323. package/src/cli/index.ts +3 -0
  324. package/src/cli/tasks/__tests__/cli-task.test.ts +181 -69
  325. package/src/cli/tasks/__tests__/task.test.ts +40 -45
  326. package/src/cli/tasks/cli-task.ts +43 -2
  327. package/src/cli/tasks/swc-compile-package/__tests__/get-swc-options.test.ts +46 -4
  328. package/src/cli/tasks/swc-compile-package/__tests__/swc-compile-package.test.ts +25 -4
  329. package/src/cli/tasks/swc-compile-package/get-swc-options.ts +14 -1
  330. package/src/cli/tasks/swc-compile-package/swc-compile-package.ts +6 -2
  331. package/src/cli/tasks/task.ts +8 -2
  332. package/src/cli/tasks/tsc-compile/__tests__/tsc-compile.test.ts +8 -32
  333. package/src/cli/tasks/tsc-compile-package/__tests__/tsc-compile-package.test.ts +10 -19
  334. package/src/cli/utils/__tests__/cli-npm.test.ts +33 -0
  335. package/src/cli/utils/__tests__/cli-os.test.ts +86 -3
  336. package/src/cli/utils/__tests__/compile.test.ts +37 -2
  337. package/src/cli/utils/__tests__/copy-files.test.ts +1 -1
  338. package/src/cli/utils/__tests__/with-exponential-backoff.test.ts +119 -0
  339. package/src/cli/utils/cli-npm.ts +19 -4
  340. package/src/cli/utils/cli-os.ts +14 -0
  341. package/src/cli/utils/compile.ts +8 -1
  342. package/src/cli/utils/copy-files.ts +1 -1
  343. package/src/cli/utils/index.ts +1 -1
  344. package/src/cli/utils/resolve-bundler.ts +2 -1
  345. package/src/cli/utils/ts-config.ts +1 -1
  346. package/src/cli/utils/with-exponential-backoff.ts +28 -0
  347. package/src/core/constants.ts +2 -0
  348. package/src/cypress/config/__tests__/vite-config.test.ts +21 -11
  349. package/src/cypress/config/__tests__/webpack-config.test.ts +17 -0
  350. package/src/cypress/config/vite-config.ts +18 -3
  351. package/src/cypress/config/webpack-config.ts +2 -0
  352. package/src/storybook-config/__tests__/vite-final.test.ts +71 -11
  353. package/src/storybook-config/__tests__/webpack-final.test.ts +30 -6
  354. package/src/storybook-config/vite-final.ts +23 -2
  355. package/src/storybook-config/webpack-final.ts +10 -2
  356. package/src/utils/__tests__/exit-when-parent-exits.test.ts +87 -0
  357. package/src/utils/__tests__/find-up.test.ts +49 -0
  358. package/src/utils/__tests__/get-configuration.test.ts +62 -0
  359. package/src/utils/exit-when-parent-exits.ts +33 -0
  360. package/src/utils/find-up.ts +2 -2
  361. package/src/utils/get-configuration.ts +14 -5
  362. package/src/utils/index.ts +1 -0
  363. package/src/vite/__tests__/build-shared-dependencies.test.ts +39 -5
  364. package/src/vite/build-shared-dependencies.ts +2 -1
  365. package/src/vite/config/__tests__/base-config.test.ts +16 -4
  366. package/src/vite/config/__tests__/create-css-config.test.ts +2 -6
  367. package/src/vite/config/__tests__/create-filtering-logger.test.ts +9 -0
  368. package/src/vite/config/__tests__/create-vite-build-context.test.ts +25 -0
  369. package/src/vite/config/__tests__/create-vite-config.test.ts +6 -3
  370. package/src/vite/config/base-config.ts +18 -2
  371. package/src/vite/config/create-filtering-logger.ts +13 -2
  372. package/src/vite/config/create-vite-build-context.ts +1 -0
  373. package/src/vite/config/create-vite-config.ts +6 -3
  374. package/src/vite/index.html +2 -2
  375. package/src/vite/index.ts +2 -0
  376. package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +1 -1
  377. package/src/vite/plugins/__tests__/clean-plugin.test.ts +1 -1
  378. package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
  379. package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +15 -3
  380. package/src/vite/plugins/__tests__/dev-server-routing-plugin.test.ts +121 -99
  381. package/src/vite/plugins/__tests__/externals-plugin.test.ts +24 -3
  382. package/src/vite/plugins/__tests__/html-plugin.test.ts +10 -3
  383. package/src/vite/plugins/__tests__/html-template.test.ts +10 -2
  384. package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +30 -6
  385. package/src/vite/plugins/__tests__/istanbul-plugin.test.ts +42 -1
  386. package/src/vite/plugins/__tests__/less-tilde-plugin.test.ts +91 -0
  387. package/src/vite/plugins/__tests__/metadata-plugin.test.ts +1 -1
  388. package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +35 -25
  389. package/src/vite/plugins/__tests__/style-urls-plugin.test.ts +1 -1
  390. package/src/vite/plugins/__tests__/virtual-modules-plugin.test.ts +20 -9
  391. package/src/vite/plugins/__tests__/window-externals-plugin.test.ts +128 -0
  392. package/src/vite/plugins/chain-source-maps-plugin.ts +1 -1
  393. package/src/vite/plugins/clean-plugin.ts +1 -1
  394. package/src/vite/plugins/css-injector-plugin.ts +1 -1
  395. package/src/vite/plugins/design-system-guard-plugin.ts +11 -8
  396. package/src/vite/plugins/dev-server-routing-plugin.ts +4 -4
  397. package/src/vite/plugins/externals-plugin.ts +15 -6
  398. package/src/vite/plugins/html-plugin.ts +4 -2
  399. package/src/vite/plugins/ignore-modules-plugin.ts +32 -23
  400. package/src/vite/plugins/index.ts +3 -0
  401. package/src/vite/plugins/istanbul-plugin.ts +28 -1
  402. package/src/vite/plugins/less-tilde-plugin.ts +64 -0
  403. package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +1 -1
  404. package/src/vite/plugins/metadata-plugin.ts +1 -1
  405. package/src/vite/plugins/moment-locales-plugin.ts +24 -14
  406. package/src/vite/plugins/react-refresh-plugin/README.md +165 -0
  407. package/src/vite/plugins/react-refresh-plugin/__tests__/react-refresh-plugin.test.ts +366 -0
  408. package/src/vite/plugins/react-refresh-plugin/__tests__/refresh-runtime.test.ts +193 -0
  409. package/src/vite/plugins/react-refresh-plugin/index.ts +1 -0
  410. package/src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts +144 -0
  411. package/src/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
  412. package/src/vite/plugins/shared-dependencies-plugin/__tests__/shared-dependencies-plugin.test.ts +21 -16
  413. package/src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts +13 -12
  414. package/src/vite/plugins/style-urls-plugin.ts +1 -1
  415. package/src/vite/plugins/virtual-modules-plugin.ts +8 -7
  416. package/src/vite/plugins/window-externals-plugin.ts +94 -0
  417. package/src/vite/types.ts +4 -1
  418. package/src/webpack/__tests__/bundle-webpack.test.ts +32 -0
  419. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +17 -5
  420. package/src/webpack/__tests__/create-webpack-config.test.ts +10 -6
  421. package/src/webpack/bundle-webpack.ts +7 -1
  422. package/src/webpack/configs/optimization-config.ts +3 -3
  423. package/src/webpack/configs/output-config.ts +1 -1
  424. package/src/webpack/utils/__tests__/normalize-proxy-config.test.ts +121 -0
  425. package/src/webpack/utils/index.ts +1 -0
  426. package/src/webpack/utils/normalize-proxy-config.ts +59 -0
  427. package/tsconfig/types.d.ts +10 -0
  428. package/dist/cli/utils/get-bundle-command.d.ts +0 -3
  429. package/dist/cli/utils/get-bundle-command.d.ts.map +0 -1
  430. package/dist/cli/utils/get-bundle-command.js +0 -16
  431. package/dist/cli/utils/get-bundle-command.js.map +0 -1
  432. package/src/cli/utils/__tests__/get-bundle-command.test.ts +0 -23
  433. package/src/cli/utils/get-bundle-command.ts +0 -5
@@ -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 GlobalTask extends Task {
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
- describe('Global task', () => {
44
- const subject = () => new GlobalTask();
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 the arbitrary directory", () => {
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('Package task', () => {
68
- const subject = () => new PackageTask();
64
+ describe('watchForParentExit', () => {
65
+ const subject = () => new MockTask(args).watchForParentExit();
69
66
 
70
- test('runs from the package directory', () => {
71
- jest.mocked(readJsonSafe).mockReturnValueOnce({});
67
+ test('does not watch for the parent process to exit', () => {
68
+ subject();
72
69
 
73
- expect(subject).not.toThrow();
70
+ expect(exitWhenParentExits).not.toHaveBeenCalled();
74
71
  });
75
72
 
76
- test("doesn't run from the workspace root directory", () => {
77
- jest.mocked(readJsonSafe).mockReturnValueOnce({ workspaces: ['packages/*'] });
78
-
79
- expect(subject).toThrow();
80
- });
73
+ describe('with watch: true', () => {
74
+ beforeEach(() => (args.watch = true));
81
75
 
82
- test("doesn't run from arbitrary directory", () => {
83
- jest.mocked(readJsonSafe).mockReturnValueOnce(undefined);
76
+ test('watches for the parent process to exit', () => {
77
+ subject();
84
78
 
85
- expect(subject).toThrow();
79
+ expect(exitWhenParentExits).toHaveBeenCalledWith(args.name);
80
+ });
86
81
  });
87
82
  });
88
83
  });
@@ -1,5 +1,6 @@
1
- import execa from 'execa';
2
- import { pipeStdout, watchStdout } from '../utils';
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
- 'tsconfig.json': JSON.stringify(config),
16
+ [tsConfigPath]: JSON.stringify(config),
13
17
  });
14
18
  }
15
19
 
16
20
  beforeEach(() => {
17
- tsConfig = new TSConfig('tsconfig.json');
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 { getSwcOptions } from '../get-swc-options';
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(() => vol.reset());
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(new TSConfig('tsconfig.json')),
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
  });
@@ -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
- constructor({ watch }: Args) {
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 }
@@ -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
- private readonly name: string;
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 { log } from '../../../../utils';
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.clearAllMocks();
50
- jest.spyOn(log, 'info').mockImplementation(jest.fn()); // suppress log output
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(execa).toHaveBeenCalledWith(
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 execa from 'execa';
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 execa', () => {
49
+ test('calls runChildProcess', () => {
55
50
  subject();
56
51
 
57
- expect(execa).toHaveBeenCalledWith('tsc', tscOptions, {
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 execa', () => {
58
+ test('calls runChildProcess', () => {
66
59
  subject();
67
60
 
68
- expect(execa).toHaveBeenCalledWith('tsc', ['-w', ...tscOptions], {
69
- stdio: ['inherit', 'pipe', 'inherit'],
70
- });
61
+ expect(runChildProcessSpy).toHaveBeenCalledWith('tsc', ['-w', ...tscOptions]);
71
62
  });
72
63
  });
73
64
  });
@@ -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, () => {