@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.
Files changed (429) 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 +32 -10
  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 +13 -0
  16. package/dist/cli/commands/command.d.ts.map +1 -0
  17. package/dist/cli/commands/command.js +74 -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.d.ts.map +1 -1
  24. package/dist/cli/commands/init.js +13 -5
  25. package/dist/cli/commands/init.js.map +1 -1
  26. package/dist/cli/commands/install.d.ts.map +1 -1
  27. package/dist/cli/commands/install.js +14 -21
  28. package/dist/cli/commands/install.js.map +1 -1
  29. package/dist/cli/commands/kendo-ui-license.js +13 -4
  30. package/dist/cli/commands/kendo-ui-license.js.map +1 -1
  31. package/dist/cli/commands/lint.js +13 -4
  32. package/dist/cli/commands/lint.js.map +1 -1
  33. package/dist/cli/commands/mfe-check.d.ts.map +1 -1
  34. package/dist/cli/commands/mfe-check.js +15 -7
  35. package/dist/cli/commands/mfe-check.js.map +1 -1
  36. package/dist/cli/commands/mfe-generate-metadata.js +13 -4
  37. package/dist/cli/commands/mfe-generate-metadata.js.map +1 -1
  38. package/dist/cli/commands/mfe-list.js +13 -4
  39. package/dist/cli/commands/mfe-list.js.map +1 -1
  40. package/dist/cli/commands/mfe-package-clean.js +13 -4
  41. package/dist/cli/commands/mfe-package-clean.js.map +1 -1
  42. package/dist/cli/commands/mfe-package-publish.js +13 -4
  43. package/dist/cli/commands/mfe-package-publish.js.map +1 -1
  44. package/dist/cli/commands/mfe-package-rollback.js +13 -4
  45. package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
  46. package/dist/cli/commands/mfe-publish.js +13 -4
  47. package/dist/cli/commands/mfe-publish.js.map +1 -1
  48. package/dist/cli/commands/mfe-purge-cache.js +13 -4
  49. package/dist/cli/commands/mfe-purge-cache.js.map +1 -1
  50. package/dist/cli/commands/prepare-package.js +13 -4
  51. package/dist/cli/commands/prepare-package.js.map +1 -1
  52. package/dist/cli/commands/registry/build.d.ts +1 -1
  53. package/dist/cli/commands/registry/build.d.ts.map +1 -1
  54. package/dist/cli/commands/registry/build.js +3 -5
  55. package/dist/cli/commands/registry/build.js.map +1 -1
  56. package/dist/cli/commands/registry/bundle-package.d.ts +41 -0
  57. package/dist/cli/commands/registry/bundle-package.d.ts.map +1 -0
  58. package/dist/cli/commands/registry/bundle-package.js +54 -0
  59. package/dist/cli/commands/registry/bundle-package.js.map +1 -0
  60. package/dist/cli/commands/registry/command-registry.d.ts +42 -18
  61. package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
  62. package/dist/cli/commands/registry/command-registry.js +10 -19
  63. package/dist/cli/commands/registry/command-registry.js.map +1 -1
  64. package/dist/cli/commands/registry/install.d.ts +0 -16
  65. package/dist/cli/commands/registry/install.d.ts.map +1 -1
  66. package/dist/cli/commands/registry/install.js +1 -17
  67. package/dist/cli/commands/registry/install.js.map +1 -1
  68. package/dist/cli/commands/registry/start.d.ts +1 -1
  69. package/dist/cli/commands/registry/start.d.ts.map +1 -1
  70. package/dist/cli/commands/registry/start.js +3 -5
  71. package/dist/cli/commands/registry/start.js.map +1 -1
  72. package/dist/cli/commands/review/review.js +14 -7
  73. package/dist/cli/commands/review/review.js.map +1 -1
  74. package/dist/cli/commands/review/rules/no-deprecated-content-base.js +1 -3
  75. package/dist/cli/commands/review/rules/no-deprecated-content-base.js.map +1 -1
  76. package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js +1 -3
  77. package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js.map +1 -1
  78. package/dist/cli/commands/review/rules/no-typescript-entry-point.js +1 -3
  79. package/dist/cli/commands/review/rules/no-typescript-entry-point.js.map +1 -1
  80. package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js +5 -12
  81. package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js.map +1 -1
  82. package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js +5 -12
  83. package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js.map +1 -1
  84. package/dist/cli/commands/review/rules/require-explicit-side-effects.js +1 -3
  85. package/dist/cli/commands/review/rules/require-explicit-side-effects.js.map +1 -1
  86. package/dist/cli/commands/review/rules/require-one-collection-version.js +1 -3
  87. package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
  88. package/dist/cli/commands/review/rules/require-servicetitan-scope.js +1 -3
  89. package/dist/cli/commands/review/rules/require-servicetitan-scope.js.map +1 -1
  90. package/dist/cli/commands/review/rules/require-tsconfig-references.js +1 -3
  91. package/dist/cli/commands/review/rules/require-tsconfig-references.js.map +1 -1
  92. package/dist/cli/commands/review/utils/compare-version.js +8 -19
  93. package/dist/cli/commands/review/utils/compare-version.js.map +1 -1
  94. package/dist/cli/commands/run-task.d.ts +1 -0
  95. package/dist/cli/commands/run-task.d.ts.map +1 -1
  96. package/dist/cli/commands/run-task.js +20 -6
  97. package/dist/cli/commands/run-task.js.map +1 -1
  98. package/dist/cli/commands/start.d.ts.map +1 -1
  99. package/dist/cli/commands/start.js +37 -14
  100. package/dist/cli/commands/start.js.map +1 -1
  101. package/dist/cli/commands/stylelint.js +13 -4
  102. package/dist/cli/commands/stylelint.js.map +1 -1
  103. package/dist/cli/commands/styles-check.js +13 -4
  104. package/dist/cli/commands/styles-check.js.map +1 -1
  105. package/dist/cli/commands/test/runners/jest.js +1 -3
  106. package/dist/cli/commands/test/runners/jest.js.map +1 -1
  107. package/dist/cli/commands/test/tests.js +13 -4
  108. package/dist/cli/commands/test/tests.js.map +1 -1
  109. package/dist/cli/commands/types.d.ts +1 -6
  110. package/dist/cli/commands/types.d.ts.map +1 -1
  111. package/dist/cli/commands/types.js +2 -20
  112. package/dist/cli/commands/types.js.map +1 -1
  113. package/dist/cli/commands/upload-sourcemaps.js +17 -13
  114. package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
  115. package/dist/cli/index.js +1 -0
  116. package/dist/cli/index.js.map +1 -1
  117. package/dist/cli/tasks/cli-task.d.ts +3 -0
  118. package/dist/cli/tasks/cli-task.d.ts.map +1 -1
  119. package/dist/cli/tasks/cli-task.js +41 -9
  120. package/dist/cli/tasks/cli-task.js.map +1 -1
  121. package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts +9 -1
  122. package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts.map +1 -1
  123. package/dist/cli/tasks/swc-compile-package/get-swc-options.js +18 -2
  124. package/dist/cli/tasks/swc-compile-package/get-swc-options.js.map +1 -1
  125. package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts +3 -1
  126. package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts.map +1 -1
  127. package/dist/cli/tasks/swc-compile-package/swc-compile-package.js +17 -3
  128. package/dist/cli/tasks/swc-compile-package/swc-compile-package.js.map +1 -1
  129. package/dist/cli/tasks/task.d.ts +2 -1
  130. package/dist/cli/tasks/task.d.ts.map +1 -1
  131. package/dist/cli/tasks/task.js +6 -3
  132. package/dist/cli/tasks/task.js.map +1 -1
  133. package/dist/cli/tasks/tsc-compile/tsc-compile.js +1 -3
  134. package/dist/cli/tasks/tsc-compile/tsc-compile.js.map +1 -1
  135. package/dist/cli/utils/cli-git.d.ts +7 -0
  136. package/dist/cli/utils/cli-git.d.ts.map +1 -1
  137. package/dist/cli/utils/cli-git.js +30 -0
  138. package/dist/cli/utils/cli-git.js.map +1 -1
  139. package/dist/cli/utils/cli-npm.d.ts.map +1 -1
  140. package/dist/cli/utils/cli-npm.js +8 -1
  141. package/dist/cli/utils/cli-npm.js.map +1 -1
  142. package/dist/cli/utils/cli-os.d.ts +7 -1
  143. package/dist/cli/utils/cli-os.d.ts.map +1 -1
  144. package/dist/cli/utils/cli-os.js +42 -0
  145. package/dist/cli/utils/cli-os.js.map +1 -1
  146. package/dist/cli/utils/compile.d.ts.map +1 -1
  147. package/dist/cli/utils/compile.js +7 -4
  148. package/dist/cli/utils/compile.js.map +1 -1
  149. package/dist/cli/utils/copy-files.js +1 -0
  150. package/dist/cli/utils/copy-files.js.map +1 -1
  151. package/dist/cli/utils/index.d.ts +1 -1
  152. package/dist/cli/utils/index.d.ts.map +1 -1
  153. package/dist/cli/utils/index.js +1 -1
  154. package/dist/cli/utils/index.js.map +1 -1
  155. package/dist/cli/utils/process-tree.js +2 -6
  156. package/dist/cli/utils/process-tree.js.map +1 -1
  157. package/dist/cli/utils/resolve-bundler.d.ts.map +1 -1
  158. package/dist/cli/utils/resolve-bundler.js +2 -1
  159. package/dist/cli/utils/resolve-bundler.js.map +1 -1
  160. package/dist/cli/utils/ts-config.d.ts +1 -1
  161. package/dist/cli/utils/ts-config.d.ts.map +1 -1
  162. package/dist/cli/utils/ts-config.js +1 -3
  163. package/dist/cli/utils/ts-config.js.map +1 -1
  164. package/dist/cli/utils/with-exponential-backoff.d.ts +7 -0
  165. package/dist/cli/utils/with-exponential-backoff.d.ts.map +1 -0
  166. package/dist/cli/utils/with-exponential-backoff.js +28 -0
  167. package/dist/cli/utils/with-exponential-backoff.js.map +1 -0
  168. package/dist/core/constants.d.ts +2 -0
  169. package/dist/core/constants.d.ts.map +1 -1
  170. package/dist/core/constants.js +6 -1
  171. package/dist/core/constants.js.map +1 -1
  172. package/dist/postinstall.js +118 -0
  173. package/dist/scripts/generate-bin-wrappers.js +203 -0
  174. package/dist/storybook-config/swc.d.ts +6 -0
  175. package/dist/storybook-config/swc.d.ts.map +1 -1
  176. package/dist/storybook-config/webpack-final.d.ts.map +1 -1
  177. package/dist/storybook-config/webpack-final.js +2 -1
  178. package/dist/storybook-config/webpack-final.js.map +1 -1
  179. package/dist/telemetry/index.d.ts +3 -0
  180. package/dist/telemetry/index.d.ts.map +1 -0
  181. package/dist/telemetry/index.js +21 -0
  182. package/dist/telemetry/index.js.map +1 -0
  183. package/dist/telemetry/telemetry.d.ts +15 -0
  184. package/dist/telemetry/telemetry.d.ts.map +1 -0
  185. package/dist/telemetry/telemetry.js +176 -0
  186. package/dist/telemetry/telemetry.js.map +1 -0
  187. package/dist/utils/exit-when-parent-exits.d.ts +6 -0
  188. package/dist/utils/exit-when-parent-exits.d.ts.map +1 -0
  189. package/dist/utils/exit-when-parent-exits.js +37 -0
  190. package/dist/utils/exit-when-parent-exits.js.map +1 -0
  191. package/dist/utils/find-up.d.ts +1 -1
  192. package/dist/utils/find-up.d.ts.map +1 -1
  193. package/dist/utils/find-up.js +2 -2
  194. package/dist/utils/find-up.js.map +1 -1
  195. package/dist/utils/get-configuration.d.ts +6 -3
  196. package/dist/utils/get-configuration.d.ts.map +1 -1
  197. package/dist/utils/get-configuration.js +10 -2
  198. package/dist/utils/get-configuration.js.map +1 -1
  199. package/dist/utils/index.d.ts +1 -0
  200. package/dist/utils/index.d.ts.map +1 -1
  201. package/dist/utils/index.js +1 -0
  202. package/dist/utils/index.js.map +1 -1
  203. package/dist/utils/log.js +1 -3
  204. package/dist/utils/log.js.map +1 -1
  205. package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
  206. package/dist/vite/build-shared-dependencies.js +2 -0
  207. package/dist/vite/build-shared-dependencies.js.map +1 -1
  208. package/dist/vite/config/base-config.d.ts.map +1 -1
  209. package/dist/vite/config/base-config.js +12 -1
  210. package/dist/vite/config/base-config.js.map +1 -1
  211. package/dist/vite/config/create-filtering-logger.d.ts.map +1 -1
  212. package/dist/vite/config/create-filtering-logger.js +6 -2
  213. package/dist/vite/config/create-filtering-logger.js.map +1 -1
  214. package/dist/vite/config/create-vite-config.js +7 -2
  215. package/dist/vite/config/create-vite-config.js.map +1 -1
  216. package/dist/vite/config/load-config-file.js +8 -19
  217. package/dist/vite/config/load-config-file.js.map +1 -1
  218. package/dist/vite/index.d.ts +2 -0
  219. package/dist/vite/index.d.ts.map +1 -1
  220. package/dist/vite/index.html +2 -2
  221. package/dist/vite/index.js +16 -0
  222. package/dist/vite/index.js.map +1 -1
  223. package/dist/vite/plugins/chain-source-maps-plugin.js +1 -1
  224. package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -1
  225. package/dist/vite/plugins/clean-plugin.js +1 -1
  226. package/dist/vite/plugins/clean-plugin.js.map +1 -1
  227. package/dist/vite/plugins/css-injector-plugin.js +1 -1
  228. package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
  229. package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -1
  230. package/dist/vite/plugins/design-system-guard-plugin.js +10 -5
  231. package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -1
  232. package/dist/vite/plugins/dev-server-routing-plugin.js +1 -1
  233. package/dist/vite/plugins/dev-server-routing-plugin.js.map +1 -1
  234. package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
  235. package/dist/vite/plugins/externals-plugin.js +11 -5
  236. package/dist/vite/plugins/externals-plugin.js.map +1 -1
  237. package/dist/vite/plugins/html-plugin.d.ts.map +1 -1
  238. package/dist/vite/plugins/html-plugin.js +5 -3
  239. package/dist/vite/plugins/html-plugin.js.map +1 -1
  240. package/dist/vite/plugins/ignore-modules-plugin.d.ts +2 -2
  241. package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
  242. package/dist/vite/plugins/ignore-modules-plugin.js +36 -24
  243. package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
  244. package/dist/vite/plugins/index.d.ts +3 -0
  245. package/dist/vite/plugins/index.d.ts.map +1 -1
  246. package/dist/vite/plugins/index.js +3 -0
  247. package/dist/vite/plugins/index.js.map +1 -1
  248. package/dist/vite/plugins/less-tilde-plugin.d.ts +8 -0
  249. package/dist/vite/plugins/less-tilde-plugin.d.ts.map +1 -0
  250. package/dist/vite/plugins/less-tilde-plugin.js +53 -0
  251. package/dist/vite/plugins/less-tilde-plugin.js.map +1 -0
  252. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +1 -1
  253. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -1
  254. package/dist/vite/plugins/metadata-plugin.js +1 -1
  255. package/dist/vite/plugins/metadata-plugin.js.map +1 -1
  256. package/dist/vite/plugins/moment-locales-plugin.d.ts +1 -1
  257. package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -1
  258. package/dist/vite/plugins/moment-locales-plugin.js +30 -14
  259. package/dist/vite/plugins/moment-locales-plugin.js.map +1 -1
  260. package/dist/vite/plugins/react-refresh-plugin/index.d.ts +2 -0
  261. package/dist/vite/plugins/react-refresh-plugin/index.d.ts.map +1 -0
  262. package/dist/vite/plugins/react-refresh-plugin/index.js +20 -0
  263. package/dist/vite/plugins/react-refresh-plugin/index.js.map +1 -0
  264. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts +4 -0
  265. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts.map +1 -0
  266. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js +143 -0
  267. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js.map +1 -0
  268. package/dist/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
  269. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -1
  270. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js +14 -11
  271. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -1
  272. package/dist/vite/plugins/style-urls-plugin.js +1 -1
  273. package/dist/vite/plugins/style-urls-plugin.js.map +1 -1
  274. package/dist/vite/plugins/virtual-modules-plugin.d.ts.map +1 -1
  275. package/dist/vite/plugins/virtual-modules-plugin.js +9 -6
  276. package/dist/vite/plugins/virtual-modules-plugin.js.map +1 -1
  277. package/dist/vite/plugins/window-externals-plugin.d.ts +22 -0
  278. package/dist/vite/plugins/window-externals-plugin.d.ts.map +1 -0
  279. package/dist/vite/plugins/window-externals-plugin.js +74 -0
  280. package/dist/vite/plugins/window-externals-plugin.js.map +1 -0
  281. package/dist/webpack/bundle-webpack.d.ts.map +1 -1
  282. package/dist/webpack/bundle-webpack.js +6 -1
  283. package/dist/webpack/bundle-webpack.js.map +1 -1
  284. package/dist/webpack/configs/optimization-config.js +17 -12
  285. package/dist/webpack/configs/optimization-config.js.map +1 -1
  286. package/dist/webpack/configs/output-config.js +1 -1
  287. package/dist/webpack/configs/output-config.js.map +1 -1
  288. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +1 -3
  289. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
  290. package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/configuration.expose-loader.js +13 -0
  291. package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/index.js +1 -0
  292. package/dist/webpack/utils/index.d.ts +1 -0
  293. package/dist/webpack/utils/index.d.ts.map +1 -1
  294. package/dist/webpack/utils/index.js +1 -0
  295. package/dist/webpack/utils/index.js.map +1 -1
  296. package/dist/webpack/utils/normalize-proxy-config.d.ts +6 -0
  297. package/dist/webpack/utils/normalize-proxy-config.d.ts.map +1 -0
  298. package/dist/webpack/utils/normalize-proxy-config.js +52 -0
  299. package/dist/webpack/utils/normalize-proxy-config.js.map +1 -0
  300. package/package.json +32 -26
  301. package/src/cli/commands/__tests__/build.test.ts +81 -20
  302. package/src/cli/commands/__tests__/bundle-package.test.ts +65 -0
  303. package/src/cli/commands/__tests__/command.test.ts +154 -0
  304. package/src/cli/commands/__tests__/init.test.ts +1 -1
  305. package/src/cli/commands/__tests__/install.test.ts +5 -72
  306. package/src/cli/commands/__tests__/mfe-check.test.ts +26 -5
  307. package/src/cli/commands/__tests__/run-task.test.ts +20 -1
  308. package/src/cli/commands/__tests__/start.test.ts +77 -16
  309. package/src/cli/commands/build.ts +15 -6
  310. package/src/cli/commands/bundle-package.ts +20 -0
  311. package/src/cli/commands/command.ts +64 -0
  312. package/src/cli/commands/init.ts +0 -1
  313. package/src/cli/commands/install.ts +5 -21
  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/install.ts +1 -6
  319. package/src/cli/commands/registry/start.ts +3 -2
  320. package/src/cli/commands/run-task.ts +8 -2
  321. package/src/cli/commands/start.ts +17 -6
  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-git.test.ts +54 -3
  335. package/src/cli/utils/__tests__/cli-npm.test.ts +33 -0
  336. package/src/cli/utils/__tests__/cli-os.test.ts +183 -4
  337. package/src/cli/utils/__tests__/compile.test.ts +37 -2
  338. package/src/cli/utils/__tests__/copy-files.test.ts +1 -1
  339. package/src/cli/utils/__tests__/with-exponential-backoff.test.ts +119 -0
  340. package/src/cli/utils/cli-git.ts +27 -1
  341. package/src/cli/utils/cli-npm.ts +19 -4
  342. package/src/cli/utils/cli-os.ts +44 -0
  343. package/src/cli/utils/compile.ts +8 -1
  344. package/src/cli/utils/copy-files.ts +1 -1
  345. package/src/cli/utils/index.ts +1 -1
  346. package/src/cli/utils/resolve-bundler.ts +2 -1
  347. package/src/cli/utils/ts-config.ts +1 -1
  348. package/src/cli/utils/with-exponential-backoff.ts +28 -0
  349. package/src/core/constants.ts +2 -0
  350. package/src/storybook-config/__tests__/vite-final.test.ts +6 -0
  351. package/src/storybook-config/__tests__/webpack-final.test.ts +26 -12
  352. package/src/storybook-config/webpack-final.ts +10 -4
  353. package/src/telemetry/__tests__/telemetry.test.ts +326 -0
  354. package/src/telemetry/index.ts +2 -0
  355. package/src/telemetry/telemetry.ts +134 -0
  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 +12 -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 +3 -2
  368. package/src/vite/config/__tests__/create-vite-config.test.ts +6 -3
  369. package/src/vite/config/base-config.ts +13 -1
  370. package/src/vite/config/create-filtering-logger.ts +8 -2
  371. package/src/vite/config/create-vite-config.ts +6 -3
  372. package/src/vite/index.html +2 -2
  373. package/src/vite/index.ts +2 -0
  374. package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +1 -1
  375. package/src/vite/plugins/__tests__/clean-plugin.test.ts +1 -1
  376. package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
  377. package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +15 -3
  378. package/src/vite/plugins/__tests__/dev-server-routing-plugin.test.ts +1 -1
  379. package/src/vite/plugins/__tests__/externals-plugin.test.ts +24 -3
  380. package/src/vite/plugins/__tests__/html-plugin.test.ts +10 -3
  381. package/src/vite/plugins/__tests__/html-template.test.ts +10 -2
  382. package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +30 -6
  383. package/src/vite/plugins/__tests__/less-tilde-plugin.test.ts +91 -0
  384. package/src/vite/plugins/__tests__/metadata-plugin.test.ts +1 -1
  385. package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +35 -25
  386. package/src/vite/plugins/__tests__/style-urls-plugin.test.ts +1 -1
  387. package/src/vite/plugins/__tests__/virtual-modules-plugin.test.ts +20 -9
  388. package/src/vite/plugins/__tests__/window-externals-plugin.test.ts +128 -0
  389. package/src/vite/plugins/chain-source-maps-plugin.ts +1 -1
  390. package/src/vite/plugins/clean-plugin.ts +1 -1
  391. package/src/vite/plugins/css-injector-plugin.ts +1 -1
  392. package/src/vite/plugins/design-system-guard-plugin.ts +11 -8
  393. package/src/vite/plugins/dev-server-routing-plugin.ts +1 -1
  394. package/src/vite/plugins/externals-plugin.ts +15 -6
  395. package/src/vite/plugins/html-plugin.ts +4 -2
  396. package/src/vite/plugins/ignore-modules-plugin.ts +32 -23
  397. package/src/vite/plugins/index.ts +3 -0
  398. package/src/vite/plugins/less-tilde-plugin.ts +64 -0
  399. package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +1 -1
  400. package/src/vite/plugins/metadata-plugin.ts +1 -1
  401. package/src/vite/plugins/moment-locales-plugin.ts +24 -14
  402. package/src/vite/plugins/react-refresh-plugin/README.md +165 -0
  403. package/src/vite/plugins/react-refresh-plugin/__tests__/react-refresh-plugin.test.ts +366 -0
  404. package/src/vite/plugins/react-refresh-plugin/__tests__/refresh-runtime.test.ts +193 -0
  405. package/src/vite/plugins/react-refresh-plugin/index.ts +1 -0
  406. package/src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts +144 -0
  407. package/src/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
  408. package/src/vite/plugins/shared-dependencies-plugin/__tests__/shared-dependencies-plugin.test.ts +21 -16
  409. package/src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts +13 -12
  410. package/src/vite/plugins/style-urls-plugin.ts +1 -1
  411. package/src/vite/plugins/virtual-modules-plugin.ts +8 -7
  412. package/src/vite/plugins/window-externals-plugin.ts +94 -0
  413. package/src/webpack/__tests__/bundle-webpack.test.ts +32 -0
  414. package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +27 -1
  415. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +17 -5
  416. package/src/webpack/__tests__/create-webpack-config.test.ts +10 -6
  417. package/src/webpack/bundle-webpack.ts +7 -1
  418. package/src/webpack/configs/optimization-config.ts +22 -11
  419. package/src/webpack/configs/output-config.ts +1 -1
  420. package/src/webpack/utils/__tests__/normalize-proxy-config.test.ts +121 -0
  421. package/src/webpack/utils/index.ts +1 -0
  422. package/src/webpack/utils/normalize-proxy-config.ts +59 -0
  423. package/tsconfig/types.d.ts +10 -0
  424. package/dist/cli/utils/get-bundle-command.d.ts +0 -3
  425. package/dist/cli/utils/get-bundle-command.d.ts.map +0 -1
  426. package/dist/cli/utils/get-bundle-command.js +0 -16
  427. package/dist/cli/utils/get-bundle-command.js.map +0 -1
  428. package/src/cli/utils/__tests__/get-bundle-command.test.ts +0 -23
  429. package/src/cli/utils/get-bundle-command.ts +0 -5
