@tramvai/cli 2.64.0 → 2.66.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 (426) hide show
  1. package/README.md +46 -38
  2. package/lib/api/analyze/providers/shared.js +1 -1
  3. package/lib/api/analyze/providers/shared.js.map +1 -1
  4. package/lib/api/benchmark/index.d.ts +1 -1
  5. package/lib/api/build/child-app.js +3 -2
  6. package/lib/api/build/child-app.js.map +1 -1
  7. package/lib/api/build/module.js +1 -2
  8. package/lib/api/build/module.js.map +1 -1
  9. package/lib/api/build/providers/shared.js +1 -1
  10. package/lib/api/build/providers/shared.js.map +1 -1
  11. package/lib/api/index.d.ts +6 -2
  12. package/lib/api/index.js +3 -3
  13. package/lib/api/index.js.map +1 -1
  14. package/lib/api/shared/types/withConfig.d.ts +3 -2
  15. package/lib/api/start/providers/application/server.js +11 -18
  16. package/lib/api/start/providers/application/server.js.map +1 -1
  17. package/lib/api/start/providers/application/shared.js +17 -25
  18. package/lib/api/start/providers/application/shared.js.map +1 -1
  19. package/lib/api/start/providers/child-app/shared.js +19 -25
  20. package/lib/api/start/providers/child-app/shared.js.map +1 -1
  21. package/lib/api/start/providers/module/shared.js +18 -24
  22. package/lib/api/start/providers/module/shared.js.map +1 -1
  23. package/lib/api/start/utils/banner.js +3 -2
  24. package/lib/api/start/utils/banner.js.map +1 -1
  25. package/lib/api/start/utils/listenServer.js +3 -2
  26. package/lib/api/start/utils/listenServer.js.map +1 -1
  27. package/lib/api/start/utils/tips/tips.js +10 -8
  28. package/lib/api/start/utils/tips/tips.js.map +1 -1
  29. package/lib/api/start-prod/providers/application.js +6 -5
  30. package/lib/api/start-prod/providers/application.js.map +1 -1
  31. package/lib/api/start-prod/providers/child-app.js +3 -2
  32. package/lib/api/start-prod/providers/child-app.js.map +1 -1
  33. package/lib/api/start-prod/providers/shared.js +5 -13
  34. package/lib/api/start-prod/providers/shared.js.map +1 -1
  35. package/lib/builder/webpack/devServer/client.js +18 -15
  36. package/lib/builder/webpack/devServer/client.js.map +1 -1
  37. package/lib/builder/webpack/devServer/notifier.d.ts +2 -2
  38. package/lib/builder/webpack/devServer/notifier.js +3 -3
  39. package/lib/builder/webpack/devServer/notifier.js.map +1 -1
  40. package/lib/builder/webpack/devServer/pool/process/pool.js +3 -2
  41. package/lib/builder/webpack/devServer/pool/process/pool.js.map +1 -1
  42. package/lib/builder/webpack/devServer/pool/thread/pool.js +7 -0
  43. package/lib/builder/webpack/devServer/pool/thread/pool.js.map +1 -1
  44. package/lib/builder/webpack/devServer/server.js +7 -2
  45. package/lib/builder/webpack/devServer/server.js.map +1 -1
  46. package/lib/builder/webpack/providers/analyze/shared.js +3 -3
  47. package/lib/builder/webpack/providers/analyze/shared.js.map +1 -1
  48. package/lib/builder/webpack/providers/build/application/server.js.map +1 -1
  49. package/lib/builder/webpack/providers/build/client.js +3 -3
  50. package/lib/builder/webpack/providers/build/client.js.map +1 -1
  51. package/lib/builder/webpack/providers/build/server.js +1 -1
  52. package/lib/builder/webpack/providers/build/server.js.map +1 -1
  53. package/lib/builder/webpack/tokens.d.ts +313 -3
  54. package/lib/builder/webpack/tokens.js.map +1 -1
  55. package/lib/builder/webpack/utils/copyBuildFile.d.ts +2 -1
  56. package/lib/builder/webpack/utils/copyBuildFile.js +2 -3
  57. package/lib/builder/webpack/utils/copyBuildFile.js.map +1 -1
  58. package/lib/builder/webpack/utils/copyStatsJsonFile.d.ts +2 -1
  59. package/lib/builder/webpack/utils/copyStatsJsonFile.js +1 -1
  60. package/lib/builder/webpack/utils/copyStatsJsonFile.js.map +1 -1
  61. package/lib/cli/CLI.d.ts +2 -2
  62. package/lib/cli/CLI.js +2 -2
  63. package/lib/cli/CLI.js.map +1 -1
  64. package/lib/cli/index.js.map +1 -1
  65. package/lib/commands/analyze/command.d.ts +1 -1
  66. package/lib/commands/analyze/command.js.map +1 -1
  67. package/lib/commands/benchmark/command.d.ts +1 -1
  68. package/lib/commands/benchmark/command.js.map +1 -1
  69. package/lib/commands/build/command.d.ts +1 -1
  70. package/lib/commands/build/command.js.map +1 -1
  71. package/lib/commands/new/new.js +0 -1
  72. package/lib/commands/new/new.js.map +1 -1
  73. package/lib/commands/new/questions/packageManager.d.ts +1 -1
  74. package/lib/commands/new/questions/packageManager.js.map +1 -1
  75. package/lib/commands/new/questions/template.d.ts +1 -1
  76. package/lib/commands/new/questions/template.js.map +1 -1
  77. package/lib/commands/new/questions/testingFramework.d.ts +1 -1
  78. package/lib/commands/new/questions/testingFramework.js.map +1 -1
  79. package/lib/commands/new/questions/type.d.ts +1 -1
  80. package/lib/commands/new/questions/type.js.map +1 -1
  81. package/lib/commands/new/steps/initializationGit.d.ts +1 -1
  82. package/lib/commands/new/steps/initializationGit.js.map +1 -1
  83. package/lib/commands/start/command.d.ts +1 -1
  84. package/lib/commands/start/command.js.map +1 -1
  85. package/lib/commands/start-prod/command.d.ts +1 -1
  86. package/lib/commands/start-prod/command.js.map +1 -1
  87. package/lib/commands/static/application.js +4 -4
  88. package/lib/commands/static/application.js.map +1 -1
  89. package/lib/commands/static/command.d.ts +1 -1
  90. package/lib/commands/static/command.js.map +1 -1
  91. package/lib/commands/static/generate.js +2 -2
  92. package/lib/commands/static/generate.js.map +1 -1
  93. package/lib/commands/static/server.d.ts +2 -1
  94. package/lib/commands/static/server.js +1 -1
  95. package/lib/commands/static/server.js.map +1 -1
  96. package/lib/commands/static/staticServer.d.ts +2 -1
  97. package/lib/commands/static/staticServer.js +1 -1
  98. package/lib/commands/static/staticServer.js.map +1 -1
  99. package/lib/commands/update/updatePackageJson.js +3 -0
  100. package/lib/commands/update/updatePackageJson.js.map +1 -1
  101. package/lib/config/configManager.d.ts +15 -73
  102. package/lib/config/configManager.js +64 -92
  103. package/lib/config/configManager.js.map +1 -1
  104. package/lib/config/showConfig.d.ts +1 -1
  105. package/lib/config/showConfig.js +1 -1
  106. package/lib/config/showConfig.js.map +1 -1
  107. package/lib/config/validate.d.ts +5 -4
  108. package/lib/config/validate.js +2 -9
  109. package/lib/config/validate.js.map +1 -1
  110. package/lib/di/tokens/config.d.ts +106 -1
  111. package/lib/di/tokens/config.js.map +1 -1
  112. package/lib/external/config.d.ts +2 -2
  113. package/lib/library/babel/index.js +1 -0
  114. package/lib/library/babel/index.js.map +1 -1
  115. package/lib/library/swc/index.js +1 -1
  116. package/lib/library/swc/index.js.map +1 -1
  117. package/lib/library/webpack/application/client/common.js +6 -4
  118. package/lib/library/webpack/application/client/common.js.map +1 -1
  119. package/lib/library/webpack/application/client/dev.js +9 -8
  120. package/lib/library/webpack/application/client/dev.js.map +1 -1
  121. package/lib/library/webpack/application/client/prod/optimization/splitChunks.js +40 -39
  122. package/lib/library/webpack/application/client/prod/optimization/splitChunks.js.map +1 -1
  123. package/lib/library/webpack/application/client/prod.js +3 -4
  124. package/lib/library/webpack/application/client/prod.js.map +1 -1
  125. package/lib/library/webpack/application/server/common.js +5 -5
  126. package/lib/library/webpack/application/server/common.js.map +1 -1
  127. package/lib/library/webpack/application/server/dev.js +3 -6
  128. package/lib/library/webpack/application/server/dev.js.map +1 -1
  129. package/lib/library/webpack/application/server/prod.js +3 -4
  130. package/lib/library/webpack/application/server/prod.js.map +1 -1
  131. package/lib/library/webpack/blocks/apiResolve.js +1 -1
  132. package/lib/library/webpack/blocks/apiResolve.js.map +1 -1
  133. package/lib/library/webpack/blocks/configResolve.js +2 -2
  134. package/lib/library/webpack/blocks/configResolve.js.map +1 -1
  135. package/lib/library/webpack/blocks/configToEnv.js +5 -2
  136. package/lib/library/webpack/blocks/configToEnv.js.map +1 -1
  137. package/lib/library/webpack/blocks/css.d.ts +3 -1
  138. package/lib/library/webpack/blocks/css.js +17 -6
  139. package/lib/library/webpack/blocks/css.js.map +1 -1
  140. package/lib/library/webpack/blocks/extractCssPlugin.d.ts +4 -3
  141. package/lib/library/webpack/blocks/extractCssPlugin.js +4 -6
  142. package/lib/library/webpack/blocks/extractCssPlugin.js.map +1 -1
  143. package/lib/library/webpack/blocks/filesClient.d.ts +3 -2
  144. package/lib/library/webpack/blocks/filesClient.js +7 -7
  145. package/lib/library/webpack/blocks/filesClient.js.map +1 -1
  146. package/lib/library/webpack/blocks/filesServer.d.ts +2 -1
  147. package/lib/library/webpack/blocks/filesServer.js +3 -3
  148. package/lib/library/webpack/blocks/filesServer.js.map +1 -1
  149. package/lib/library/webpack/blocks/js.d.ts +2 -1
  150. package/lib/library/webpack/blocks/js.js +1 -1
  151. package/lib/library/webpack/blocks/js.js.map +1 -1
  152. package/lib/library/webpack/blocks/nodeClient.d.ts +2 -1
  153. package/lib/library/webpack/blocks/nodeClient.js +2 -2
  154. package/lib/library/webpack/blocks/nodeClient.js.map +1 -1
  155. package/lib/library/webpack/blocks/optimize.d.ts +2 -1
  156. package/lib/library/webpack/blocks/optimize.js +3 -3
  157. package/lib/library/webpack/blocks/optimize.js.map +1 -1
  158. package/lib/library/webpack/blocks/pagesResolve.js +1 -1
  159. package/lib/library/webpack/blocks/pagesResolve.js.map +1 -1
  160. package/lib/library/webpack/blocks/postcssAssets.d.ts +2 -1
  161. package/lib/library/webpack/blocks/postcssAssets.js +2 -2
  162. package/lib/library/webpack/blocks/postcssAssets.js.map +1 -1
  163. package/lib/library/webpack/blocks/serverInline.d.ts +2 -1
  164. package/lib/library/webpack/blocks/serverInline.js.map +1 -1
  165. package/lib/library/webpack/blocks/ts.d.ts +2 -1
  166. package/lib/library/webpack/blocks/ts.js.map +1 -1
  167. package/lib/library/webpack/child-app/client/common.d.ts +2 -2
  168. package/lib/library/webpack/child-app/client/common.js +1 -1
  169. package/lib/library/webpack/child-app/client/common.js.map +1 -1
  170. package/lib/library/webpack/child-app/client/dev.d.ts +2 -2
  171. package/lib/library/webpack/child-app/client/dev.js +6 -5
  172. package/lib/library/webpack/child-app/client/dev.js.map +1 -1
  173. package/lib/library/webpack/child-app/client/prod.d.ts +2 -2
  174. package/lib/library/webpack/child-app/client/prod.js.map +1 -1
  175. package/lib/library/webpack/child-app/common.d.ts +2 -2
  176. package/lib/library/webpack/child-app/common.js.map +1 -1
  177. package/lib/library/webpack/child-app/server/common.d.ts +2 -2
  178. package/lib/library/webpack/child-app/server/common.js +1 -1
  179. package/lib/library/webpack/child-app/server/common.js.map +1 -1
  180. package/lib/library/webpack/child-app/server/dev.d.ts +2 -2
  181. package/lib/library/webpack/child-app/server/dev.js.map +1 -1
  182. package/lib/library/webpack/child-app/server/prod.d.ts +2 -2
  183. package/lib/library/webpack/child-app/server/prod.js.map +1 -1
  184. package/lib/library/webpack/common/client/prod.d.ts +2 -1
  185. package/lib/library/webpack/common/client/prod.js +4 -5
  186. package/lib/library/webpack/common/client/prod.js.map +1 -1
  187. package/lib/library/webpack/common/main.d.ts +2 -1
  188. package/lib/library/webpack/common/main.js +3 -3
  189. package/lib/library/webpack/common/main.js.map +1 -1
  190. package/lib/library/webpack/common/server/prod.d.ts +2 -1
  191. package/lib/library/webpack/common/server/prod.js +4 -5
  192. package/lib/library/webpack/common/server/prod.js.map +1 -1
  193. package/lib/library/webpack/index.js +1 -2
  194. package/lib/library/webpack/index.js.map +1 -1
  195. package/lib/library/webpack/loaders/image-loader/index.d.ts +2 -1
  196. package/lib/library/webpack/loaders/image-loader/index.js.map +1 -1
  197. package/lib/library/webpack/loaders/pagesResolve.d.ts +10 -1
  198. package/lib/library/webpack/loaders/pagesResolve.js +4 -3
  199. package/lib/library/webpack/loaders/pagesResolve.js.map +1 -1
  200. package/lib/library/webpack/loaders/replaceContent.d.ts +6 -1
  201. package/lib/library/webpack/loaders/replaceContent.js +4 -3
  202. package/lib/library/webpack/loaders/replaceContent.js.map +1 -1
  203. package/lib/library/webpack/module/client/common.js +1 -1
  204. package/lib/library/webpack/module/client/common.js.map +1 -1
  205. package/lib/library/webpack/module/externals.d.ts +1 -1
  206. package/lib/library/webpack/module/externals.js.map +1 -1
  207. package/lib/library/webpack/module/resolveExternal.d.ts +1 -1
  208. package/lib/library/webpack/module/resolveExternal.js.map +1 -1
  209. package/lib/library/webpack/module/server/common.js +1 -1
  210. package/lib/library/webpack/module/server/common.js.map +1 -1
  211. package/lib/library/webpack/plugins/LazyModuleInitialization.d.ts +2 -2
  212. package/lib/library/webpack/plugins/LazyModuleInitialization.js +1 -0
  213. package/lib/library/webpack/plugins/LazyModuleInitialization.js.map +1 -1
  214. package/lib/library/webpack/plugins/WebpackBar/utils/index.d.ts +7 -7
  215. package/lib/library/webpack/plugins/WebpackBar/utils/index.js.map +1 -1
  216. package/lib/library/webpack/plugins/WebpackBar/utils/webpack.d.ts +2 -2
  217. package/lib/library/webpack/plugins/WebpackBar/utils/webpack.js.map +1 -1
  218. package/lib/library/webpack/types/webpack.d.ts +2 -2
  219. package/lib/library/webpack/utils/files.d.ts +4 -3
  220. package/lib/library/webpack/utils/files.js +2 -2
  221. package/lib/library/webpack/utils/files.js.map +1 -1
  222. package/lib/library/webpack/utils/transpiler.d.ts +3 -2
  223. package/lib/library/webpack/utils/transpiler.js +2 -2
  224. package/lib/library/webpack/utils/transpiler.js.map +1 -1
  225. package/lib/library/webpack/utils/workersPool.d.ts +3 -6
  226. package/lib/library/webpack/utils/workersPool.js +1 -1
  227. package/lib/library/webpack/utils/workersPool.js.map +1 -1
  228. package/lib/models/config.d.ts +2 -3
  229. package/lib/models/config.js +32 -3
  230. package/lib/models/config.js.map +1 -1
  231. package/lib/schema/ConfigSchema.d.ts +13 -4
  232. package/lib/schema/autogeneratedSchema.json +1808 -2074
  233. package/lib/typings/configEntry/application.d.ts +81 -86
  234. package/lib/typings/configEntry/child-app.d.ts +10 -29
  235. package/lib/typings/configEntry/cli.d.ts +254 -0
  236. package/lib/typings/configEntry/{CheckAsyncTsConfig.js → cli.js} +1 -1
  237. package/lib/typings/configEntry/cli.js.map +1 -0
  238. package/lib/typings/configEntry/common.d.ts +16 -276
  239. package/lib/typings/configEntry/common.js +15 -0
  240. package/lib/typings/configEntry/common.js.map +1 -1
  241. package/lib/typings/configEntry/module.d.ts +10 -29
  242. package/lib/typings/configEntry/package.d.ts +2 -1
  243. package/lib/ui/commander.js +1 -1
  244. package/lib/ui/commander.js.map +1 -1
  245. package/lib/utils/applyTemplate.js.map +1 -1
  246. package/lib/utils/detectPortSync.d.ts +1 -0
  247. package/lib/utils/detectPortSync.js +10 -0
  248. package/lib/utils/detectPortSync.js.map +1 -0
  249. package/lib/utils/safeRequire.js +5 -1
  250. package/lib/utils/safeRequire.js.map +1 -1
  251. package/lib/utils/webpackBuild.d.ts +2 -1
  252. package/lib/utils/webpackBuild.js +3 -3
  253. package/lib/utils/webpackBuild.js.map +1 -1
  254. package/package.json +14 -9
  255. package/schema.json +1802 -2068
  256. package/src/api/analyze/providers/shared.ts +3 -2
  257. package/src/api/benchmark/__integration__/__fixtures__/tramvai.json +1 -8
  258. package/src/api/benchmark/index.ts +1 -1
  259. package/src/api/build/__integration__/__fixtures__/app/App.tsx +0 -1
  260. package/src/api/build/__integration__/__fixtures__/app/index.tsx +14 -8
  261. package/src/api/build/__integration__/__fixtures__/app/server.tsx +0 -1
  262. package/src/api/build/__integration__/__fixtures__/tramvai.json +1 -10
  263. package/src/api/build/__integration__/build.test.ts +4 -13
  264. package/src/api/build/child-app.ts +4 -4
  265. package/src/api/build/module.ts +2 -4
  266. package/src/api/build/providers/shared.ts +2 -2
  267. package/src/api/index.ts +6 -2
  268. package/src/api/shared/types/withConfig.ts +5 -6
  269. package/src/api/start/__integration__/__fixtures__/app/index.tsx +11 -7
  270. package/src/api/start/__integration__/__fixtures__/tramvai.json +6 -17
  271. package/src/api/start/__integration__/start.test.ts +38 -13
  272. package/src/api/start/providers/application/server.ts +14 -23
  273. package/src/api/start/providers/application/shared.ts +26 -52
  274. package/src/api/start/providers/child-app/shared.ts +23 -46
  275. package/src/api/start/providers/module/shared.ts +24 -47
  276. package/src/api/start/utils/banner.ts +3 -2
  277. package/src/api/start/utils/listenServer.ts +2 -1
  278. package/src/api/start/utils/tips/tips.ts +11 -8
  279. package/src/api/start-prod/providers/application.ts +19 -19
  280. package/src/api/start-prod/providers/child-app.ts +7 -8
  281. package/src/api/start-prod/providers/shared.ts +6 -20
  282. package/src/builder/webpack/devServer/client.ts +22 -15
  283. package/src/builder/webpack/devServer/notifier.ts +6 -6
  284. package/src/builder/webpack/devServer/pool/process/pool.ts +3 -3
  285. package/src/builder/webpack/devServer/pool/thread/pool.ts +7 -0
  286. package/src/builder/webpack/devServer/server.ts +13 -6
  287. package/src/builder/webpack/providers/analyze/shared.ts +3 -2
  288. package/src/builder/webpack/providers/build/application/server.ts +5 -1
  289. package/src/builder/webpack/providers/build/client.ts +2 -2
  290. package/src/builder/webpack/providers/build/server.ts +1 -1
  291. package/src/builder/webpack/tokens.ts +4 -3
  292. package/src/builder/webpack/utils/copyBuildFile.ts +4 -5
  293. package/src/builder/webpack/utils/copyStatsJsonFile.ts +5 -2
  294. package/src/cli/CLI.ts +6 -6
  295. package/src/cli/index.ts +1 -1
  296. package/src/commands/analyze/command.ts +1 -1
  297. package/src/commands/benchmark/command.ts +1 -1
  298. package/src/commands/build/command.ts +2 -2
  299. package/src/commands/new/new.ts +0 -1
  300. package/src/commands/new/questions/packageManager.ts +1 -1
  301. package/src/commands/new/questions/template.ts +1 -1
  302. package/src/commands/new/questions/testingFramework.ts +1 -1
  303. package/src/commands/new/questions/type.ts +1 -1
  304. package/src/commands/new/steps/initializationGit.ts +1 -1
  305. package/src/commands/new/templates/app/monorepo/tramvai.json.hbs +6 -32
  306. package/src/commands/new/templates/app/multirepo/tramvai.json.hbs +6 -23
  307. package/src/commands/new/templates/child-app/monorepo/tramvai.json.hbs +3 -18
  308. package/src/commands/new/templates/child-app/multirepo/tramvai.json.hbs +3 -9
  309. package/src/commands/start/command.ts +2 -2
  310. package/src/commands/start-prod/command.ts +2 -2
  311. package/src/commands/static/application.ts +5 -14
  312. package/src/commands/static/command.ts +1 -1
  313. package/src/commands/static/generate.ts +2 -2
  314. package/src/commands/static/server.ts +5 -2
  315. package/src/commands/static/staticServer.ts +6 -3
  316. package/src/commands/update/updatePackageJson.ts +6 -2
  317. package/src/config/configManager.spec.ts +49 -0
  318. package/src/config/configManager.ts +129 -197
  319. package/src/config/showConfig.ts +2 -2
  320. package/src/config/validate.ts +14 -25
  321. package/src/di/tokens/config.ts +2 -1
  322. package/src/library/babel/index.ts +1 -0
  323. package/src/library/swc/__integration__/swc.build.test.ts +3 -21
  324. package/src/library/swc/__integration__/swc.start.test.ts +3 -21
  325. package/src/library/swc/index.ts +1 -1
  326. package/src/library/webpack/application/client/common.ts +7 -7
  327. package/src/library/webpack/application/client/dev.ts +9 -9
  328. package/src/library/webpack/application/client/prod/optimization/splitChunks.ts +43 -44
  329. package/src/library/webpack/application/client/prod.ts +3 -5
  330. package/src/library/webpack/application/server/common.ts +5 -8
  331. package/src/library/webpack/application/server/dev.ts +5 -6
  332. package/src/library/webpack/application/server/prod.ts +3 -9
  333. package/src/library/webpack/blocks/apiResolve.ts +1 -1
  334. package/src/library/webpack/blocks/configResolve.ts +2 -2
  335. package/src/library/webpack/blocks/configToEnv.ts +5 -2
  336. package/src/library/webpack/blocks/css.ts +26 -17
  337. package/src/library/webpack/blocks/extractCssPlugin.ts +11 -10
  338. package/src/library/webpack/blocks/filesClient.ts +52 -50
  339. package/src/library/webpack/blocks/filesServer.ts +4 -3
  340. package/src/library/webpack/blocks/js.ts +3 -2
  341. package/src/library/webpack/blocks/nodeClient.ts +4 -3
  342. package/src/library/webpack/blocks/optimize.ts +5 -6
  343. package/src/library/webpack/blocks/pagesResolve.ts +1 -1
  344. package/src/library/webpack/blocks/postcssAssets.ts +6 -7
  345. package/src/library/webpack/blocks/serverInline.ts +2 -1
  346. package/src/library/webpack/blocks/ts.ts +2 -1
  347. package/src/library/webpack/child-app/client/common.ts +3 -3
  348. package/src/library/webpack/child-app/client/dev.ts +8 -8
  349. package/src/library/webpack/child-app/client/prod.ts +2 -2
  350. package/src/library/webpack/child-app/common.ts +2 -2
  351. package/src/library/webpack/child-app/server/common.ts +3 -3
  352. package/src/library/webpack/child-app/server/dev.ts +2 -2
  353. package/src/library/webpack/child-app/server/prod.ts +2 -2
  354. package/src/library/webpack/common/client/prod.ts +10 -6
  355. package/src/library/webpack/common/main.ts +9 -4
  356. package/src/library/webpack/common/server/prod.ts +10 -6
  357. package/src/library/webpack/index.ts +2 -3
  358. package/src/library/webpack/loaders/image-loader/index.ts +2 -1
  359. package/src/library/webpack/loaders/pagesResolve.ts +17 -5
  360. package/src/library/webpack/loaders/replaceContent.ts +11 -2
  361. package/src/library/webpack/module/client/common.ts +1 -1
  362. package/src/library/webpack/module/externals.ts +1 -1
  363. package/src/library/webpack/module/resolveExternal.ts +1 -1
  364. package/src/library/webpack/module/server/common.ts +1 -1
  365. package/src/library/webpack/plugins/LazyModuleInitialization.ts +6 -1
  366. package/src/library/webpack/plugins/WebpackBar/utils/index.ts +8 -8
  367. package/src/library/webpack/plugins/WebpackBar/utils/webpack.ts +1 -1
  368. package/src/library/webpack/types/webpack.ts +2 -2
  369. package/src/library/webpack/utils/files.ts +4 -3
  370. package/src/library/webpack/utils/transpiler.ts +6 -11
  371. package/src/library/webpack/utils/workersPool.ts +6 -9
  372. package/src/models/config.spec.ts +352 -0
  373. package/src/models/config.ts +41 -9
  374. package/src/schema/ConfigSchema.ts +15 -4
  375. package/src/schema/autogeneratedSchema.json +1808 -2074
  376. package/src/schema/tramvai.spec.ts +89 -184
  377. package/src/typings/configEntry/application.ts +85 -87
  378. package/src/typings/configEntry/child-app.ts +10 -30
  379. package/src/typings/configEntry/cli.ts +271 -0
  380. package/src/typings/configEntry/common.ts +26 -278
  381. package/src/typings/configEntry/module.ts +11 -30
  382. package/src/typings/configEntry/package.ts +3 -1
  383. package/src/ui/commander.ts +1 -1
  384. package/src/utils/applyTemplate.ts +2 -2
  385. package/src/utils/detectPortSync.ts +7 -0
  386. package/src/utils/safeRequire.ts +6 -1
  387. package/src/utils/webpackBuild.ts +4 -3
  388. package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.d.ts +0 -37
  389. package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.js +0 -241
  390. package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.js.map +0 -1
  391. package/lib/library/webpack/plugins/DedupePlugin/index.d.ts +0 -1
  392. package/lib/library/webpack/plugins/DedupePlugin/index.js +0 -6
  393. package/lib/library/webpack/plugins/DedupePlugin/index.js.map +0 -1
  394. package/lib/typings/configEntry/CheckAsyncTsConfig.d.ts +0 -13
  395. package/lib/typings/configEntry/CheckAsyncTsConfig.js.map +0 -1
  396. package/src/library/webpack/plugins/DedupePlugin/DedupePlugin.spec.ts +0 -95
  397. package/src/library/webpack/plugins/DedupePlugin/DedupePlugin.ts +0 -307
  398. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/index.js +0 -3
  399. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/node_modules/package-dep/index.js +0 -1
  400. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/node_modules/package-dep/package.json +0 -7
  401. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/package.json +0 -7
  402. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/index.js +0 -3
  403. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/node_modules/package-dep/index.js +0 -1
  404. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/node_modules/package-dep/package.json +0 -7
  405. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/package.json +0 -7
  406. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/index.js +0 -3
  407. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/node_modules/package-dep/index.js +0 -1
  408. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/node_modules/package-dep/package.json +0 -7
  409. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/package.json +0 -7
  410. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-dep/index.js +0 -1
  411. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-dep/package.json +0 -7
  412. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/index.js +0 -3
  413. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/node_modules/package-esm-dep/index.js +0 -1
  414. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/node_modules/package-esm-dep/package.json +0 -8
  415. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/package.json +0 -8
  416. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/index.js +0 -3
  417. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/node_modules/package-esm-dep/index.js +0 -1
  418. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/node_modules/package-esm-dep/package.json +0 -8
  419. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/package.json +0 -8
  420. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/package-lock.json +0 -0
  421. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/package.json +0 -14
  422. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/src/index.js +0 -9
  423. package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/tramvai.json +0 -67
  424. package/src/library/webpack/plugins/DedupePlugin/__integration__/DedupePlugin.test.ts +0 -90
  425. package/src/library/webpack/plugins/DedupePlugin/index.ts +0 -1
  426. package/src/typings/configEntry/CheckAsyncTsConfig.ts +0 -15
