piral-cli 1.0.0-pre.2217 → 1.0.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 (408) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +30 -7
  3. package/lib/api.js +23 -23
  4. package/lib/api.js.map +1 -1
  5. package/lib/apps/add-piral-instance-pilet.d.ts +26 -0
  6. package/lib/apps/add-piral-instance-pilet.js +53 -0
  7. package/lib/apps/add-piral-instance-pilet.js.map +1 -0
  8. package/lib/apps/build-pilet.d.ts +33 -2
  9. package/lib/apps/build-pilet.js +159 -32
  10. package/lib/apps/build-pilet.js.map +1 -1
  11. package/lib/apps/build-piral.d.ts +18 -1
  12. package/lib/apps/build-piral.js +68 -52
  13. package/lib/apps/build-piral.js.map +1 -1
  14. package/lib/apps/debug-pilet.d.ts +38 -2
  15. package/lib/apps/debug-pilet.js +150 -108
  16. package/lib/apps/debug-pilet.js.map +1 -1
  17. package/lib/apps/debug-piral.d.ts +23 -0
  18. package/lib/apps/debug-piral.js +63 -52
  19. package/lib/apps/debug-piral.js.map +1 -1
  20. package/lib/apps/declaration-piral.js +5 -3
  21. package/lib/apps/declaration-piral.js.map +1 -1
  22. package/lib/apps/index.d.ts +3 -0
  23. package/lib/apps/index.js +8 -1
  24. package/lib/apps/index.js.map +1 -1
  25. package/lib/apps/new-pilet.d.ts +7 -3
  26. package/lib/apps/new-pilet.js +47 -52
  27. package/lib/apps/new-pilet.js.map +1 -1
  28. package/lib/apps/new-piral.d.ts +7 -3
  29. package/lib/apps/new-piral.js +33 -23
  30. package/lib/apps/new-piral.js.map +1 -1
  31. package/lib/apps/pack-pilet.d.ts +9 -0
  32. package/lib/apps/pack-pilet.js +6 -13
  33. package/lib/apps/pack-pilet.js.map +1 -1
  34. package/lib/apps/publish-pilet.d.ts +23 -3
  35. package/lib/apps/publish-pilet.js +112 -62
  36. package/lib/apps/publish-pilet.js.map +1 -1
  37. package/lib/apps/publish-piral.d.ts +6 -2
  38. package/lib/apps/publish-piral.js +30 -26
  39. package/lib/apps/publish-piral.js.map +1 -1
  40. package/lib/apps/remove-piral-instance-pilet.d.ts +22 -0
  41. package/lib/apps/remove-piral-instance-pilet.js +52 -0
  42. package/lib/apps/remove-piral-instance-pilet.js.map +1 -0
  43. package/lib/apps/run-emulator-piral.d.ts +34 -0
  44. package/lib/apps/run-emulator-piral.js +91 -0
  45. package/lib/apps/run-emulator-piral.js.map +1 -0
  46. package/lib/apps/upgrade-pilet.d.ts +6 -2
  47. package/lib/apps/upgrade-pilet.js +41 -43
  48. package/lib/apps/upgrade-pilet.js.map +1 -1
  49. package/lib/apps/upgrade-piral.d.ts +2 -2
  50. package/lib/apps/upgrade-piral.js +21 -20
  51. package/lib/apps/upgrade-piral.js.map +1 -1
  52. package/lib/apps/validate-pilet.js +30 -36
  53. package/lib/apps/validate-pilet.js.map +1 -1
  54. package/lib/apps/validate-piral.js +13 -10
  55. package/lib/apps/validate-piral.js.map +1 -1
  56. package/lib/build/bundler-calls.d.ts +3 -0
  57. package/lib/build/bundler-calls.js +117 -0
  58. package/lib/build/bundler-calls.js.map +1 -0
  59. package/lib/build/run-build-pilet.d.ts +1 -0
  60. package/lib/build/run-build-pilet.js +65 -0
  61. package/lib/build/run-build-pilet.js.map +1 -0
  62. package/lib/build/run-build-piral.d.ts +1 -0
  63. package/lib/build/run-build-piral.js +67 -0
  64. package/lib/build/run-build-piral.js.map +1 -0
  65. package/lib/build/run-debug-mono-piral.d.ts +1 -0
  66. package/lib/build/run-debug-mono-piral.js +70 -0
  67. package/lib/build/run-debug-mono-piral.js.map +1 -0
  68. package/lib/build/run-debug-pilet.d.ts +1 -0
  69. package/lib/build/run-debug-pilet.js +89 -0
  70. package/lib/build/run-debug-pilet.js.map +1 -0
  71. package/lib/build/run-debug-piral.d.ts +1 -0
  72. package/lib/build/run-debug-piral.js +85 -0
  73. package/lib/build/run-debug-piral.js.map +1 -0
  74. package/lib/bundler.js +75 -26
  75. package/lib/bundler.js.map +1 -1
  76. package/lib/cli.js +7 -4
  77. package/lib/cli.js.map +1 -1
  78. package/lib/commands.js +266 -46
  79. package/lib/commands.js.map +1 -1
  80. package/lib/common/archive.d.ts +4 -0
  81. package/lib/common/archive.js +31 -10
  82. package/lib/common/archive.js.map +1 -1
  83. package/lib/common/browser.d.ts +2 -1
  84. package/lib/common/browser.js +17 -8
  85. package/lib/common/browser.js.map +1 -1
  86. package/lib/common/clients/index.d.ts +21 -0
  87. package/lib/common/clients/index.js +48 -0
  88. package/lib/common/clients/index.js.map +1 -0
  89. package/lib/common/clients/lerna.d.ts +7 -1
  90. package/lib/common/clients/lerna.js +93 -7
  91. package/lib/common/clients/lerna.js.map +1 -1
  92. package/lib/common/clients/npm.d.ts +6 -1
  93. package/lib/common/clients/npm.js +66 -18
  94. package/lib/common/clients/npm.js.map +1 -1
  95. package/lib/common/clients/pnp.d.ts +7 -0
  96. package/lib/common/clients/pnp.js +104 -0
  97. package/lib/common/clients/pnp.js.map +1 -0
  98. package/lib/common/clients/pnpm.d.ts +5 -0
  99. package/lib/common/clients/pnpm.js +55 -6
  100. package/lib/common/clients/pnpm.js.map +1 -1
  101. package/lib/common/clients/rush.d.ts +7 -0
  102. package/lib/common/clients/rush.js +127 -0
  103. package/lib/common/clients/rush.js.map +1 -0
  104. package/lib/common/clients/yarn.d.ts +5 -0
  105. package/lib/common/clients/yarn.js +57 -6
  106. package/lib/common/clients/yarn.js.map +1 -1
  107. package/lib/common/compatibility.js +14 -9
  108. package/lib/common/compatibility.js.map +1 -1
  109. package/lib/common/config.d.ts +52 -1
  110. package/lib/common/config.js +10 -30
  111. package/lib/common/config.js.map +1 -1
  112. package/lib/common/constants.d.ts +10 -2
  113. package/lib/common/constants.js +22 -4
  114. package/lib/common/constants.js.map +1 -1
  115. package/lib/common/declaration.d.ts +2 -1
  116. package/lib/common/declaration.js +113 -56
  117. package/lib/common/declaration.js.map +1 -1
  118. package/lib/common/emoji.d.ts +8 -0
  119. package/lib/common/emoji.js +10 -1
  120. package/lib/common/emoji.js.map +1 -1
  121. package/lib/common/emulator.d.ts +2 -2
  122. package/lib/common/emulator.js +45 -32
  123. package/lib/common/emulator.js.map +1 -1
  124. package/lib/common/enums.d.ts +0 -4
  125. package/lib/common/enums.js +1 -6
  126. package/lib/common/enums.js.map +1 -1
  127. package/lib/common/envs.js +16 -5
  128. package/lib/common/envs.js.map +1 -1
  129. package/lib/common/hash.d.ts +1 -0
  130. package/lib/common/hash.js +8 -3
  131. package/lib/common/hash.js.map +1 -1
  132. package/lib/common/http.d.ts +5 -2
  133. package/lib/common/http.js +65 -23
  134. package/lib/common/http.js.map +1 -1
  135. package/lib/common/importmap.d.ts +2 -0
  136. package/lib/common/importmap.js +202 -0
  137. package/lib/common/importmap.js.map +1 -0
  138. package/lib/common/index.d.ts +10 -0
  139. package/lib/common/index.js +15 -1
  140. package/lib/common/index.js.map +1 -1
  141. package/lib/common/info.d.ts +5 -0
  142. package/lib/common/info.js +9 -2
  143. package/lib/common/info.js.map +1 -1
  144. package/lib/common/injectors.d.ts +36 -8
  145. package/lib/common/injectors.js +46 -19
  146. package/lib/common/injectors.js.map +1 -1
  147. package/lib/common/inspect.d.ts +5 -3
  148. package/lib/common/inspect.js +15 -15
  149. package/lib/common/inspect.js.map +1 -1
  150. package/lib/common/interactive.d.ts +9 -0
  151. package/lib/common/interactive.js +60 -1
  152. package/lib/common/interactive.js.map +1 -1
  153. package/lib/common/io.d.ts +9 -3
  154. package/lib/common/io.js +219 -116
  155. package/lib/common/io.js.map +1 -1
  156. package/lib/common/language.d.ts +9 -6
  157. package/lib/common/language.js +68 -12
  158. package/lib/common/language.js.map +1 -1
  159. package/lib/common/log.d.ts +5 -3
  160. package/lib/common/log.js +34 -48
  161. package/lib/common/log.js.map +1 -1
  162. package/lib/common/npm.d.ts +17 -16
  163. package/lib/common/npm.js +262 -158
  164. package/lib/common/npm.js.map +1 -1
  165. package/lib/common/pack.js +47 -26
  166. package/lib/common/pack.js.map +1 -1
  167. package/lib/common/package.d.ts +43 -20
  168. package/lib/common/package.js +377 -213
  169. package/lib/common/package.js.map +1 -1
  170. package/lib/common/parallel.d.ts +1 -0
  171. package/lib/common/parallel.js +29 -0
  172. package/lib/common/parallel.js.map +1 -0
  173. package/lib/common/patcher.js +20 -20
  174. package/lib/common/patcher.js.map +1 -1
  175. package/lib/common/platform.d.ts +13 -0
  176. package/lib/common/platform.js +29 -0
  177. package/lib/common/platform.js.map +1 -0
  178. package/lib/common/port.d.ts +1 -0
  179. package/lib/common/port.js +14 -4
  180. package/lib/common/port.js.map +1 -1
  181. package/lib/common/rules.js +4 -4
  182. package/lib/common/rules.js.map +1 -1
  183. package/lib/common/scaffold.d.ts +18 -4
  184. package/lib/common/scaffold.js +59 -36
  185. package/lib/common/scaffold.js.map +1 -1
  186. package/lib/common/scripts.js +8 -8
  187. package/lib/common/scripts.js.map +1 -1
  188. package/lib/common/shell.d.ts +2 -0
  189. package/lib/common/shell.js +33 -0
  190. package/lib/common/shell.js.map +1 -0
  191. package/lib/common/spec.d.ts +29 -0
  192. package/lib/common/spec.js +69 -0
  193. package/lib/common/spec.js.map +1 -0
  194. package/lib/common/template.d.ts +1 -2
  195. package/lib/common/template.js +23 -22
  196. package/lib/common/template.js.map +1 -1
  197. package/lib/common/url.d.ts +1 -0
  198. package/lib/common/url.js +17 -0
  199. package/lib/common/url.js.map +1 -0
  200. package/lib/common/utils.d.ts +1 -0
  201. package/lib/common/utils.js +8 -0
  202. package/lib/common/utils.js.map +1 -0
  203. package/lib/common/version.d.ts +2 -0
  204. package/lib/common/version.js +130 -0
  205. package/lib/common/version.js.map +1 -0
  206. package/lib/common/watcher.d.ts +13 -0
  207. package/lib/common/watcher.js +78 -0
  208. package/lib/common/watcher.js.map +1 -0
  209. package/lib/external/index.js +59413 -57862
  210. package/lib/helpers.d.ts +6 -6
  211. package/lib/helpers.js +10 -25
  212. package/lib/helpers.js.map +1 -1
  213. package/lib/index.js +5 -1
  214. package/lib/index.js.map +1 -1
  215. package/lib/inject.js +2 -2
  216. package/lib/inject.js.map +1 -1
  217. package/lib/injectors/pilet-injector.d.ts +75 -0
  218. package/lib/injectors/pilet-injector.js +246 -0
  219. package/lib/injectors/pilet-injector.js.map +1 -0
  220. package/lib/injectors/{piral.d.ts → piral-injector.d.ts} +10 -2
  221. package/lib/injectors/piral-injector.js +97 -0
  222. package/lib/injectors/piral-injector.js.map +1 -0
  223. package/lib/messages.d.ts +567 -47
  224. package/lib/messages.js +638 -51
  225. package/lib/messages.js.map +1 -1
  226. package/lib/pb-cli.js +1 -1
  227. package/lib/pb-cli.js.map +1 -1
  228. package/lib/pilet-cli.js +1 -1
  229. package/lib/pilet-cli.js.map +1 -1
  230. package/lib/piral-cli.js +1 -1
  231. package/lib/piral-cli.js.map +1 -1
  232. package/lib/platforms/node.d.ts +8 -0
  233. package/lib/platforms/node.js +30 -0
  234. package/lib/platforms/node.js.map +1 -0
  235. package/lib/platforms/web.d.ts +8 -0
  236. package/lib/platforms/web.js +120 -0
  237. package/lib/platforms/web.js.map +1 -0
  238. package/lib/plugin.js +36 -11
  239. package/lib/plugin.js.map +1 -1
  240. package/lib/questionnaire.d.ts +1 -1
  241. package/lib/questionnaire.js +9 -4
  242. package/lib/questionnaire.js.map +1 -1
  243. package/lib/release.d.ts +1 -1
  244. package/lib/release.js +38 -6
  245. package/lib/release.js.map +1 -1
  246. package/lib/resolvers.js +13 -13
  247. package/lib/resolvers.js.map +1 -1
  248. package/lib/rules/index.js +8 -8
  249. package/lib/rules/index.js.map +1 -1
  250. package/lib/rules/pilet-has-externals-as-peers.d.ts +1 -1
  251. package/lib/rules/pilet-has-externals-as-peers.js +9 -7
  252. package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
  253. package/lib/rules/pilet-has-no-self-reference.d.ts +1 -1
  254. package/lib/rules/pilet-has-no-self-reference.js +2 -2
  255. package/lib/rules/pilet-has-no-self-reference.js.map +1 -1
  256. package/lib/rules/pilet-has-no-third-party-dependency.d.ts +1 -1
  257. package/lib/rules/pilet-stays-small.d.ts +1 -1
  258. package/lib/rules/pilet-stays-small.js +4 -4
  259. package/lib/rules/pilet-stays-small.js.map +1 -1
  260. package/lib/rules/pilet-uses-latest-piral.d.ts +1 -1
  261. package/lib/rules/pilet-uses-latest-piral.js +18 -9
  262. package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
  263. package/lib/rules/piral-depends-on-piral.d.ts +1 -1
  264. package/lib/rules/piral-entry-ends-with-html.d.ts +1 -1
  265. package/lib/rules/piral-entry-ends-with-html.js +1 -1
  266. package/lib/rules/piral-entry-ends-with-html.js.map +1 -1
  267. package/lib/rules/piral-has-valid-devDependencies.d.ts +1 -1
  268. package/lib/rules/piral-has-valid-externals.d.ts +1 -1
  269. package/lib/rules/piral-has-valid-externals.js +10 -24
  270. package/lib/rules/piral-has-valid-externals.js.map +1 -1
  271. package/lib/rules/piral-has-valid-files.d.ts +1 -1
  272. package/lib/rules/piral-has-valid-files.js +5 -5
  273. package/lib/rules/piral-has-valid-files.js.map +1 -1
  274. package/lib/rules/piral-has-valid-scripts.d.ts +1 -1
  275. package/lib/runner.js +1 -1
  276. package/lib/runner.js.map +1 -1
  277. package/lib/select.js +6 -6
  278. package/lib/select.js.map +1 -1
  279. package/lib/types/common.d.ts +88 -8
  280. package/lib/types/common.js.map +1 -1
  281. package/lib/types/index.js +5 -1
  282. package/lib/types/index.js.map +1 -1
  283. package/lib/types/internal.d.ts +12 -13
  284. package/lib/types/public.d.ts +89 -23
  285. package/package.json +19 -16
  286. package/src/apps/add-piral-instance-pilet.ts +98 -0
  287. package/src/apps/build-pilet.ts +286 -38
  288. package/src/apps/build-piral.test.ts +20 -7
  289. package/src/apps/build-piral.ts +90 -39
  290. package/src/apps/debug-pilet.ts +229 -123
  291. package/src/apps/debug-piral.ts +121 -68
  292. package/src/apps/declaration-piral.ts +4 -2
  293. package/src/apps/index.ts +3 -0
  294. package/src/apps/new-pilet.test.ts +28 -11
  295. package/src/apps/new-pilet.ts +60 -48
  296. package/src/apps/new-piral.test.ts +25 -13
  297. package/src/apps/new-piral.ts +43 -19
  298. package/src/apps/pack-pilet.test.ts +2 -2
  299. package/src/apps/pack-pilet.ts +12 -10
  300. package/src/apps/publish-pilet.ts +148 -43
  301. package/src/apps/publish-piral.ts +38 -11
  302. package/src/apps/remove-piral-instance-pilet.ts +92 -0
  303. package/src/apps/run-emulator-piral.ts +154 -0
  304. package/src/apps/upgrade-pilet.ts +37 -31
  305. package/src/apps/upgrade-piral.ts +9 -7
  306. package/src/apps/validate-pilet.ts +30 -22
  307. package/src/apps/validate-piral.ts +5 -2
  308. package/src/build/bundler-calls.ts +133 -0
  309. package/src/build/run-build-pilet.ts +91 -0
  310. package/src/build/run-build-piral.ts +93 -0
  311. package/src/build/run-debug-mono-piral.ts +86 -0
  312. package/src/build/run-debug-pilet.ts +116 -0
  313. package/src/build/run-debug-piral.ts +105 -0
  314. package/src/bundler.test.ts +86 -68
  315. package/src/bundler.ts +74 -19
  316. package/src/cli.ts +6 -2
  317. package/src/commands.ts +273 -44
  318. package/src/common/archive.test.ts +51 -45
  319. package/src/common/archive.ts +28 -1
  320. package/src/common/browser.test.ts +20 -10
  321. package/src/common/browser.ts +13 -6
  322. package/src/common/clients/index.ts +41 -0
  323. package/src/common/clients/lerna.ts +85 -1
  324. package/src/common/clients/npm.ts +56 -14
  325. package/src/common/clients/pnp.ts +84 -0
  326. package/src/common/clients/pnpm.ts +45 -1
  327. package/src/common/clients/rush.ts +118 -0
  328. package/src/common/clients/yarn.ts +49 -3
  329. package/src/common/compatibility.ts +8 -1
  330. package/src/common/config.ts +57 -22
  331. package/src/common/constants.ts +21 -3
  332. package/src/common/declaration.ts +124 -50
  333. package/src/common/emoji.ts +9 -0
  334. package/src/common/emulator.ts +43 -23
  335. package/src/common/enums.ts +0 -5
  336. package/src/common/envs.ts +15 -3
  337. package/src/common/hash.ts +5 -0
  338. package/src/common/http.test.ts +76 -64
  339. package/src/common/http.ts +88 -24
  340. package/src/common/importmap.ts +242 -0
  341. package/src/common/index.ts +10 -0
  342. package/src/common/info.ts +9 -1
  343. package/src/common/injectors.ts +49 -22
  344. package/src/common/inspect.ts +13 -14
  345. package/src/common/interactive.test.ts +6 -0
  346. package/src/common/interactive.ts +69 -1
  347. package/src/common/io.ts +199 -82
  348. package/src/common/language.ts +87 -10
  349. package/src/common/log.ts +32 -46
  350. package/src/common/npm.test.ts +187 -166
  351. package/src/common/npm.ts +263 -119
  352. package/src/common/pack.test.ts +11 -13
  353. package/src/common/pack.ts +60 -21
  354. package/src/common/package.test.ts +59 -49
  355. package/src/common/package.ts +406 -167
  356. package/src/common/parallel.test.ts +28 -0
  357. package/src/common/parallel.ts +21 -0
  358. package/src/common/platform.ts +31 -0
  359. package/src/common/port.test.ts +4 -1
  360. package/src/common/port.ts +10 -0
  361. package/src/common/rules.test.ts +3 -3
  362. package/src/common/scaffold.ts +69 -41
  363. package/src/common/scripts.ts +5 -4
  364. package/src/common/shell.ts +34 -0
  365. package/src/common/spec.ts +69 -0
  366. package/src/common/template.ts +20 -18
  367. package/src/common/url.test.ts +28 -0
  368. package/src/common/url.ts +15 -0
  369. package/src/common/utils.ts +3 -0
  370. package/src/common/version.test.ts +233 -0
  371. package/src/common/version.ts +142 -0
  372. package/src/common/watcher.ts +89 -0
  373. package/src/external/index.test.ts +2 -2
  374. package/src/external/index.ts +7 -3
  375. package/src/external/resolve.ts +29 -0
  376. package/src/helpers.test.ts +2 -22
  377. package/src/helpers.ts +21 -30
  378. package/src/injectors/{pilet.test.ts → pilet-injector.test.ts} +13 -4
  379. package/src/injectors/pilet-injector.ts +346 -0
  380. package/src/injectors/{piral.test.ts → piral-injector.test.ts} +14 -5
  381. package/src/injectors/piral-injector.ts +130 -0
  382. package/src/messages.ts +649 -63
  383. package/src/platforms/node.ts +16 -0
  384. package/src/platforms/web.ts +148 -0
  385. package/src/plugin.ts +34 -5
  386. package/src/questionnaire.ts +17 -3
  387. package/src/release.ts +47 -5
  388. package/src/rules/index.ts +1 -1
  389. package/src/rules/pilet-has-externals-as-peers.test.ts +3 -2
  390. package/src/rules/pilet-has-externals-as-peers.ts +9 -7
  391. package/src/rules/pilet-has-no-self-reference.ts +1 -1
  392. package/src/rules/pilet-stays-small.ts +1 -1
  393. package/src/rules/pilet-uses-latest-piral.ts +22 -12
  394. package/src/rules/piral-has-valid-externals.ts +10 -29
  395. package/src/types/common.ts +99 -9
  396. package/src/types/internal.ts +14 -14
  397. package/src/types/public.ts +93 -27
  398. package/lib/external/child.js +0 -144
  399. package/lib/external/classes.trie +0 -0
  400. package/lib/external/xdg-open +0 -1066
  401. package/lib/injectors/pilet.d.ts +0 -47
  402. package/lib/injectors/pilet.js +0 -187
  403. package/lib/injectors/pilet.js.map +0 -1
  404. package/lib/injectors/piral.js +0 -62
  405. package/lib/injectors/piral.js.map +0 -1
  406. package/src/injectors/pilet.ts +0 -219
  407. package/src/injectors/piral.ts +0 -76
  408. package/templates/piral-index.js.ejs +0 -16