@@ -0,0 +1,326 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+ import os from 'os';
5
+ import { gitGetContext } from '../../cli/utils/cli-git';
6
+ import { getStartupVersion } from '../../core';
7
+ import { Telemetry } from '../telemetry';
8
+
9
+ jest.mock('../../cli/utils/cli-git', () => ({ gitGetContext: jest.fn() }));
10
+ jest.mock('../../core', () => ({ getStartupVersion: jest.fn() }));
11
+ jest.mock('os', () => ({ ...jest.requireActual('os'), hostname: jest.fn() }));
12
+
13
+ jest.mock('@servicetitan/secrets', () => ({}), { virtual: true });
14
+
15
+ describe(`[startup] ${Telemetry.name}`, () => {
16
+ const OLD_ENV = process.env;
17
+ const token = 'pub-test-token';
18
+ const gitContext = {
19
+ repo: 'monolith',
20
+ branch: 'main',
21
+ userEmail: 'dev@st.com',
22
+ userName: 'dev',
23
+ };
24
+ const hostname = 'test-host';
25
+ const startupVersion = '38.0.0';
26
+ const intakeUrl = (clientToken: string) =>
27
+ `https://browser-intake-datadoghq.com/api/v2/logs?dd-api-key=${clientToken}&ddsource=frontend-platform`;
28
+ const secrets = jest.requireMock('@servicetitan/secrets') as {
29
+ datadogStartupClientToken?: string;
30
+ };
31
+
32
+ let fetchMock: jest.Mock;
33
+
34
+ beforeEach(() => {
35
+ jest.clearAllMocks();
36
+ process.env = {};
37
+ secrets.datadogStartupClientToken = token;
38
+ jest.mocked(gitGetContext).mockResolvedValue(gitContext);
39
+ jest.mocked(getStartupVersion).mockReturnValue(startupVersion);
40
+ jest.mocked(os.hostname).mockReturnValue(hostname);
41
+ fetchMock = jest.fn(() => Promise.resolve({ ok: true } as Response));
42
+ global.fetch = fetchMock as unknown as typeof fetch;
43
+ });
44
+
45
+ afterAll(() => {
46
+ process.env = OLD_ENV;
47
+ });
48
+
49
+ const sentBody = () => JSON.parse(fetchMock.mock.calls[0][1].body)[0];
50
+
51
+ const emit = async (act: (telemetry: Telemetry) => void): Promise<void> => {
52
+ const telemetry = new Telemetry();
53
+ act(telemetry);
54
+ await telemetry.flush();
55
+ };
56
+
57
+ describe('construction', () => {
58
+ const subject = () => new Telemetry();
59
+
60
+ test('does not spawn git', () => {
61
+ subject();
62
+
63
+ expect(gitGetContext).not.toHaveBeenCalled();
64
+ });
65
+ });
66
+
67
+ describe('info', () => {
68
+ let attributes: Record<string, string>;
69
+
70
+ beforeEach(() => (attributes = {}));
71
+
72
+ const subject = () => emit(telemetry => telemetry.info('command.started', attributes));
73
+
74
+ test('posts to the browser logs intake with the client token', async () => {
75
+ await subject();
76
+
77
+ expect(fetchMock).toHaveBeenCalledWith(
78
+ intakeUrl(token),
79
+ expect.objectContaining({
80
+ method: 'POST',
81
+ headers: { 'Content-Type': 'application/json' },
82
+ })
83
+ );
84
+ });
85
+
86
+ test('includes the base context', async () => {
87
+ await subject();
88
+
89
+ expect(sentBody()).toEqual(
90
+ expect.objectContaining({
91
+ service: 'startup',
92
+ repo: gitContext.repo,
93
+ branch: gitContext.branch,
94
+ startupVersion,
95
+ hostname,
96
+ os: process.platform,
97
+ node: process.versions.node,
98
+ message: 'command.started',
99
+ status: 'info',
100
+ date: expect.any(Number),
101
+ agent: false,
102
+ usr: { email: gitContext.userEmail, name: gitContext.userName },
103
+ })
104
+ );
105
+ });
106
+
107
+ describe('with event attributes', () => {
108
+ beforeEach(() => {
109
+ attributes.command = 'build';
110
+ attributes.bundler = 'vite';
111
+ });
112
+
113
+ test('merges them into the payload', async () => {
114
+ await subject();
115
+
116
+ expect(sentBody()).toEqual(expect.objectContaining(attributes));
117
+ });
118
+ });
119
+
120
+ describe('when AI_AGENT is set', () => {
121
+ beforeEach(() => (process.env.AI_AGENT = 'claude-code'));
122
+
123
+ test('sets the agent flag', async () => {
124
+ await subject();
125
+
126
+ expect(sentBody()).toEqual(expect.objectContaining({ agent: true }));
127
+ });
128
+ });
129
+
130
+ describe('when CURSOR_AGENT is set', () => {
131
+ beforeEach(() => (process.env.CURSOR_AGENT = '1'));
132
+
133
+ test('sets the agent flag', async () => {
134
+ await subject();
135
+
136
+ expect(sentBody()).toEqual(expect.objectContaining({ agent: true }));
137
+ });
138
+ });
139
+
140
+ describe('without a client token', () => {
141
+ beforeEach(() => (secrets.datadogStartupClientToken = undefined));
142
+
143
+ test('does not send anything', async () => {
144
+ await subject();
145
+
146
+ expect(fetchMock).not.toHaveBeenCalled();
147
+ });
148
+
149
+ test('does not collect git context', async () => {
150
+ await subject();
151
+
152
+ expect(gitGetContext).not.toHaveBeenCalled();
153
+ });
154
+ });
155
+
156
+ describe('with DATADOG_CLIENT_TOKEN set', () => {
157
+ beforeEach(() => (process.env.DATADOG_CLIENT_TOKEN = 'env-token'));
158
+
159
+ test('overrides the secrets token', async () => {
160
+ await subject();
161
+
162
+ expect(fetchMock).toHaveBeenCalledWith(
163
+ intakeUrl('env-token'),
164
+ expect.objectContaining({ method: 'POST' })
165
+ );
166
+ });
167
+ });
168
+
169
+ describe('when fetch throws', () => {
170
+ beforeEach(() => {
171
+ global.fetch = (() => {
172
+ throw new Error('boom');
173
+ }) as unknown as typeof fetch;
174
+ });
175
+
176
+ test('does not reject', async () => {
177
+ await expect(subject()).resolves.toBeUndefined();
178
+ });
179
+ });
180
+
181
+ describe('when base context gathering fails', () => {
182
+ beforeEach(() => {
183
+ jest.mocked(gitGetContext).mockRejectedValue(new Error('git blew up'));
184
+ });
185
+
186
+ test('still sends the event', async () => {
187
+ await subject();
188
+
189
+ expect(sentBody()).toEqual(expect.objectContaining({ message: 'command.started' }));
190
+ });
191
+ });
192
+ });
193
+
194
+ describe('warn', () => {
195
+ const subject = () => emit(telemetry => telemetry.warn('node.version.unsupported'));
196
+
197
+ test('sends with warn status', async () => {
198
+ await subject();
199
+
200
+ expect(sentBody()).toEqual(
201
+ expect.objectContaining({ message: 'node.version.unsupported', status: 'warn' })
202
+ );
203
+ });
204
+ });
205
+
206
+ describe('error', () => {
207
+ const message = 'compile blew up';
208
+
209
+ let error: unknown;
210
+
211
+ beforeEach(() => (error = new TypeError(message)));
212
+
213
+ const subject = () => emit(telemetry => telemetry.error('command.finished', error));
214
+
215
+ test('sends with error status, message, and kind', async () => {
216
+ await subject();
217
+
218
+ expect(sentBody()).toEqual(
219
+ expect.objectContaining({
220
+ message: 'command.finished',
221
+ status: 'error',
222
+ error: {
223
+ message,
224
+ kind: TypeError.name,
225
+ stack: expect.any(String),
226
+ },
227
+ })
228
+ );
229
+ });
230
+
231
+ describe('with a string', () => {
232
+ const stringError = 'boom';
233
+
234
+ beforeEach(() => (error = stringError));
235
+
236
+ test('uses it as the message', async () => {
237
+ await subject();
238
+
239
+ expect(sentBody()).toEqual(
240
+ expect.objectContaining({ error: { message: stringError } })
241
+ );
242
+ });
243
+ });
244
+
245
+ describe('with a non-Error object', () => {
246
+ const objectError = { code: 42 };
247
+
248
+ beforeEach(() => (error = objectError));
249
+
250
+ test('serializes it', async () => {
251
+ await subject();
252
+
253
+ expect(sentBody()).toEqual(
254
+ expect.objectContaining({ error: { message: JSON.stringify(objectError) } })
255
+ );
256
+ });
257
+ });
258
+
259
+ describe('with a circular value', () => {
260
+ beforeEach(() => {
261
+ const circular: Record<string, unknown> = {};
262
+ circular.self = circular;
263
+ error = circular;
264
+ });
265
+
266
+ test('falls back to a safe message', async () => {
267
+ await subject();
268
+
269
+ expect(sentBody()).toEqual(
270
+ expect.objectContaining({ error: { message: 'unserializable error value' } })
271
+ );
272
+ });
273
+ });
274
+ });
275
+
276
+ describe('flush', () => {
277
+ const subject = () => {
278
+ const telemetry = new Telemetry();
279
+ telemetry.info('command.started');
280
+ telemetry.info('command.finished');
281
+ return telemetry;
282
+ };
283
+
284
+ describe('with in-flight sends', () => {
285
+ let resolvers: (() => void)[];
286
+
287
+ beforeEach(() => {
288
+ resolvers = [];
289
+ fetchMock.mockImplementation(
290
+ () =>
291
+ new Promise<Response>(resolve => {
292
+ resolvers.push(() => resolve({ ok: true } as Response));
293
+ })
294
+ );
295
+ });
296
+
297
+ test('waits for all of them, not just the last', async () => {
298
+ let done = false;
299
+ const flushing = subject()
300
+ .flush()
301
+ .then(() => (done = true));
302
+
303
+ await new Promise(resolve => setImmediate(resolve));
304
+ expect(resolvers).toHaveLength(2);
305
+
306
+ resolvers[1]();
307
+ await Promise.resolve();
308
+ expect(done).toBe(false);
309
+
310
+ resolvers[0]();
311
+ await flushing;
312
+ expect(done).toBe(true);
313
+ });
314
+ });
315
+
316
+ describe('when a send rejects', () => {
317
+ beforeEach(() => {
318
+ fetchMock.mockRejectedValue(new Error('network down'));
319
+ });
320
+
321
+ test('resolves without rejecting', async () => {
322
+ await expect(subject().flush()).resolves.toBeUndefined();
323
+ });
324
+ });
325
+ });
326
+ });
@@ -0,0 +1,2 @@
1
+ export { Telemetry, telemetry } from './telemetry';
2
+ export type { AttributeValue, Attributes } from './telemetry';
@@ -0,0 +1,134 @@
1
+ import { isCI } from '@servicetitan/install';
2
+ import os from 'os';
3
+ import { gitGetContext } from '../cli/utils/cli-git';
4
+ import { getStartupVersion } from '../core';
5
+
6
+ const DDSOURCE = 'frontend-platform';
7
+ const SERVICE = 'startup';
8
+ const SITE = 'datadoghq.com';
9
+ const REQUEST_TIMEOUT_MS = 2000;
10
+
11
+ type Status = 'info' | 'warn' | 'error';
12
+ export type AttributeValue = string | number | boolean | undefined;
13
+ export type Attributes = Record<string, AttributeValue | Record<string, AttributeValue>>;
14
+
15
+ interface Context {
16
+ clientToken: string;
17
+ baseAttributes: Attributes;
18
+ }
19
+
20
+ function toError(error: unknown): { message: string; kind?: string; stack?: string } {
21
+ if (error instanceof Error) {
22
+ return { message: error.message, kind: error.name, stack: error.stack };
23
+ }
24
+ if (typeof error === 'string') {
25
+ return { message: error };
26
+ }
27
+ try {
28
+ return { message: JSON.stringify(error) };
29
+ } catch {
30
+ return { message: 'unserializable error value' };
31
+ }
32
+ }
33
+
34
+ function getClientToken(): string | undefined {
35
+ if (process.env.DATADOG_CLIENT_TOKEN) {
36
+ return process.env.DATADOG_CLIENT_TOKEN;
37
+ }
38
+ try {
39
+ const secrets = require('@servicetitan/secrets') as {
40
+ datadogStartupClientToken?: string;
41
+ };
42
+ return secrets.datadogStartupClientToken;
43
+ } catch {
44
+ return undefined;
45
+ }
46
+ }
47
+
48
+ async function getBaseContext(): Promise<Attributes> {
49
+ const git = await gitGetContext();
50
+ return {
51
+ service: SERVICE,
52
+ repo: git.repo,
53
+ branch: git.branch,
54
+ startupVersion: getStartupVersion(),
55
+ ci: isCI(),
56
+ agent: Boolean(process.env.AI_AGENT ?? process.env.CURSOR_AGENT),
57
+ hostname: os.hostname(),
58
+ os: process.platform,
59
+ node: process.versions.node,
60
+ usr: { email: git.userEmail, name: git.userName },
61
+ };
62
+ }
63
+
64
+ async function resolveContext(): Promise<Context | undefined> {
65
+ const clientToken = getClientToken();
66
+ if (!clientToken) {
67
+ return undefined;
68
+ }
69
+ const baseAttributes = await getBaseContext().catch(() => ({}));
70
+ return { clientToken, baseAttributes };
71
+ }
72
+
73
+ export class Telemetry {
74
+ private initPromise?: Promise<Context | undefined>;
75
+ private readonly pendingRequests = new Set<Promise<unknown>>();
76
+
77
+ info(name: string, attributes: Attributes = {}): void {
78
+ this.event(name, 'info', attributes);
79
+ }
80
+
81
+ warn(name: string, attributes: Attributes = {}): void {
82
+ this.event(name, 'warn', attributes);
83
+ }
84
+
85
+ error(name: string, error: unknown, attributes: Attributes = {}): void {
86
+ this.event(name, 'error', { ...attributes, error: toError(error) });
87
+ }
88
+
89
+ async flush(): Promise<void> {
90
+ /*
91
+ * Promise.all, not allSettled: pending requests never reject, and swallowing
92
+ * here would leave failures asymmetric on whether flush ran (a race).
93
+ */
94
+ await Promise.all([...this.pendingRequests]);
95
+ }
96
+
97
+ private init(): Promise<Context | undefined> {
98
+ this.initPromise ??= resolveContext();
99
+ return this.initPromise;
100
+ }
101
+
102
+ private event(name: string, status: Status, attributes: Attributes): void {
103
+ try {
104
+ this.send({ message: name, status, date: Date.now(), ...attributes });
105
+ } catch {} // eslint-disable-line no-empty
106
+ }
107
+
108
+ private send(event: Attributes): void {
109
+ const request = this.init()
110
+ .then(context => {
111
+ if (!context) {
112
+ return;
113
+ }
114
+ const { clientToken, baseAttributes } = context;
115
+ const controller = new AbortController();
116
+ const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
117
+ timer.unref();
118
+ const url =
119
+ `https://browser-intake-${SITE}/api/v2/logs` +
120
+ `?dd-api-key=${encodeURIComponent(clientToken)}&ddsource=${DDSOURCE}`;
121
+ return fetch(url, {
122
+ method: 'POST',
123
+ headers: { 'Content-Type': 'application/json' },
124
+ body: JSON.stringify([{ ...baseAttributes, ...event }]),
125
+ signal: controller.signal,
126
+ }).finally(() => clearTimeout(timer));
127
+ })
128
+ .catch(() => {})
129
+ .finally(() => this.pendingRequests.delete(request));
130
+ this.pendingRequests.add(request);
131
+ }
132
+ }
133
+
134
+ export const telemetry = new Telemetry();
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+ import { exitWhenParentExits } from '../exit-when-parent-exits';
5
+ import { log } from '../log';
6
+
7
+ jest.mock('../log', () => ({ log: { info: jest.fn() } }));
8
+
9
+ describe(`[startup] ${exitWhenParentExits.name}`, () => {
10
+ const command = 'some-task';
11
+ const parentPid = 4321;
12
+ let callback: (() => void) | undefined;
13
+ let killSpy: jest.SpyInstance;
14
+ let exitSpy: jest.SpyInstance;
15
+
16
+ beforeEach(() => {
17
+ jest.clearAllMocks();
18
+ jest.useFakeTimers();
19
+ callback = undefined;
20
+ killSpy = jest.spyOn(process, 'kill').mockImplementation(jest.fn());
21
+ exitSpy = jest.spyOn(process, 'exit').mockImplementation(jest.fn() as any);
22
+ process.env.STARTUP_PARENT_PID = String(parentPid);
23
+ });
24
+
25
+ afterEach(() => {
26
+ jest.useRealTimers();
27
+ });
28
+
29
+ const subject = () => {
30
+ exitWhenParentExits(command, callback);
31
+ jest.advanceTimersByTime(1000);
32
+ };
33
+
34
+ test('polls whether the parent process is still running', () => {
35
+ subject();
36
+
37
+ expect(killSpy).toHaveBeenCalledWith(parentPid, 0);
38
+ });
39
+
40
+ describe('with no process.env.STARTUP_PARENT_PID', () => {
41
+ beforeEach(() => delete process.env.STARTUP_PARENT_PID);
42
+
43
+ test('does not poll', () => {
44
+ subject();
45
+
46
+ expect(killSpy).not.toHaveBeenCalled();
47
+ });
48
+ });
49
+
50
+ describe('when the parent process has exited', () => {
51
+ beforeEach(() => {
52
+ killSpy.mockImplementation(() => {
53
+ throw new Error('ESRCH');
54
+ });
55
+ });
56
+
57
+ test('logs shutdown message', () => {
58
+ subject();
59
+
60
+ expect(log.info).toHaveBeenCalledWith(`${command} shutting down`);
61
+ });
62
+
63
+ test('exits the process', () => {
64
+ subject();
65
+
66
+ expect(exitSpy).toHaveBeenCalledWith(0);
67
+ });
68
+
69
+ describe('with a callback', () => {
70
+ beforeEach(() => (callback = jest.fn()));
71
+
72
+ test('does not exit the process', () => {
73
+ subject();
74
+
75
+ expect(exitSpy).not.toHaveBeenCalled();
76
+ });
77
+
78
+ test('calls the callback', () => {
79
+ subject();
80
+
81
+ jest.advanceTimersByTime(1000);
82
+
83
+ expect(callback).toHaveBeenCalled();
84
+ });
85
+ });
86
+ });
87
+ });
@@ -0,0 +1,49 @@
1
+ import path from 'path';
2
+ import { findUp } from '../find-up';
3
+
4
+ describe(findUp.name, () => {
5
+ let callback: jest.Mock;
6
+ let from: string | undefined;
7
+
8
+ const subject = () => findUp(callback, from);
9
+
10
+ beforeEach(() => {
11
+ jest.clearAllMocks();
12
+ callback = jest.fn();
13
+ from = undefined;
14
+ });
15
+
16
+ test('searches upward from the current working directory', () => {
17
+ subject();
18
+
19
+ ['.', '..', '../..'].forEach((dir, index) =>
20
+ expect(callback).toHaveBeenNthCalledWith(index + 1, path.resolve(dir))
21
+ );
22
+ });
23
+
24
+ test('returns undefined', () => {
25
+ expect(subject()).toBeUndefined();
26
+ });
27
+
28
+ describe('when a directory matches', () => {
29
+ const result = 'foo';
30
+
31
+ beforeEach(() => callback.mockReturnValueOnce(undefined).mockReturnValueOnce(result));
32
+
33
+ test('returns the callback result', () => {
34
+ expect(subject()).toBe(result);
35
+ });
36
+ });
37
+
38
+ describe('with a starting directory', () => {
39
+ beforeEach(() => (from = path.resolve('a/b/c')));
40
+
41
+ test('searches upward from the specified directory', () => {
42
+ subject();
43
+
44
+ ['.', '..', '../..'].forEach((dir, index) =>
45
+ expect(callback).toHaveBeenNthCalledWith(index + 1, path.resolve(from!, dir))
46
+ );
47
+ });
48
+ });
49
+ });
@@ -7,6 +7,7 @@ import {
7
7
  getExposeProcessEnv,
8
8
  getJestConfiguration,
9
9
  getReviewConfiguration,
10
+ getSharedDependencies,
10
11
  getStylelintConfiguration,
11
12
  getViteConfiguration,
12
13
  getVitestConfiguration,
@@ -243,6 +244,67 @@ describe('[startup] Utils', () => {
243
244
  });
244
245
  });