@@ -0,0 +1,271 @@
1
+ import type { Configuration } from 'webpack';
2
+ import type { DeduplicateStrategy } from '@tinkoff/webpack-dedupe-plugin';
3
+ import type { ConfigEntry, OverridableOption } from './common';
4
+
5
+ type Notifications = {
6
+ /**
7
+ * @title Defines when success notifications are shown
8
+ */
9
+ suppressSuccess?: false | true | 'always' | 'initial';
10
+ /**
11
+ * @title True to suppress the warning notifications, otherwise false
12
+ */
13
+ suppressWarning?: boolean;
14
+ /**
15
+ * @title True to activate (focus) the terminal window when a compilation error occurs
16
+ */
17
+ activateTerminalOnError?: boolean;
18
+ };
19
+
20
+ export type WebpackExperiments = Omit<
21
+ Configuration['experiments'],
22
+ 'buildHttp' | 'lazyCompilation' | 'css'
23
+ > & {
24
+ /**
25
+ * @title Enable additional in-memory caching of modules which are unchanged and reference only unchanged modules.
26
+ * @default true
27
+ */
28
+ cacheUnaffected: boolean;
29
+ /**
30
+ * @title Enable backward compatibility with webpack previous major versions
31
+ * @default false
32
+ */
33
+ backCompat: boolean;
34
+ };
35
+
36
+ export type MinicssExperiments = {
37
+ /**
38
+ * @title Use a new webpack API to execute modules instead of child compilers. This improves performance and memory usage a lot.
39
+ * @default true
40
+ */
41
+ useImportModule: OverridableOption<boolean>;
42
+ };
43
+
44
+ export type TranspilationExperiments = {
45
+ /**
46
+ * @title specify loader to transpile js-ts code
47
+ * @default "babel"
48
+ */
49
+ loader: OverridableOption<'babel' | 'swc'>;
50
+ };
51
+
52
+ export interface Experiments {
53
+ /**
54
+ * @title experiments configuration for [webpack](https://webpack.js.org/configuration/experiments/)
55
+ * @default {}
56
+ */
57
+ webpack: WebpackExperiments;
58
+ /**
59
+ * @title experimental settings for [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin)
60
+ * @default {}
61
+ */
62
+ minicss: MinicssExperiments;
63
+
64
+ /**
65
+ * @title experimental settings for code transpilation
66
+ * @default {}
67
+ */
68
+ transpilation: TranspilationExperiments;
69
+ }
70
+
71
+ /**
72
+ * @default {}
73
+ * @additionalProperties true
74
+ */
75
+ type Define = Record<string, string>;
76
+
77
+ /**
78
+ * @tutorial
79
+ * - Common properties that are defined in the tramvai.json config file
80
+ * - These properties are later used to generate the json-schema
81
+ * - Although, some of the marked as required in typings they are anyway converted to optional
82
+ * while generating schema
83
+ * - you can provide default value with "@default" jsdoc in order to replace with default on schema validation
84
+ * - if you provide default value with "@default" mark the property as required to easier its usage in cli code
85
+ * - if the option doesn't have a default value mark it as optional to properly handle this case in cli code
86
+ * - to specify option that might be overridden for dev/prod environments specify its type as `OverridableOption<T>`. You can
87
+ * provide the default value either as single value (will be used in both envs) or in the form of { development: T, production: T } (to be able to
88
+ * provide defaults for all of the envs)
89
+ * - do not use `OverridableOption<T>` with complex types that has internal properties with "@default" as that defaults will not be set by ajv
90
+ */
91
+ export interface CliConfigEntry extends ConfigEntry {
92
+ /**
93
+ * @title Enable source maps
94
+ * @default false
95
+ */
96
+ sourceMap: OverridableOption<boolean>;
97
+ /**
98
+ * @title Change different experimental cli settings
99
+ * @default {}
100
+ */
101
+ experiments: Experiments;
102
+ /**
103
+ * @title List of modules to exclude from `@babel/preset-env`
104
+ * @description Option doesn't affect build with swc loader
105
+ */
106
+ excludesPresetEnv?: string[];
107
+ /**
108
+ * @title Webpack's thread-loader config
109
+ * @additionalProperties true
110
+ */
111
+ threadLoader?: Record<string, unknown>;
112
+ /**
113
+ * @title Define static variables that should be replaced by name with provided value
114
+ * @default {}
115
+ */
116
+ define: {
117
+ shared: Define;
118
+ development: Define;
119
+ production: Define;
120
+ };
121
+ /**
122
+ * @title `@deprecated` will be removed in next major release.
123
+ * @default false
124
+ */
125
+ generateDataQaTag: boolean;
126
+ /**
127
+ * @title `@deprecated` will be removed in next major release. Включает использование плагина fill-action-name
128
+ * @default false
129
+ */
130
+ enableFillActionNamePlugin: boolean;
131
+ /**
132
+ * @default {}
133
+ */
134
+ postcss: {
135
+ /**
136
+ * @title Path to postcss config file. By default, `postcss.config.js` file is used
137
+ */
138
+ config?: string;
139
+ /**
140
+ * @title CSS identifiers build algorithm
141
+ */
142
+ cssLocalIdentName?: OverridableOption<string>;
143
+ /**
144
+ * @title Path to postcss config file for assets
145
+ */
146
+ assetsConfig?: string;
147
+
148
+ /**
149
+ * @title Enable CSS modules for all files matching /RegExp/i.test(filename) regexp.
150
+ */
151
+ cssModulePattern?: string;
152
+ };
153
+ /**
154
+ * @title `@deprecated` as cli now supports baseUrl and paths from the app's tsconfig.json file.
155
+ * Just check or add configuration to your tsconfig file and remove alias from tramvai.json
156
+ * @additionalProperties true
157
+ */
158
+ alias?: Record<string, any>;
159
+ /**
160
+ * @title svgo-loader options
161
+ */
162
+ svgo?: {
163
+ /**
164
+ * @title svgo plugins
165
+ */
166
+ plugins?: Array<any>;
167
+ };
168
+
169
+ /**
170
+ * @title Settings for image-webpack-loader
171
+ */
172
+ imageOptimization?: {
173
+ /**
174
+ * @title Enable image-webpack-loader
175
+ */
176
+ enabled?: boolean;
177
+ /**
178
+ * @title Pass options to image-webpack-loader
179
+ * @additionalProperties true
180
+ */
181
+ options?: Record<string, any>;
182
+ };
183
+ /**
184
+ * @title transpile libs based only on %40tinkoff/is-modern-lib
185
+ * @default true
186
+ */
187
+ transpileOnlyModernLibs: boolean;
188
+ /**
189
+ * @title Webpack specific settings
190
+ * @default {}
191
+ */
192
+ webpack: {
193
+ /**
194
+ * @title Browser package resolve aliases. E.g. { "stream": "stream-browserify" }
195
+ * @additionalProperties true
196
+ */
197
+ resolveAlias?: Record<string, string>;
198
+ /**
199
+ * @title Browser packages to provide with ProvidePlugin. E.g. { "Buffer": ["buffer", "Buffer"] }
200
+ * @additionalProperties true
201
+ */
202
+ provide?: Record<string, any>;
203
+ };
204
+
205
+ // options that affect only production builds
206
+ /**
207
+ * @title Enable DedupePlugin
208
+ * @default {}
209
+ */
210
+ dedupe: {
211
+ /**
212
+ * @title Strategy for DedupePlugin
213
+ * @default true
214
+ */
215
+ enabled: boolean;
216
+ /**
217
+ * @title Strategy for DedupePlugin
218
+ * @default "equality"
219
+ */
220
+ strategy: DeduplicateStrategy;
221
+ /**
222
+ * @title Sets ignore to DedupePlugin
223
+ */
224
+ ignore?: string[];
225
+ };
226
+ /**
227
+ * @title terser settings
228
+ * @default {}
229
+ */
230
+ terser: {
231
+ /**
232
+ * @title Configuration for enabling parallel compression for terser plugin
233
+ * @default true
234
+ */
235
+ parallel: boolean;
236
+ };
237
+ /**
238
+ * @title Set minimizer for css
239
+ * @default "css-minimizer"
240
+ */
241
+ cssMinimize: 'csso' | 'css-minimizer';
242
+
243
+ // options that affect only development builds
244
+
245
+ /**
246
+ * @title React hot-refresh
247
+ * @default {}
248
+ */
249
+ hotRefresh: {
250
+ /**
251
+ * @title Enable react hot-refresh
252
+ * @default true
253
+ */
254
+ enabled?: boolean;
255
+ /**
256
+ * @title Configure react hot-refresh https://github.com/pmmmwh/react-refresh-webpack-plugin#options
257
+ */
258
+ options?: {
259
+ overlay?: boolean | Record<string, any>;
260
+ [key: string]: any;
261
+ };
262
+ };
263
+ /**
264
+ * @title Controls build notifications settings during development
265
+ * @default {}
266
+ */
267
+ notifications: Notifications & {
268
+ client?: Notifications;
269
+ server?: Notifications;
270
+ };
271
+ }
@@ -1,293 +1,41 @@
1
- import type { Configuration } from 'webpack';
1
+ import all from '@tinkoff/utils/array/all';
2
2
  import type { ProjectType } from '../projectType';