@@ -9,7 +9,7 @@ export interface BuildPiralOptions {
9
9
  */
10
10
  target?: string;
11
11
  /**
12
- * Sets the public URL (path) of the bundle.
12
+ * Sets the public URL (path) of the bundle. Only for release output.
13
13
  */
14
14
  publicUrl?: string;
15
15
  /**
@@ -36,6 +36,10 @@ export interface BuildPiralOptions {
36
36
  * Create associated source maps for the bundles.
37
37
  */
38
38
  sourceMaps?: boolean;
39
+ /**
40
+ * States if the build should run continuously and re-build when files change.
41
+ */
42
+ watch?: boolean;
39
43
  /**
40
44
  * Sets the bundler to use for building, if any specific.
41
45
  */
@@ -52,6 +56,19 @@ export interface BuildPiralOptions {
52
56
  * Additional arguments for a specific bundler.
53
57
  */
54
58
  _?: Record<string, any>;
59
+ /**
60
+ * Hooks to be triggered at various stages.
61
+ */
62
+ hooks?: {
63
+ onBegin?(e: any): Promise<void>;
64
+ beforeBuild?(e: any): Promise<void>;
65
+ afterBuild?(e: any): Promise<void>;
66
+ beforeEmulator?(e: any): Promise<void>;
67
+ afterEmulator?(e: any): Promise<void>;
68
+ beforePackage?(e: any): Promise<void>;
69
+ afterPackage?(e: any): Promise<void>;
70
+ onEnd?(e: any): Promise<void>;
71
+ };
55
72
  }
56
73
  export declare const buildPiralDefaults: BuildPiralOptions;
57
74
  export declare function buildPiral(baseDir?: string, options?: BuildPiralOptions): Promise<void>;
@@ -17,21 +17,6 @@ const common_1 = require("../common");
17
17
  const releaseName = 'release';
18
18
  const emulatorName = 'emulator';
19
19
  const emulatorSourcesName = 'emulator-sources';
20
- function getDestination(entryFiles, target) {
21
- const isdir = path_1.extname(target) !== '.html';
22
- if (isdir) {
23
- return {
24
- outDir: target,
25
- outFile: path_1.basename(entryFiles),
26
- };
27
- }
28
- else {
29
- return {
30
- outDir: path_1.dirname(target),
31
- outFile: path_1.basename(target),
32
- };
33
- }
34
- }
35
20
  exports.buildPiralDefaults = {
36
21
  entry: './',
37
22
  target: './dist',
@@ -42,6 +27,7 @@ exports.buildPiralDefaults = {
42
27
  type: 'all',
43
28
  subdir: true,
44
29
  sourceMaps: true,
30
+ watch: false,
45
31
  contentHash: true,
46
32
  optimizeModules: false,
47
33
  };
@@ -49,81 +35,109 @@ function runLifecycle(root, scripts, type) {
49
35
  return __awaiter(this, void 0, void 0, function* () {
50
36
  const script = scripts === null || scripts === void 0 ? void 0 : scripts[type];
51
37
  if (script) {
52
- common_1.log('generalDebug_0003', `Running "${type}" ("${script}") ...`);
53
- yield common_1.runScript(script, root);
54
- common_1.log('generalDebug_0003', `Finished running "${type}".`);
38
+ (0, common_1.log)('generalDebug_0003', `Running "${type}" ("${script}") ...`);
39
+ yield (0, common_1.runScript)(script, root);
40
+ (0, common_1.log)('generalDebug_0003', `Finished running "${type}".`);
55
41
  }
56
42
  else {
57
- common_1.log('generalDebug_0003', `No script for "${type}" found ...`);
43
+ (0, common_1.log)('generalDebug_0003', `No script for "${type}" found ...`);
58
44
  }
59
45
  });
60
46
  }
61
47
  function buildPiral(baseDir = process.cwd(), options = {}) {
48
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
62
49
  return __awaiter(this, void 0, void 0, function* () {
63
- const { entry = exports.buildPiralDefaults.entry, target = exports.buildPiralDefaults.target, publicUrl = exports.buildPiralDefaults.publicUrl, logLevel = exports.buildPiralDefaults.logLevel, minify = exports.buildPiralDefaults.minify, sourceMaps = exports.buildPiralDefaults.sourceMaps, contentHash = exports.buildPiralDefaults.contentHash, subdir = exports.buildPiralDefaults.subdir, fresh = exports.buildPiralDefaults.fresh, type = exports.buildPiralDefaults.type, optimizeModules = exports.buildPiralDefaults.optimizeModules, _ = {}, bundlerName, } = options;
64
- common_1.setLogLevel(logLevel);
65
- common_1.progress('Reading configuration ...');
50
+ const { entry = exports.buildPiralDefaults.entry, target = exports.buildPiralDefaults.target, publicUrl: originalPublicUrl = exports.buildPiralDefaults.publicUrl, logLevel = exports.buildPiralDefaults.logLevel, minify = exports.buildPiralDefaults.minify, sourceMaps = exports.buildPiralDefaults.sourceMaps, watch = exports.buildPiralDefaults.watch, contentHash = exports.buildPiralDefaults.contentHash, subdir = exports.buildPiralDefaults.subdir, fresh = exports.buildPiralDefaults.fresh, type = exports.buildPiralDefaults.type, optimizeModules = exports.buildPiralDefaults.optimizeModules, _ = {}, hooks = {}, bundlerName, } = options;
51
+ const publicUrl = (0, common_1.normalizePublicUrl)(originalPublicUrl);
52
+ const fullBase = (0, path_1.resolve)(process.cwd(), baseDir);
66
53
  const useSubdir = type === 'all' || subdir;
67
- const entryFiles = yield common_1.retrievePiralRoot(baseDir, entry);
68
- const { name, root, ignored, externals, scripts } = yield common_1.retrievePiletsInfo(entryFiles);
69
- const dest = getDestination(entryFiles, path_1.resolve(baseDir, target));
70
- yield common_1.checkCliCompatibility(root);
54
+ (0, common_1.setLogLevel)(logLevel);
55
+ yield ((_a = hooks.onBegin) === null || _a === void 0 ? void 0 : _a.call(hooks, { options, fullBase }));
56
+ (0, common_1.progress)('Reading configuration ...');
57
+ const entryFiles = yield (0, common_1.retrievePiralRoot)(fullBase, entry);
58
+ const { name, root, ignored, externals, scripts } = yield (0, common_1.retrievePiletsInfo)(entryFiles);
59
+ const piralInstances = [name];
60
+ const dest = (0, common_1.getDestination)(entryFiles, (0, path_1.resolve)(fullBase, target));
61
+ yield (0, common_1.checkCliCompatibility)(root);
62
+ (0, common_1.validateSharedDependencies)(externals);
71
63
  if (fresh) {
72
- common_1.progress('Removing output directory ...');
73
- yield common_1.removeDirectory(dest.outDir);
64
+ (0, common_1.progress)('Removing output directory ...');
65
+ yield (0, common_1.removeDirectory)(dest.outDir);
74
66
  }
75
67
  // everything except release -> build emulator
76
68
  if (type !== releaseName) {
77
- const targetDir = useSubdir ? path_1.join(dest.outDir, emulatorName) : dest.outDir;
78
- common_1.progress('Starting emulator build ...');
69
+ const emulatorPublicUrl = '/';
70
+ const targetDir = useSubdir ? (0, path_1.join)(dest.outDir, emulatorName) : dest.outDir;
71
+ (0, common_1.progress)('Starting emulator build ...');
79
72
  // since we create this anyway let's just pretend we want to have it clean!
80
- yield common_1.removeDirectory(targetDir);
81
- common_1.logInfo(`Bundle ${emulatorName} ...`);
82
- const { dir: outDir, name: outFile } = yield bundler_1.callPiralBuild({
73
+ yield (0, common_1.removeDirectory)(targetDir);
74
+ yield ((_b = hooks.beforeBuild) === null || _b === void 0 ? void 0 : _b.call(hooks, { root, publicUrl: emulatorPublicUrl, externals, entryFiles, targetDir, piralInstances }));
75
+ (0, common_1.logInfo)(`Bundle ${emulatorName} ...`);
76
+ const { dir: outDir, name: outFile, hash, } = yield (0, bundler_1.callPiralBuild)({
83
77
  root,
84
- piral: name,
78
+ piralInstances,
85
79
  emulator: true,
80
+ standalone: false,
86
81
  optimizeModules,
87
82
  sourceMaps,
83
+ watch,
88
84
  contentHash,
89
85
  minify: false,
90
- externals,
91
- publicUrl,
92
- outFile: dest.outFile,
93
- outDir: path_1.join(targetDir, 'app'),
86
+ externals: externals.map(m => m.name),
87
+ publicUrl: emulatorPublicUrl,
94
88
  entryFiles,
95
89
  logLevel,
96
90
  ignored,
91
+ outDir: (0, path_1.join)(targetDir, 'app'),
92
+ outFile: dest.outFile,
97
93
  _,
98
94
  }, bundlerName);
95
+ yield ((_c = hooks.afterBuild) === null || _c === void 0 ? void 0 : _c.call(hooks, {
96
+ root,
97
+ publicUrl: emulatorPublicUrl,
98
+ externals,
99
+ entryFiles,
100
+ targetDir,
101
+ piralInstances,
102
+ hash,
103
+ outDir,
104
+ outFile,
105
+ }));
99
106
  yield runLifecycle(root, scripts, 'piral:postbuild');
100
107
  yield runLifecycle(root, scripts, `piral:postbuild-${emulatorName}`);
101
- const rootDir = yield common_1.createEmulatorSources(root, outDir, outFile, logLevel);
108
+ yield ((_d = hooks.beforeEmulator) === null || _d === void 0 ? void 0 : _d.call(hooks, { root, externals, targetDir, outDir }));
109
+ const rootDir = yield (0, common_1.createEmulatorSources)(root, externals, outDir, outFile, logLevel);
110
+ yield ((_e = hooks.afterEmulator) === null || _e === void 0 ? void 0 : _e.call(hooks, { root, externals, targetDir, outDir, rootDir }));
102
111
  if (type !== emulatorSourcesName) {
103
- yield common_1.packageEmulator(rootDir);
104
- common_1.logDone(`Emulator sources available in "${rootDir}".`);
112
+ yield ((_f = hooks.beforePackage) === null || _f === void 0 ? void 0 : _f.call(hooks, { root, externals, targetDir, outDir, rootDir }));
113
+ yield (0, common_1.packageEmulator)(rootDir);
114
+ yield ((_g = hooks.afterPackage) === null || _g === void 0 ? void 0 : _g.call(hooks, { root, externals, targetDir, outDir, rootDir }));
115
+ (0, common_1.logDone)(`Emulator package available in "${rootDir}".`);
105
116
  }
106
117
  else {
107
- common_1.logDone(`Emulator package available in "${rootDir}".`);
118
+ (0, common_1.logDone)(`Emulator sources available in "${rootDir}".`);
108
119
  }
109
- common_1.logReset();
120
+ (0, common_1.logReset)();
110
121
  }
111
122
  // everything except emulator and emulator-soruces -> build release
112
123
  if (type !== emulatorName && type !== emulatorSourcesName) {
113
- const targetDir = useSubdir ? path_1.join(dest.outDir, releaseName) : dest.outDir;
114
- common_1.progress('Starting release build ...');
124
+ const targetDir = useSubdir ? (0, path_1.join)(dest.outDir, releaseName) : dest.outDir;
125
+ (0, common_1.progress)('Starting release build ...');
115
126
  // since we create this anyway let's just pretend we want to have it clean!
116
- yield common_1.removeDirectory(targetDir);
117
- common_1.logInfo(`Bundle ${releaseName} ...`);
118
- const { dir: outDir } = yield bundler_1.callPiralBuild({
127
+ yield (0, common_1.removeDirectory)(targetDir);
128
+ (0, common_1.logInfo)(`Bundle ${releaseName} ...`);
129
+ yield ((_h = hooks.beforeBuild) === null || _h === void 0 ? void 0 : _h.call(hooks, { root, publicUrl, externals, entryFiles, targetDir, piralInstances }));
130
+ const { dir: outDir, name: outFile, hash, } = yield (0, bundler_1.callPiralBuild)({
119
131
  root,
120
- piral: name,
132
+ piralInstances,
121
133
  emulator: false,
134
+ standalone: false,
122
135
  optimizeModules,
123
136
  sourceMaps,
137
+ watch,
124
138
  contentHash,
125
139
  minify,
126
- externals,
140
+ externals: externals.map(m => m.name),
127
141
  publicUrl,
128
142
  outFile: dest.outFile,
129
143
  outDir: targetDir,
@@ -132,11 +146,13 @@ function buildPiral(baseDir = process.cwd(), options = {}) {
132
146
  ignored,
133
147
  _,
134
148
  }, bundlerName);
149
+ yield ((_j = hooks.afterBuild) === null || _j === void 0 ? void 0 : _j.call(hooks, { root, publicUrl, externals, entryFiles, targetDir, piralInstances, outDir, outFile, hash }));
135
150
  yield runLifecycle(root, scripts, 'piral:postbuild');
136
151
  yield runLifecycle(root, scripts, `piral:postbuild-${releaseName}`);
137
- common_1.logDone(`Files for publication available in "${outDir}".`);
138
- common_1.logReset();
152
+ (0, common_1.logDone)(`Files for publication available in "${outDir}".`);
153
+ (0, common_1.logReset)();
139
154
  }
155
+ yield ((_k = hooks.onEnd) === null || _k === void 0 ? void 0 : _k.call(hooks, { root }));
140
156
  });
141
157
  }
142
158
  exports.buildPiral = buildPiral;
@@ -1 +1 @@
1
- {"version":3,"file":"build-piral.js","sourceRoot":"","sources":["../../src/apps/build-piral.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AC;YAEvH,MAAM,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;YACrD,MAAM,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,mBAAmB,WAAW,EAAE,CAAC,CAAC;YAEpE,IAAA,gBAAO,EAAC,uCAAuC,MAAM,IAAI,CAAC,CAAC;YAC3D,IAAA,iBAAQ,GAAE,CAAC;SACZ;QAED,MAAM,CAAA,MAAA,KAAK,CAAC,KAAK,sDAAG,EAAE,IAAI,EAAE,CAAC,CAAA,CAAC;;CAC/B;AAhKD,gCAgKC"}
@@ -8,11 +8,21 @@ export interface DebugPiletOptions {
8
8
  * Sets the paths to the entry modules.
9
9
  */
10
10
  entry?: string | Array<string>;
11
+ /**
12
+ * The target file of bundling.
13
+ * @example './dist/index.js'
14
+ */
15
+ target?: string;
11
16
  /**
12
17
  * Overrides the name of the app shell to use.
13
18
  * By default the app is inferred from the package.json.
14
19
  */
15
20
  app?: string;
21
+ /**
22
+ * Overrides the directory of the app to serve when
23
+ * debugging.
24
+ */
25
+ appInstanceDir?: string;
16
26
  /**
17
27
  * Sets if the (system default) browser should be auto-opened.
18
28
  */
@@ -21,6 +31,15 @@ export interface DebugPiletOptions {
21
31
  * Sets the port to use for the debug server.
22
32
  */
23
33
  port?: number;
34
+ /**
35
+ * Sets the publicUrl to use.
36
+ * By default, the server is assumed to be at root "/".
37
+ */
38
+ publicUrl?: string;
39
+ /**
40
+ * Sets the maximum number of parallel build processes.
41
+ */
42
+ concurrency?: number;
24
43
  /**
25
44
  * Defines if hot module reloading (HMR) should be integrated for faster debugging.
26
45
  */
@@ -29,6 +48,10 @@ export interface DebugPiletOptions {
29
48
  * Sets the bundler to use for building, if any specific.
30
49
  */
31
50
  bundlerName?: string;
51
+ /**
52
+ * Sets the relative path to the krasrc, if any.
53
+ */
54
+ krasrc?: string;
32
55
  /**
33
56
  * States if the node modules should be included for target transpilation
34
57
  */
@@ -39,13 +62,26 @@ export interface DebugPiletOptions {
39
62
  */
40
63
  schemaVersion?: PiletSchemaVersion;
41
64
  /**
42
- * The URL of a pilet feed used to include locally missing pilets.
65
+ * The URL of a pilet feed(s) used to include locally missing pilets.
43
66
  */
44
- feed?: string;
67
+ feed?: string | Array<string>;
45
68
  /**
46
69
  * Additional arguments for a specific bundler.
47
70
  */
48
71
  _?: Record<string, any>;
72
+ /**
73
+ * Hooks to be triggered at various stages.
74
+ */
75
+ hooks?: {
76
+ onBegin?(e: any): Promise<void>;
77
+ beforeBuild?(e: any): Promise<void>;
78
+ afterBuild?(e: any): Promise<void>;
79
+ beforeApp?(e: any): Promise<void>;
80
+ afterApp?(e: any): Promise<void>;
81
+ beforeOnline?(e: any): Promise<void>;
82
+ afterOnline?(e: any): Promise<void>;
83
+ onEnd?(e: any): Promise<void>;
84
+ };
49
85
  }
50
86
  export declare const debugPiletDefaults: DebugPiletOptions;
51
87
  export declare function debugPilet(baseDir?: string, options?: DebugPiletOptions): Promise<void>;
@@ -11,146 +11,188 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.debugPilet = exports.debugPiletDefaults = void 0;
13
13
  const path_1 = require("path");
14
- const kras_1 = require("kras");
15
14
  const bundler_1 = require("../bundler");
16
15
  const types_1 = require("../types");
17
16
  const common_1 = require("../common");
18
17
  exports.debugPiletDefaults = {
19
18
  logLevel: types_1.LogLevels.info,
19
+ target: './dist/index.js',
20
20
  entry: './src/index',
21
- open: false,
22
- port: 1234,
21
+ open: common_1.config.openBrowser,
22
+ port: common_1.config.port,
23
+ publicUrl: '/',
23
24
  hmr: true,
25
+ krasrc: undefined,
24
26
  optimizeModules: false,
25
- schemaVersion: 'v1',
27
+ schemaVersion: undefined,
28
+ concurrency: common_1.cpuCount,
26
29
  };
27
- const injectorName = path_1.resolve(__dirname, '../injectors/pilet.js');
28
- function getOrMakeAppDir({ emulator, piral, externals, appFile }, logLevel) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
+ function byPort(a, b) {
31
+ return a[1] - b[1];
32
+ }
33
+ function getOrMakeApps({ apps, publicUrl }, logLevel) {
34
+ return Promise.all(apps.map(({ emulator, appFile, appPackage, appPort }) => __awaiter(this, void 0, void 0, function* () {
30
35
  if (!emulator) {
31
- const packageJson = require.resolve(`${piral}/package.json`);
32
- const cwd = path_1.resolve(packageJson, '..');
33
- const { dir } = yield bundler_1.callDebugPiralFromMonoRepo({
34
- root: cwd,
36
+ const piralInstances = [appPackage.name];
37
+ const { externals, root, ignored } = yield (0, common_1.retrievePiletsInfo)(appFile);
38
+ const { dir } = yield (0, bundler_1.callDebugPiralFromMonoRepo)({
39
+ root,
35
40
  optimizeModules: false,
36
- ignored: [],
37
- externals,
38
- piral,
41
+ publicUrl,
42
+ ignored,
43
+ externals: (0, common_1.flattenExternals)(externals),
44
+ piralInstances,
39
45
  entryFiles: appFile,
40
46
  logLevel,
41
47
  _: {},
42
48
  });
43
- return dir;
49
+ return [dir, appPort];
44
50
  }
45
- return path_1.dirname(appFile);
46
- });
51
+ return [(0, path_1.dirname)(appFile), appPort];
52
+ })));
47
53
  }
48
54
  function checkSanity(pilets) {
49
55
  for (let i = 1; i < pilets.length; i++) {
50
56
  const previous = pilets[i - 1];
51
57
  const current = pilets[i];
52
- if (previous.piral !== current.piral) {
53
- return common_1.log('piletMultiDebugAppShellDifferent_0301', previous.piral, current.piral);
58
+ const previousInstances = previous.apps;
59
+ const currentInstances = current.apps;
60
+ const previousInstancesNames = previousInstances
61
+ .map((m) => m.appPackage.name)
62
+ .sort()
63
+ .join(', ');
64
+ const currentInstancesNames = currentInstances
65
+ .map((m) => m.appPackage.name)
66
+ .sort()
67
+ .join(', ');
68
+ const previousInstancesVersions = previousInstances.map((m) => m.appPackage.version).join(', ');
69
+ const currentInstancesVersions = currentInstances.map((m) => m.appPackage.version).join(', ');
70
+ if (previousInstancesNames !== currentInstancesNames) {
71
+ return (0, common_1.log)('piletMultiDebugAppShellDifferent_0301', previousInstancesNames, currentInstancesNames);
54
72
  }
55
- else if (previous.appVersion !== current.appVersion) {
56
- return common_1.log('piletMultiDebugAppShellVersions_0302', previous.appVersion, current.appVersion);
73
+ else if (previousInstancesVersions !== currentInstancesVersions) {
74
+ return (0, common_1.log)('piletMultiDebugAppShellVersions_0302', previousInstancesVersions, currentInstancesVersions);
57
75
  }
58
76
  else if (previous.externals.length !== current.externals.length) {
59
- return common_1.log('piletMultiDebugExternalsDifferent_0303', previous.externals, current.externals);
77
+ return (0, common_1.log)('piletMultiDebugExternalsDifferent_0303', previous.externals, current.externals);
60
78
  }
61
79
  else if (previous.externals.some((m) => !current.externals.includes(m))) {
62
- return common_1.log('piletMultiDebugExternalsDifferent_0303', previous.externals, current.externals);
80
+ return (0, common_1.log)('piletMultiDebugExternalsDifferent_0303', previous.externals, current.externals);
63
81
  }
64
82
  }
65
83
  }
66
84
  function debugPilet(baseDir = process.cwd(), options = {}) {
85
+ var _a, _b;
67
86
  return __awaiter(this, void 0, void 0, function* () {
68
- const { entry = exports.debugPiletDefaults.entry, port = exports.debugPiletDefaults.port, open = exports.debugPiletDefaults.open, hmr = exports.debugPiletDefaults.hmr, logLevel = exports.debugPiletDefaults.logLevel, optimizeModules = exports.debugPiletDefaults.optimizeModules, schemaVersion = exports.debugPiletDefaults.schemaVersion, _ = {}, bundlerName, app, feed, } = options;
69
- common_1.setLogLevel(logLevel);
70
- common_1.progress('Reading configuration ...');
71
- const krasConfig = kras_1.readKrasConfig({ port }, kras_1.krasrc);
72
- const api = common_1.config.piletApi;
73
- const entryList = Array.isArray(entry) ? entry : [entry];
74
- const multi = entryList.length > 1 || entryList[0].indexOf('*') !== -1;
75
- common_1.log('generalDebug_0003', `Looking for (${multi ? 'multi' : 'single'}) "${entryList.join('", "')}" in "${baseDir}".`);
76
- const allEntries = multi ? yield common_1.matchAny(baseDir, entryList) : entryList;
77
- common_1.log('generalDebug_0003', `Found the following entries: ${allEntries.join(', ')}`);
78
- if (krasConfig.sources === undefined) {
79
- krasConfig.sources = [];
80
- }
81
- if (allEntries.length === 0) {
82
- common_1.fail('entryFileMissing_0077');
83
- }
84
- const pilets = yield Promise.all(allEntries.map((entry) => __awaiter(this, void 0, void 0, function* () {
85
- const entryFile = path_1.join(baseDir, entry);
86
- const targetDir = path_1.dirname(entryFile);
87
- const entryModule = yield common_1.findEntryModule(entryFile, targetDir);
88
- const { peerDependencies, peerModules, root, appPackage, appFile, ignored, emulator } = yield common_1.retrievePiletData(targetDir, app);
89
- const externals = [...Object.keys(peerDependencies), ...peerModules];
90
- const mocks = path_1.join(targetDir, 'mocks');
91
- const exists = yield common_1.checkExistingDirectory(mocks);
92
- if (exists) {
93
- if (krasConfig.directory === undefined) {
94
- krasConfig.directory = mocks;
95
- }
96
- krasConfig.sources.push(mocks);
87
+ const { entry = exports.debugPiletDefaults.entry, target = exports.debugPiletDefaults.target, open = exports.debugPiletDefaults.open, hmr = exports.debugPiletDefaults.hmr, port: originalPort = exports.debugPiletDefaults.port, publicUrl: originalPublicUrl = exports.debugPiletDefaults.publicUrl, logLevel = exports.debugPiletDefaults.logLevel, concurrency = exports.debugPiletDefaults.concurrency, krasrc: customkrasrc = exports.debugPiletDefaults.krasrc, optimizeModules = exports.debugPiletDefaults.optimizeModules, schemaVersion: originalSchemaVersion = exports.debugPiletDefaults.schemaVersion, _ = {}, hooks = {}, bundlerName, app, appInstanceDir, feed, } = options;
88
+ const publicUrl = (0, common_1.normalizePublicUrl)(originalPublicUrl);
89
+ const fullBase = (0, path_1.resolve)(process.cwd(), baseDir);
90
+ (0, common_1.setLogLevel)(logLevel);
91
+ yield ((_a = hooks.onBegin) === null || _a === void 0 ? void 0 : _a.call(hooks, { options, fullBase }));
92
+ const watcherRef = yield (0, common_1.watcherTask)((watcherContext) => __awaiter(this, void 0, void 0, function* () {
93
+ var _c, _d, _e, _f, _g;
94
+ (0, common_1.progress)('Reading configuration ...');
95
+ const entryList = Array.isArray(entry) ? entry : [entry];
96
+ const multi = entryList.length > 1 || entryList[0].indexOf('*') !== -1;
97
+ (0, common_1.log)('generalDebug_0003', `Looking for (${multi ? 'multi' : 'single'}) "${entryList.join('", "')}" in "${fullBase}".`);
98
+ const allEntries = yield (0, common_1.matchAnyPilet)(fullBase, entryList);
99
+ const maxListeners = Math.max(2 + allEntries.length * 2, 16);
100
+ (0, common_1.log)('generalDebug_0003', `Found the following entries: ${allEntries.join(', ')}`);
101
+ if (allEntries.length === 0) {
102
+ (0, common_1.fail)('entryFileMissing_0077');
97
103
  }
98
- const bundler = yield bundler_1.callPiletDebug({
99
- root,
100
- piral: appPackage.name,
101
- optimizeModules,
102
- hmr,
103
- externals,
104
- targetDir,
105
- entryModule,
106
- logLevel,
107
- version: schemaVersion,
108
- ignored,
109
- _,
110
- }, bundlerName);
111
- return {
112
- emulator,
113
- appFile,
114
- appVersion: appPackage.version,
115
- externals,
116
- piral: appPackage.name,
117
- bundler,
118
- root,
119
- };
120
- })));
121
- // sanity check see #250
122
- checkSanity(pilets);
123
- const appDir = yield getOrMakeAppDir(pilets[0], logLevel);
124
- if (krasConfig.ssl === undefined) {
125
- krasConfig.ssl = undefined;
126
- }
127
- if (krasConfig.map === undefined) {
128
- krasConfig.map = {};
129
- }
130
- if (krasConfig.api === undefined) {
131
- krasConfig.api = '/manage-mock-server';
132
- }
133
- if (krasConfig.injectors === undefined) {
134
- krasConfig.injectors = kras_1.defaultConfig.injectors;
135
- }
136
- const injectorConfig = {
137
- active: true,
138
- pilets,
139
- app: appDir,
140
- handle: ['/', api],
141
- api,
142
- feed,
143
- };
144
- krasConfig.map['/'] = '';
145
- krasConfig.map[api] = '';
146
- krasConfig.injectors = common_1.reorderInjectors(injectorName, injectorConfig, krasConfig.injectors);
147
- common_1.log('generalVerbose_0004', `Using kras with configuration: ${JSON.stringify(krasConfig, undefined, 2)}`);
148
- const krasServer = kras_1.buildKrasWithCli(krasConfig);
149
- krasServer.removeAllListeners('open');
150
- krasServer.on('open', common_1.notifyServerOnline(pilets.map((p) => p.bundler), krasConfig.api));
151
- yield krasServer.start();
152
- common_1.openBrowser(open, port);
153
- yield new Promise((resolve) => krasServer.on('close', resolve));
104
+ (_c = process.stderr) === null || _c === void 0 ? void 0 : _c.setMaxListeners(maxListeners);
105
+ (_d = process.stdout) === null || _d === void 0 ? void 0 : _d.setMaxListeners(maxListeners);
106
+ (_e = process.stdin) === null || _e === void 0 ? void 0 : _e.setMaxListeners(maxListeners);
107
+ const pilets = yield (0, common_1.concurrentWorkers)(allEntries, concurrency, (entryModule) => __awaiter(this, void 0, void 0, function* () {
108
+ var _h;
109
+ const targetDir = (0, path_1.dirname)(entryModule);
110
+ const { peerDependencies, peerModules, root, apps, ignored, importmap, schema } = yield (0, common_1.retrievePiletData)(targetDir, app);
111
+ const schemaVersion = originalSchemaVersion || schema || common_1.config.schemaVersion || common_1.defaultSchemaVersion;
112
+ const piralInstances = apps.map((m) => m.appPackage.name);
113
+ const externals = (0, common_1.combinePiletExternals)(piralInstances, peerDependencies, peerModules, importmap);
114
+ const mocks = (0, path_1.join)(targetDir, 'mocks');
115
+ const dest = (0, path_1.resolve)(root, target);
116
+ const outDir = (0, path_1.dirname)(dest);
117
+ const outFile = (0, path_1.basename)(dest);
118
+ const mocksExists = yield (0, common_1.checkExistingDirectory)(mocks);
119
+ (0, common_1.validateSharedDependencies)(importmap);
120
+ yield ((_h = hooks.beforeBuild) === null || _h === void 0 ? void 0 : _h.call(hooks, { root, publicUrl, importmap, entryModule, schemaVersion }));
121
+ watcherContext.watch((0, path_1.join)(root, common_1.packageJson));
122
+ watcherContext.watch((0, path_1.join)(root, common_1.piletJson));
123
+ const bundler = yield (0, bundler_1.callPiletDebug)({
124
+ root,
125
+ piralInstances,
126
+ optimizeModules,
127
+ hmr,
128
+ externals,
129
+ targetDir,
130
+ importmap,
131
+ outFile,
132
+ outDir,
133
+ entryModule: `./${(0, path_1.relative)(root, entryModule)}`,
134
+ logLevel,
135
+ version: schemaVersion,
136
+ ignored,
137
+ _,
138
+ }, bundlerName);
139
+ bundler.on((args) => {
140
+ var _a;
141
+ (_a = hooks.afterBuild) === null || _a === void 0 ? void 0 : _a.call(hooks, Object.assign(Object.assign({}, args), { root,
142
+ publicUrl,
143
+ importmap,
144
+ entryModule,
145
+ schemaVersion,
146
+ bundler,
147
+ outFile,
148
+ outDir }));
149
+ });
150
+ return {
151
+ apps,
152
+ publicUrl,
153
+ externals,
154
+ bundler,
155
+ mocks: mocksExists ? mocks : undefined,
156
+ root,
157
+ };
158
+ }));
159
+ // sanity check see #250
160
+ checkSanity(pilets);
161
+ yield ((_f = hooks.beforeApp) === null || _f === void 0 ? void 0 : _f.call(hooks, { appInstanceDir, pilets }));
162
+ const appInstances = appInstanceDir
163
+ ? [[appInstanceDir, 0]]
164
+ : yield getOrMakeApps(pilets[0], logLevel);
165
+ Promise.all(pilets.map((p) => p.bundler.ready())).then(() => (0, common_1.logDone)(`Ready!`));
166
+ pilets.forEach((p) => p.bundler.start());
167
+ if (appInstances.length === 0) {
168
+ appInstances.push([undefined, originalPort]);
169
+ }
170
+ yield Promise.all(appInstances.sort(byPort).map(([appDir, appPort], i) => __awaiter(this, void 0, void 0, function* () {
171
+ const platform = (0, common_1.configurePlatform)();
172
+ const suggestedPort = appPort || originalPort + i;
173
+ yield platform.startModule({
174
+ appDir,
175
+ pilets,
176
+ customkrasrc,
177
+ feed,
178
+ fullBase,
179
+ hooks,
180
+ open,
181
+ originalPort: suggestedPort,
182
+ publicUrl,
183
+ maxListeners,
184
+ registerEnd(cb) {
185
+ return watcherContext.onClean(cb);
186
+ },
187
+ registerWatcher(file) {
188
+ return watcherContext.watch(file);
189
+ },
190
+ });
191
+ })));
192
+ yield ((_g = hooks.afterApp) === null || _g === void 0 ? void 0 : _g.call(hooks, { appInstanceDir, pilets }));
193
+ }));
194
+ yield Promise.all([watcherRef.end]);
195
+ yield ((_b = hooks.onEnd) === null || _b === void 0 ? void 0 : _b.call(hooks, {}));
154
196
  });
155
197
  }
156
198
  exports.debugPilet = debugPilet;