245
246
 
247
+ describe(getSharedDependencies.name, () => {
248
+ const sharedDependencies = { react: 'SharedDependencies.React' };
249
+ let locationOrJson: Parameters<typeof getSharedDependencies>[0];
250
+
251
+ beforeEach(() => (locationOrJson = undefined));
252
+
253
+ const subject = () => getSharedDependencies(locationOrJson);
254
+
255
+ itReturns(subject, undefined);
256
+
257
+ describe('with "cli.shared-dependencies"', () => {
258
+ beforeEach(() =>
259
+ mockPackageJson({ cli: { 'shared-dependencies': sharedDependencies } })
260
+ );
261
+
262
+ test('returns "cli.shared-dependencies"', () => {
263
+ expect(subject()).toEqual(sharedDependencies);
264
+ });
265
+ });
266
+
267
+ describe('with "cli.webpack.shared-dependencies"', () => {
268
+ beforeEach(() =>
269
+ mockPackageJson({ cli: { webpack: { 'shared-dependencies': sharedDependencies } } })
270
+ );
271
+
272
+ test('returns "cli.webpack.shared-dependencies"', () => {
273
+ expect(subject()).toEqual(sharedDependencies);
274
+ });
275
+ });
276
+
277
+ describe('with both top-level and webpack "shared-dependencies"', () => {
278
+ beforeEach(() =>
279
+ mockPackageJson({
280
+ cli: {
281
+ 'shared-dependencies': sharedDependencies,
282
+ 'webpack': { 'shared-dependencies': { mobx: 'SharedDependencies.MobX' } },
283
+ },
284
+ })
285
+ );
286
+
287
+ test('returns top-level "cli.shared-dependencies"', () => {
288
+ expect(subject()).toEqual(sharedDependencies);
289
+ });
290
+ });
291
+
292
+ describe('with a location', () => {
293
+ beforeEach(() => {
294
+ locationOrJson = 'packages/foo';
295
+ vol.fromJSON({
296
+ [`packages/foo/${packageJson}`]: JSON.stringify({
297
+ cli: { 'shared-dependencies': sharedDependencies },
298
+ }),
299
+ });
300
+ });
301
+
302
+ test("returns location's shared dependencies", () => {
303
+ expect(subject()).toEqual(sharedDependencies);
304
+ });
305
+ });
306
+ });
307
+
246
308
  describe(getViteConfiguration.name, () => {
247
309
  const subject = () => getViteConfiguration();
248
310