3
- import type { DeduplicateStrategy } from '../../library/webpack/plugins/DedupePlugin';
4
3
 
5
- type ServeNotifications = {
6
- /**
7
- * @title Defines when success notifications are shown
8
- */
9
- suppressSuccess?: false | true | 'always' | 'initial';
10
- /**
11
- * @title True to suppress the warning notifications, otherwise false
12
- */
13
- suppressWarning?: boolean;
14
- /**
15
- * @title True to activate (focus) the terminal window when a compilation error occurs
16
- */
17
- activateTerminalOnError?: boolean;
4
+ enum Brand {
5
+ _ = '',
6
+ }
7
+
8
+ /**
9
+ * @cli_overridable
10
+ */
11
+ export type OverridableOption<T> = Brand & {
12
+ development?: T;
13
+ production?: T;
18
14
  };
19
15
 
20
- export interface Experiments {
21
- /**
22
- * @title experiments configuration for [webpack](https://webpack.js.org/configuration/experiments/)
23
- * @default {}
24
- */
25
- webpack?: Omit<Configuration['experiments'], 'buildHttp' | 'lazyCompilation'> & {
26
- /**
27
- * @title Enable additional in-memory caching of modules which are unchanged and reference only unchanged modules.
28
- * @default true
29
- */
30
- cacheUnaffected?: boolean;
31
- /**
32
- * @title Enable backward compatibility with webpack previous major versions
33
- * @default false
34
- */
35
- backCompat?: boolean;
36
- };
37
- /**
38
- * @title experimental settings for [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin)
39
- * @default {}
40
- */
41
- minicss?: {
42
- /**
43
- * @title Use a new webpack API to execute modules instead of child compilers. This improves performance and memory usage a lot.
44
- * @default true
45
- */
46
- useImportModule?: boolean;
47
- };
16
+ export const isOverridableOption = <T>(
17
+ option: Record<string, any>
18
+ ): option is OverridableOption<T> => {
19
+ if (!option || typeof option !== 'object') {
20
+ return false;
21
+ }
48
22
 
49
- /**
50
- * @title experimental settings for code transpilation
51
- * @default {}
52
- */
53
- transpilation?: {
54
- /**
55
- * @title specify loader to transpile js-ts code
56
- * @default "babel"
57
- */
58
- loader?: 'babel' | 'swc';
59
- };
60
- }
23
+ const keys = Object.keys(option);
61
24
 
62
- interface ServeConfig {
63
- /**
64
- * @default {}
65
- */
66
- notifications?: ServeNotifications & {
67
- client?: ServeNotifications;
68
- server?: ServeNotifications;
69
- };
70
- /**
71
- * @default {}
72
- */
73
- configurations?: {
74
- /**
75
- * @title Enable source maps in development build (for client and server build)
76
- * @default false
77
- */
78
- sourceMap?: boolean;
79
- /**
80
- * @title Enable development build for modern browsers
81
- * @default true
82
- */
83
- modern?: boolean;
84
- /**
85
- * @title Enable react hot-refresh
86
- * @default true
87
- */
88
- hotRefresh?: boolean;
89
- /**
90
- * @title Configure react hot-refresh https://github.com/pmmmwh/react-refresh-webpack-plugin#options
91
- */
92
- hotRefreshOptions?: {
93
- overlay?: boolean | Record<string, any>;
94
- [key: string]: any;
95
- };
96
- /**
97
- * @title Experimental settings
98
- * @default {}
99
- */
100
- experiments?: Experiments;
101
- };
102
- }
25
+ return keys.length && all((key) => key === 'development' || key === 'production', keys);
26
+ };
103
27
 
104
- interface BuildConfig {
28
+ export interface ConfigEntry {
105
29
  /**
106
- * @default {}
30
+ * @title name of the project
107
31
  */
108
- options?: Record<string, any>;
32
+ name: string;
109
33
  /**
110
- * @default {}
34
+ * @title path to the root directory relative to the tramvai.json
111
35
  */
112
- configurations?: {
113
- /**
114
- * @title Enable production build for modern browsers
115
- * @default true
116
- */
117
- modern?: boolean;
118
- /**
119
- * @title Enable DedupePlugin
120
- * @default "equality"
121
- */
122
- dedupe?: DeduplicateStrategy | false;
123
- /**
124
- * @title Sets ignore to DedupePlugin
125
- */
126
- dedupeIgnore?: string[];
127
- /**
128
- * @title Enable replacing `typeof window` expression
129
- * @default true
130
- */
131
- removeTypeofWindow?: boolean;
132
- /**
133
- * @title Enable source maps in production build
134
- * @default false
135
- */
136
- sourceMap?: boolean;
137
- /**
138
- * @title Enable source maps for server assets in production build
139
- * @default false
140
- */
141
- sourceMapServer?: boolean;
142
- /**
143
- * @title Configuration for enabling parallel compression for terser plugin
144
- * @default true
145
- */
146
- terserParallel?: boolean;
147
- /**
148
- * @title List of modules to exclude from @babel/preset-env
149
- */
150
- excludesPresetEnv?: string[];
151
- /**
152
- * @title thread-loader config
153
- * @additionalProperties true
154
- */
155
- threadLoader?: Record<string, any>;
156
- /**
157
- * @title Define plugin config
158
- * @default {"prod": {}, "dev": {}}
159
- * @additionalProperties true
160
- */
161
- definePlugin?: Record<string, any>;
162
- /**
163
- * @deprecated
164
- *
165
- * @default false
166
- */
167
- generateDataQaTag?: boolean;
168
- /**
169
- * @deprecated включает использование плагина fill-action-name
170
- *
171
- * @default false
172
- */
173
- enableFillActionNamePlugin?: boolean;
174
- /**
175
- * @title Set minimizer for css
176
- */
177
- cssMinimize?: 'csso';
178
- postcss?: {
179
- /**
180
- * @title Path to postcss config file
181
- */
182
- config?: string;
183
- /**
184
- * @title CSS identifiers build algorythm
185
- */
186
- cssLocalIdentName?: string;
187
- /**
188
- * @title CSS identifiers build algorythm for development buld
189
- */
190
- cssLocalIdentNameDev?: string;
191
- /**
192
- * @title CSS identifiers build algorythm for production build
193
- */
194
- cssLocalIdentNameProd?: string;
195
- /**
196
- * @title Path to postcss config file for assets
197
- */
198
- assetsConfig?: string;
199
- };
200
- /**
201
- * @title `@@deprecated @tramvai/cli now supports baseUrl and paths from the app's tsconfig.json file.
202
- * Just check or add configuration to your tsconfig file and remove alias from tramvai.json`
203
- * @deprecated
204
- * @additionalProperties true
205
- */
206
- alias?: Record<string, any>;
207
- /**
208
- * @title svgo-loader options
209
- */
210
- svgo?: {
211
- /**
212
- * @title svgo plugins
213
- */
214
- plugins?: Record<string, any>[];
215
- };
216
- /**
217
- * @title Settings for image-webpack-loader
218
- */
219
- imageOptimization?: {
220
- /**
221
- * @title Enable image-webpack-loader
222
- */
223
- enabled?: boolean;
224
- /**
225
- * @title Pass options to image-webpack-loader
226
- * @additionalProperties true
227
- */
228
- options?: Record<string, any>;
229
- };
230
- /**
231
- * @title transpile libs based only on %40tinkoff/is-modern-lib
232
- * @default true
233
- */
234
- transpileOnlyModernLibs?: boolean;
235
- /**
236
- * @title Browser package resolve aliases. E.g. { "stream": "stream-browserify" }
237
- * @additionalProperties true
238
- */
239
- webpackResolveAlias?: Record<string, string>;
240
- /**
241
- * @title Browser packages to provide with ProvidePlugin. E.g. { "Buffer": ["buffer", "Buffer"] }
242
- * @additionalProperties true
243
- */
244
- webpackProvide?: Record<string, any>;
245
-
246
- /**
247
- * @title experimental settings for File-System Routing feature
248
- * @default {}
249
- */
250
- fileSystemPages?: {
251
- /**
252
- * @title Read pages from file system
253
- * @default false
254
- */
255
- enable?: boolean;
256
- /**
257
- * @title Folder with pages from which static routers are generated
258
- * @default "routes"
259
- */
260
- routesDir?: string | false;
261
- /**
262
- * @title Folder with components which can be manually added to static routers
263
- * @default "pages"
264
- */
265
- pagesDir?: string | false;
266
- };
267
- /**
268
- * @title Experimental settings
269
- * @default {}
270
- */
271
- experiments?: Experiments;
272
- };
273
- }
274
-
275
- export interface ConfigEntry {
276
- name: string;
277
36
  root: string;
278
- type: ProjectType;
279
- version?: string;
280
37
  /**
281
- * @default {}
38
+ * @title type of the project
282
39
  */
283
- commands?: {
284
- /**
285
- * @default {}
286
- */
287
- build?: BuildConfig;
288
- /**
289
- * @default {}
290
- */
291
- serve?: ServeConfig;
292
- };
40
+ type: ProjectType;
293
41
  }
@@ -1,40 +1,21 @@
1
- import type { ConfigEntry } from './common';
1
+ import type { CliConfigEntry } from './cli';
2
+
3
+ export interface ModuleConfigEntry extends CliConfigEntry {
4
+ type: 'module';
2
5
 
3
- export interface ModuleBuild {
4
6
  /**
5
- * @default {}
7
+ * @title Path to build module assets
8
+ * @default "dist/modules"
6
9
  */
7
- options?: {
8
- /**
9
- * @title Path to build module assets
10
- * @default "dist/modules"
11
- */
12
- output?: string;
13
- };
10
+ output: string;
14
11
  /**
15
12
  * @default {}
16
13
  */
17
- configurations?: ConfigEntry['commands']['build']['configurations'] & {
18
- /**
19
- * @default {"config": "postcss.config", "cssLocalIdentName": "[hash:base64:5]"}
20
- */
21
- postcss?: ConfigEntry['commands']['build']['configurations']['postcss'];
22
- };
23
- }
24
-
25
- export interface ModuleConfigEntry extends ConfigEntry {
26
- type: 'module';
27
- /**
28
- * @default {}
29
- */
30
- commands?: {
31
- /**
32
- * @default {}
33
- */
34
- build?: ModuleBuild;
14
+ postcss: CliConfigEntry['postcss'] & {
35
15
  /**
36
- * @default {}
16
+ * @title CSS identifiers build algorithm
17
+ * @default "[hash:base64:5]"
37
18
  */
38
- serve?: ConfigEntry['commands']['serve'];
19
+ cssLocalIdentName?: CliConfigEntry['postcss']['cssLocalIdentName'];
39
20
  };
40
21
  }
@@ -1,4 +1,6 @@
1
- export interface PackageConfigEntry {
1
+ import type { ConfigEntry } from './common';
2
+
3
+ export interface PackageConfigEntry extends ConfigEntry {
2
4
  type: 'package';
3
5
  /**
4
6
  * @title Package name
@@ -37,7 +37,7 @@ function getOptions(cmd) {
37
37
  cmd.options.forEach((o) => {
38
38
  const key = o.long.replace(/^--/, '');
39
39
 
40
- if (typeof cmd[key] !== 'function') {
40
+ if (typeof cmd[key] !== 'function' && typeof cmd[key] !== 'undefined') {
41
41
  args[key] = cmd[key];
42
42
  }
43
43
  });
@@ -26,10 +26,10 @@ const replaceHbs = (pathFile: string) => pathFile.replace(/\.hbs$/, '');
26
26
  * @returns Object indicating whether the template application was successful
27
27
  */
28
28
 
29
- function transformOutputPath(rawPath): string {
29
+ function transformOutputPath(rawPath: string): string {
30
30
  return rawPath
31
31
  .split('/')
32
- .map((filename) => {
32
+ .map((filename: string) => {
33
33
  // dotfiles are ignored when published to npm, therefore in templates
34
34
  // we need to use underscore instead (e.g. "_gitignore")
35
35
  if (filename.charAt(0) === '_' && filename.charAt(1) !== '_') {
@@ -0,0 +1,7 @@
1
+ import { execSync } from 'child_process';
2
+
3
+ export const detectPortSync = (port: number): number => {
4
+ const commandResult = execSync(`npx detect-port ${port}`);
5
+
6
+ return parseInt(commandResult.toString('utf-8'), 10);
7
+ };
@@ -1,3 +1,6 @@
1
+ import { sync as resolve } from 'resolve';
2
+ import { extensions } from '../config/constants';
3
+
1
4
  export const safeRequire = (path: string, silent?: boolean) => {
2
5
  try {
3
6
  return require(path);
@@ -11,7 +14,9 @@ export const safeRequire = (path: string, silent?: boolean) => {
11
14
 
12
15
  export const safeRequireResolve = (path: string, silent?: boolean) => {
13
16
  try {
14
- return require.resolve(path);
17
+ return resolve(path, {
18
+ extensions,
19
+ });
15
20
  } catch (error) {
16
21
  if (!silent) {
17
22
  // TODO: replace with logger from di