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
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.readImportmap = void 0;
13
+ const path_1 = require("path");
14
+ const log_1 = require("./log");
15
+ const version_1 = require("./version");
16
+ const hash_1 = require("./hash");
17
+ const io_1 = require("./io");
18
+ const npm_1 = require("./npm");
19
+ const shorthandsUrls = ['', '.', '...'];
20
+ function addLocalDependencies(dependencies, realIdentifier, identifier, version, requireVersion, entry, assetName) {
21
+ const alias = realIdentifier !== identifier ? realIdentifier : undefined;
22
+ dependencies.push({
23
+ id: `${identifier}@${version}`,
24
+ requireId: `${identifier}@${requireVersion}`,
25
+ entry,
26
+ name: identifier,
27
+ ref: `${assetName}.js`,
28
+ type: 'local',
29
+ alias,
30
+ });
31
+ }
32
+ function getDependencyDetails(depName) {
33
+ const sep = depName.indexOf('@', 1);
34
+ const version = sep > 0 ? depName.substring(sep + 1) : '';
35
+ const id = sep > 0 ? depName.substring(0, sep) : depName;
36
+ const assetName = (id.startsWith('@') ? id.substring(1) : id).replace(/[\/\.]/g, '-').replace(/(\-)+/, '-');
37
+ return [assetName, id, version];
38
+ }
39
+ function getLocalDependencyVersion(packageJson, depName, versionSpec) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const packageDir = (0, path_1.dirname)(packageJson);
42
+ const packageFile = (0, path_1.basename)(packageJson);
43
+ const details = yield (0, io_1.readJson)(packageDir, packageFile);
44
+ if (versionSpec) {
45
+ if (!(0, version_1.validate)(versionSpec)) {
46
+ (0, log_1.fail)('importMapVersionSpecInvalid_0026', depName);
47
+ }
48
+ if (!(0, version_1.satisfies)(details.version, versionSpec)) {
49
+ (0, log_1.fail)('importMapVersionSpecNotSatisfied_0025', depName, details.version);
50
+ }
51
+ return [details.name, details.version, versionSpec];
52
+ }
53
+ return [details.name, details.version, details.version];
54
+ });
55
+ }
56
+ function getInheritedDependencies(inheritedImport, dir) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const packageJson = (0, npm_1.tryResolvePackage)(`${inheritedImport}/package.json`, dir);
59
+ if (packageJson) {
60
+ const packageDir = (0, path_1.dirname)(packageJson);
61
+ const packageDetails = yield (0, io_1.readJson)(packageDir, 'package.json');
62
+ return readImportmap(packageDir, packageDetails, true);
63
+ }
64
+ else {
65
+ const directImportmap = (0, npm_1.tryResolvePackage)(inheritedImport, dir);
66
+ if (directImportmap) {
67
+ const baseDir = (0, path_1.dirname)(directImportmap);
68
+ const content = yield (0, io_1.readJson)(baseDir, (0, path_1.basename)(directImportmap));
69
+ return yield resolveImportmap(baseDir, content);
70
+ }
71
+ }
72
+ return [];
73
+ });
74
+ }
75
+ function resolveImportmap(dir, importmap) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const dependencies = [];
78
+ const sharedImports = importmap === null || importmap === void 0 ? void 0 : importmap.imports;
79
+ const inheritedImports = importmap === null || importmap === void 0 ? void 0 : importmap.inherit;
80
+ if (typeof sharedImports === 'object' && sharedImports) {
81
+ for (const depName of Object.keys(sharedImports)) {
82
+ const url = sharedImports[depName];
83
+ const [assetName, identifier, versionSpec] = getDependencyDetails(depName);
84
+ if (typeof url !== 'string') {
85
+ (0, log_1.log)('generalInfo_0000', `The value of "${depName}" in the importmap is not a string and will be ignored.`);
86
+ }
87
+ else if (/^https?:\/\//.test(url)) {
88
+ const hash = (0, hash_1.computeHash)(url).substring(0, 7);
89
+ dependencies.push({
90
+ id: `${identifier}@${hash}`,
91
+ requireId: `${identifier}@${hash}`,
92
+ entry: url,
93
+ name: identifier,
94
+ ref: url,
95
+ type: 'remote',
96
+ });
97
+ }
98
+ else if (url === identifier || shorthandsUrls.includes(url)) {
99
+ const entry = (0, npm_1.tryResolvePackage)(identifier, dir);
100
+ if (entry) {
101
+ const packageJson = yield (0, io_1.findFile)((0, path_1.dirname)(entry), 'package.json');
102
+ const [realIdentifier, version, requireVersion] = yield getLocalDependencyVersion(packageJson, depName, versionSpec);
103
+ addLocalDependencies(dependencies, realIdentifier, identifier, version, requireVersion, entry, assetName);
104
+ }
105
+ else {
106
+ (0, log_1.fail)('importMapReferenceNotFound_0027', dir, identifier);
107
+ }
108
+ }
109
+ else if (!url.startsWith('.') && !(0, path_1.isAbsolute)(url)) {
110
+ const entry = (0, npm_1.tryResolvePackage)(url, dir);
111
+ if (entry) {
112
+ const packageJson = yield (0, io_1.findFile)((0, path_1.dirname)(entry), 'package.json');
113
+ const [realIdentifier, version, requireVersion] = yield getLocalDependencyVersion(packageJson, depName, versionSpec);
114
+ addLocalDependencies(dependencies, realIdentifier, identifier, version, requireVersion, entry, assetName);
115
+ }
116
+ else {
117
+ (0, log_1.fail)('importMapReferenceNotFound_0027', dir, url);
118
+ }
119
+ }
120
+ else {
121
+ const entry = (0, path_1.resolve)(dir, url);
122
+ const exists = yield (0, io_1.checkExists)(entry);
123
+ if (exists) {
124
+ const isDirectory = yield (0, io_1.checkIsDirectory)(entry);
125
+ const packageJson = isDirectory
126
+ ? (0, path_1.resolve)(entry, 'package.json')
127
+ : yield (0, io_1.findFile)((0, path_1.dirname)(entry), 'package.json');
128
+ const packageJsonExists = yield (0, io_1.checkExists)(packageJson);
129
+ if (packageJsonExists) {
130
+ const [realIdentifier, version, requireVersion] = yield getLocalDependencyVersion(packageJson, depName, versionSpec);
131
+ addLocalDependencies(dependencies, realIdentifier, identifier, version, requireVersion, isDirectory ? (0, npm_1.tryResolvePackage)(entry, dir) : entry, assetName);
132
+ }
133
+ else if (isDirectory) {
134
+ (0, log_1.fail)('importMapReferenceNotFound_0027', entry, 'package.json');
135
+ }
136
+ else {
137
+ const hash = yield (0, io_1.getHash)(entry);
138
+ dependencies.push({
139
+ id: `${identifier}@${hash}`,
140
+ requireId: `${identifier}@${hash}`,
141
+ entry,
142
+ name: identifier,
143
+ ref: `${assetName}.js`,
144
+ type: 'local',
145
+ });
146
+ }
147
+ }
148
+ else {
149
+ (0, log_1.fail)('importMapReferenceNotFound_0027', dir, url);
150
+ }
151
+ }
152
+ }
153
+ }
154
+ if (Array.isArray(inheritedImports)) {
155
+ for (const inheritedImport of inheritedImports) {
156
+ const otherDependencies = yield getInheritedDependencies(inheritedImport, dir);
157
+ for (const dependency of otherDependencies) {
158
+ const entry = dependencies.find((dep) => dep.name === dependency.name);
159
+ if (!entry) {
160
+ dependencies.push(Object.assign(Object.assign({}, dependency), { parents: [inheritedImport] }));
161
+ }
162
+ else if (Array.isArray(entry.parents)) {
163
+ entry.parents.push(inheritedImport);
164
+ }
165
+ }
166
+ }
167
+ }
168
+ return dependencies;
169
+ });
170
+ }
171
+ function readImportmap(dir, packageDetails, inherited = false) {
172
+ var _a, _b;
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ const importmap = packageDetails.importmap;
175
+ if (typeof importmap === 'string') {
176
+ const notFound = {};
177
+ const content = yield (0, io_1.readJson)(dir, importmap, notFound);
178
+ if (content === notFound) {
179
+ (0, log_1.fail)('importMapFileNotFound_0028', dir, importmap);
180
+ }
181
+ const baseDir = (0, path_1.dirname)((0, path_1.resolve)(dir, importmap));
182
+ return yield resolveImportmap(baseDir, content);
183
+ }
184
+ else if (typeof importmap === 'undefined' && inherited) {
185
+ // Fall back to sharedDependencies or pilets.external if available
186
+ const shared = (_a = packageDetails.sharedDependencies) !== null && _a !== void 0 ? _a : (_b = packageDetails.pilets) === null || _b === void 0 ? void 0 : _b.externals;
187
+ if (Array.isArray(shared)) {
188
+ return shared.map((dep) => ({
189
+ id: dep,
190
+ name: dep,
191
+ entry: dep,
192
+ type: 'local',
193
+ ref: undefined,
194
+ requireId: dep,
195
+ }));
196
+ }
197
+ }
198
+ return yield resolveImportmap(dir, importmap);
199
+ });
200
+ }
201
+ exports.readImportmap = readImportmap;
202
+ //# sourceMappingURL=importmap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importmap.js","sourceRoot":"","sources":["../../src/common/importmap.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA8D;AAC9D,+BAAkC;AAClC,uCAAgD;AAChD,iCAAqC;AACrC,6BAAkF;AAClF,+BAA0C;AAG1C,MAAM,cAAc,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAExC,SAAS,oBAAoB,CAC3B,YAAqC,EACrC,cAAsB,EACtB,UAAkB,EAClB,OAAe,EACf,cAAsB,EACtB,KAAa,EACb,SAAiB;IAEjB,MAAM,KAAK,GAAG,cAAc,KAAK,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,C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CAAC;YACjD,OAAO,MAAM,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;SACjD;aAAM,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,EAAE;YACxD,kEAAkE;YAClE,MAAM,MAAM,GAAkB,MAAA,cAAc,CAAC,kBAAkB,mCAAI,MAAA,cAAc,CAAC,MAAM,0CAAE,SAAS,CAAC;YAEpG,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACzB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBAC1B,EAAE,EAAE,GAAG;oBACP,IAAI,EAAE,GAAG;oBACT,KAAK,EAAE,GAAG;oBACV,IAAI,EAAE,OAAO;oBACb,GAAG,EAAE,SAAS;oBACd,SAAS,EAAE,GAAG;iBACf,CAAC,CAAC,CAAC;aACL;SACF;QAED,OAAO,MAAM,gBAAgB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;;CAC/C;AAlCD,sCAkCC"}
@@ -10,8 +10,11 @@ export * from './emoji';
10
10
  export * from './envs';
11
11
  export * from './hash';
12
12
  export * from './http';
13
+ export * from './importmap';
13
14
  export * from './info';
14
15
  export * from './injectors';
16
+ export * from './inspect';
17
+ export * from './interactive';
15
18
  export * from './io';
16
19
  export * from './language';
17
20
  export * from './log';
@@ -19,10 +22,17 @@ export * from './merge';
19
22
  export * from './npm';
20
23
  export * from './pack';
21
24
  export * from './package';
25
+ export * from './parallel';
22
26
  export * from './patcher';
23
27
  export * from './patches';
28
+ export * from './platform';
24
29
  export * from './port';
25
30
  export * from './rules';
26
31
  export * from './scaffold';
27
32
  export * from './scripts';
33
+ export * from './shell';
34
+ export * from './spec';
28
35
  export * from './template';
36
+ export * from './url';
37
+ export * from './version';
38
+ export * from './watcher';
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -22,8 +26,11 @@ __exportStar(require("./emoji"), exports);
22
26
  __exportStar(require("./envs"), exports);
23
27
  __exportStar(require("./hash"), exports);
24
28
  __exportStar(require("./http"), exports);
29
+ __exportStar(require("./importmap"), exports);
25
30
  __exportStar(require("./info"), exports);
26
31
  __exportStar(require("./injectors"), exports);
32
+ __exportStar(require("./inspect"), exports);
33
+ __exportStar(require("./interactive"), exports);
27
34
  __exportStar(require("./io"), exports);
28
35
  __exportStar(require("./language"), exports);
29
36
  __exportStar(require("./log"), exports);
@@ -31,11 +38,18 @@ __exportStar(require("./merge"), exports);
31
38
  __exportStar(require("./npm"), exports);
32
39
  __exportStar(require("./pack"), exports);
33
40
  __exportStar(require("./package"), exports);
41
+ __exportStar(require("./parallel"), exports);
34
42
  __exportStar(require("./patcher"), exports);
35
43
  __exportStar(require("./patches"), exports);
44
+ __exportStar(require("./platform"), exports);
36
45
  __exportStar(require("./port"), exports);
37
46
  __exportStar(require("./rules"), exports);
38
47
  __exportStar(require("./scaffold"), exports);
39
48
  __exportStar(require("./scripts"), exports);
49
+ __exportStar(require("./shell"), exports);
50
+ __exportStar(require("./spec"), exports);
40
51
  __exportStar(require("./template"), exports);
52
+ __exportStar(require("./url"), exports);
53
+ __exportStar(require("./version"), exports);
54
+ __exportStar(require("./watcher"), exports);
41
55
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B;AAC1B,kDAAgC;AAChC,2CAAyB;AACzB,8CAA4B;AAC5B,gDAA8B;AAC9B,6CAA2B;AAC3B,0CAAwB;AACxB,0CAAwB;AACxB,yCAAuB;AACvB,yCAAuB;AACvB,yCAAuB;AACvB,yCAAuB;AACvB,8CAA4B;AAC5B,uCAAqB;AACrB,6CAA2B;AAC3B,wCAAsB;AACtB,0CAAwB;AACxB,wCAAsB;AACtB,yCAAuB;AACvB,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB;AACvB,0CAAwB;AACxB,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B;AAC1B,kDAAgC;AAChC,2CAAyB;AACzB,8CAA4B;AAC5B,gDAA8B;AAC9B,6CAA2B;AAC3B,0CAAwB;AACxB,0CAAwB;AACxB,yCAAuB;AACvB,yCAAuB;AACvB,yCAAuB;AACvB,8CAA4B;AAC5B,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,gDAA8B;AAC9B,uCAAqB;AACrB,6CAA2B;AAC3B,wCAAsB;AACtB,0CAAwB;AACxB,wCAAsB;AACtB,yCAAuB;AACvB,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,4CAA0B;AAC1B,6CAA2B;AAC3B,yCAAuB;AACvB,0CAAwB;AACxB,6CAA2B;AAC3B,4CAA0B;AAC1B,0CAAwB;AACxB,yCAAuB;AACvB,6CAA2B;AAC3B,wCAAsB;AACtB,4CAA0B;AAC1B,4CAA0B"}
@@ -1,7 +1,12 @@
1
1
  export declare function findCompatVersion(version: string): string;
2
2
  export declare const nodeVersion: string;
3
+ export declare const cliName: any;
3
4
  export declare const cliVersion: any;
4
5
  export declare const compatVersion: string;
5
6
  export declare const repositoryUrl: any;
6
7
  export declare const isWindows: boolean;
7
8
  export declare const pathSeparator: string;
9
+ export declare const cpuCount: number;
10
+ export declare const standardHeaders: {
11
+ 'user-agent': string;
12
+ };
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pathSeparator = exports.isWindows = exports.repositoryUrl = exports.compatVersion = exports.cliVersion = exports.nodeVersion = exports.findCompatVersion = void 0;
3
+ exports.standardHeaders = exports.cpuCount = exports.pathSeparator = exports.isWindows = exports.repositoryUrl = exports.compatVersion = exports.cliVersion = exports.cliName = exports.nodeVersion = exports.findCompatVersion = void 0;
4
+ const os_1 = require("os");
4
5
  const info = require('../../package.json');
6
+ const os = (0, os_1.platform)();
5
7
  function findCompatVersion(version) {
6
8
  // we only care about major and minor
7
9
  const [major, minor] = version.split('.');
@@ -12,10 +14,15 @@ function findCompatVersion(version) {
12
14
  return major;
13
15
  }
14
16
  exports.findCompatVersion = findCompatVersion;
15
- exports.nodeVersion = process.version.substr(1);
17
+ exports.nodeVersion = process.version.substring(1);
18
+ exports.cliName = info.name;
16
19
  exports.cliVersion = info.version;
17
20
  exports.compatVersion = findCompatVersion(exports.cliVersion);
18
21
  exports.repositoryUrl = info.repository.url;
19
22
  exports.isWindows = process.platform === 'win32';
20
23
  exports.pathSeparator = exports.isWindows ? ';' : ':';
24
+ exports.cpuCount = (0, os_1.cpus)().length;
25
+ exports.standardHeaders = {
26
+ 'user-agent': `piral-cli/http.node-${os}`,
27
+ };
21
28
  //# sourceMappingURL=info.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/common/info.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAE3C,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,qCAAqC;IACrC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE1C,IAAI,KA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C,kBAAU,CAAC,CAAC;AAC9C,QAAA,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;AACpC,QAAA,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AACzC,QAAA,aAAa,GAAG,iBAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACtC,QAAA,QAAQ,GAAG,IAAA,SAAI,GAAE,CAAC,MAAM,CAAC;AACzB,QAAA,eAAe,GAAG;IAC7B,YAAY,EAAE,uBAAuB,EAAE,EAAE;CAC1C,CAAC"}
@@ -1,9 +1,37 @@
1
- import { KrasConfigurationInjectors } from 'kras';
2
- import { Bundler } from '../types';
3
- export declare function reorderInjectors(injectorName: string, injectorConfig: any, injectors: KrasConfigurationInjectors): {
4
- [x: string]: any;
5
- script: import("kras").KrasInjectorConfig;
6
- har: import("kras").KrasInjectorConfig;
7
- json: import("kras").KrasInjectorConfig;
1
+ export declare function notifyServerOnline(path: string, api: string | false): (svc: any) => void;
2
+ export declare function createInitialKrasConfig(directory: string, sources?: Array<string>, map?: Record<string, string>, feed?: string | Array<string>): {
3
+ api: string;
4
+ directory: string;
5
+ map: {
6
+ '/': string;
7
+ };
8
+ ssl: any;
9
+ sources: string[];
10
+ injectorDirs: string[];
11
+ injectors: {
12
+ script: {
13
+ active: boolean;
14
+ };
15
+ har: {
16
+ active: boolean;
17
+ delay: boolean;
18
+ };
19
+ json: {
20
+ active: boolean;
21
+ randomize: boolean;
22
+ };
23
+ piral: {
24
+ active: boolean;
25
+ headers: {};
26
+ };
27
+ pilet: {
28
+ active: boolean;
29
+ meta: string;
30
+ headers: {};
31
+ feed: string | string[];
32
+ };
33
+ proxy: {
34
+ active: boolean;
35
+ };
36
+ };
8
37
  };
9
- export declare function notifyServerOnline(bundlers: Array<Bundler>, api: string | false): (svc: any) => void;
@@ -1,28 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.notifyServerOnline = exports.reorderInjectors = void 0;
4
- const chalk_1 = require("chalk");
3
+ exports.createInitialKrasConfig = exports.notifyServerOnline = void 0;
4
+ const path_1 = require("path");
5
5
  const emoji_1 = require("./emoji");
6
6
  const log_1 = require("./log");
7
- function reorderInjectors(injectorName, injectorConfig, injectors) {
8
- return Object.assign({ script: injectors.script || {
9
- active: true,
10
- }, har: injectors.har || {
11
- active: true,
12
- }, json: injectors.json || {
13
- active: true,
14
- }, [injectorName]: injectorConfig }, injectors);
15
- }
16
- exports.reorderInjectors = reorderInjectors;
17
- function notifyServerOnline(bundlers, api) {
7
+ const external_1 = require("../external");
8
+ function notifyServerOnline(path, api) {
18
9
  return (svc) => {
19
- log_1.log('generalDebug_0003', `The kras server for debugging is online!`);
20
- const address = `${svc.protocol}://localhost:${chalk_1.default.green(svc.port)}`;
21
- log_1.logInfo(`${emoji_1.liveIcon} Running at ${chalk_1.default.bold(address)}`);
22
- log_1.logInfo(`${emoji_1.settingsIcon} Manage via ${chalk_1.default.bold(address + api)}`);
23
- log_1.logReset();
24
- bundlers.forEach((bundler) => bundler.start());
10
+ (0, log_1.log)('generalDebug_0003', `The kras server for debugging is online!`);
11
+ const address = `${svc.protocol}://localhost:${external_1.chalk.green(svc.port)}`;
12
+ (0, log_1.logInfo)(`${emoji_1.liveIcon} Running at ${external_1.chalk.bold(address + path)}`);
13
+ (0, log_1.logInfo)(`${emoji_1.settingsIcon} Manage via ${external_1.chalk.bold(address + api)}`);
14
+ (0, log_1.logReset)();
25
15
  };
26
16
  }
27
17
  exports.notifyServerOnline = notifyServerOnline;
18
+ function createInitialKrasConfig(directory, sources = [], map = {}, feed = []) {
19
+ return {
20
+ api: '/manage-mock-server',
21
+ directory,
22
+ map: Object.assign({ '/': '' }, map),
23
+ ssl: undefined,
24
+ sources,
25
+ injectorDirs: [(0, path_1.resolve)(__dirname, '../injectors')],
26
+ injectors: {
27
+ script: {
28
+ active: true,
29
+ },
30
+ har: {
31
+ active: true,
32
+ delay: false,
33
+ },
34
+ json: {
35
+ active: true,
36
+ randomize: true,
37
+ },
38
+ piral: {
39
+ active: true,
40
+ headers: {},
41
+ },
42
+ pilet: {
43
+ active: true,
44
+ meta: 'debug-meta.json',
45
+ headers: {},
46
+ feed,
47
+ },
48
+ proxy: {
49
+ active: true,
50
+ },
51
+ },
52
+ };
53
+ }
54
+ exports.createInitialKrasConfig = createInitialKrasConfig;
28
55
  //# sourceMappingURL=injectors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectors.js","sourceRoot":"","sources":["../../src/common/injectors.ts"],"names":[],"mappings":";;;AAAA,iCAA0B;AAE1B,mCAAiD;AACjD,+BAA+C;AAG/C,SAAgB,gBAAgB,CAAC,YAAoB,EAAE,cAAmB,EAAE,SAAqC;IAC/G,uBACE,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI;YAC1B,MAAM,EAAE,IAAI;SACb,EACD,GAAG,EAAE,SAAS,CAAC,GAAG,IAAI;YACpB,MAAM,EAAE,IAAI;SACb,EACD,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI;YACtB,MAAM,EAAE,IAAI;SACb,EACD,CAAC,YAAY,CAAC,EAAE,cAAc,IAC3B,SAAS,EACZ;AACJ,CAAC;AAdD,4CAcC;AAED,SAAgB,kBAAkB,CAAC,QAAwB,EAAE,GAAmB;IAC9E,OAAO,CAAC,GAAQ,EAAE,EAAE;QAClB,SAAG,CAAC,mBAAmB,EAAE,0CAA0C,CAAC,CAAC;QACrE,MAAM,OAAO,GAAG,GAAG,GAAG,CAAC,QAAQ,gBAAgB,eAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACvE,aAAO,CAAC,GAAG,gBAAQ,eAAe,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzD,aAAO,CAAC,GAAG,oBAAY,eAAe,eAAK,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC;QACnE,c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ACH,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,KAAK;aACb;YACD,IAAI,EAAE;gBACJ,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,IAAI;aAChB;YACD,KAAK,EAAE;gBACL,MAAM,EAAE,IAAI;gBACZ,OAAO,EAAE,EAAE;aACZ;YACD,KAAK,EAAE;gBACL,MAAM,EAAE,IAAI;gBACZ,IAAI,EAAE,iBAAiB;gBACvB,OAAO,EAAE,EAAE;gBACX,IAAI;aACL;YACD,KAAK,EAAE;gBACL,MAAM,EAAE,IAAI;aACb;SACF;KACF,CAAC;AACJ,CAAC;AA3CD,0DA2CC"}
@@ -1,7 +1,9 @@
1
1
  /// <reference types="node" />
2
- import { PackageData } from '../types';
3
- export interface PiletPackageData extends PackageData {
2
+ import { PiletPackageData, PackageData, PackageFiles } from '../types';
3
+ export declare function getPossiblePiletMainPaths(data: PiletPackageData): string[];
4
+ export declare function getPiletMainPath(data: PiletPackageData, files: PackageFiles): string;
5
+ export interface InspectedPiletPackageData extends PiletPackageData {
4
6
  root: string;
5
7
  }
6
8
  export declare function inspectPackage(stream: NodeJS.ReadableStream): Promise<PackageData>;
7
- export declare function inspectPilet(stream: NodeJS.ReadableStream): Promise<PiletPackageData>;
9
+ export declare function inspectPilet(stream: NodeJS.ReadableStream): Promise<InspectedPiletPackageData>;
@@ -1,36 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inspectPilet = exports.inspectPackage = void 0;
3
+ exports.inspectPilet = exports.inspectPackage = exports.getPiletMainPath = exports.getPossiblePiletMainPaths = void 0;
4
4
  const path_1 = require("path");
5
5
  const archive_1 = require("./archive");
6
+ const external_1 = require("../external");
6
7
  const packageRoot = 'package/';
7
8
  function getPackageJson(files) {
8
9
  const fileName = `${packageRoot}package.json`;
9
10
  const fileContent = files[fileName];
10
11
  const content = fileContent.toString('utf8');
11
- return JSON.parse(content);
12
+ return external_1.jju.parse(content);
12
13
  }
14
+ function getPossiblePiletMainPaths(data) {
15
+ const { main = 'index.js' } = data;
16
+ return [main, `dist/${main}`, `${main}/index.js`, `dist/${main}/index.js`, 'index.js', 'dist/index.js'];
17
+ }
18
+ exports.getPossiblePiletMainPaths = getPossiblePiletMainPaths;
13
19
  function getPiletMainPath(data, files) {
14
- const paths = [
15
- data.main,
16
- `dist/${data.main}`,
17
- `${data.main}/index.js`,
18
- `dist/${data.main}/index.js`,
19
- 'index.js',
20
- 'dist/index.js',
21
- ];
22
- return paths.map((filePath) => `${packageRoot}${filePath}`).filter((filePath) => !!files[filePath])[0];
20
+ const paths = getPossiblePiletMainPaths(data);
21
+ return paths.map((filePath) => `${packageRoot}${filePath}`).find((filePath) => !!files[filePath]);
23
22
  }
23
+ exports.getPiletMainPath = getPiletMainPath;
24
24
  function inspectPackage(stream) {
25
- return archive_1.unpackGzTar(stream).then((files) => getPackageJson(files));
25
+ return (0, archive_1.unpackGzTar)(stream).then((files) => getPackageJson(files));
26
26
  }
27
27
  exports.inspectPackage = inspectPackage;
28
28
  function inspectPilet(stream) {
29
- return archive_1.unpackGzTar(stream).then((files) => {
29
+ return (0, archive_1.unpackGzTar)(stream).then((files) => {
30
30
  const data = getPackageJson(files);
31
31
  const path = getPiletMainPath(data, files);
32
- const root = path_1.dirname(path);
33
- const main = path_1.basename(path);
32
+ const root = (0, path_1.dirname)(path);
33
+ const main = (0, path_1.basename)(path);
34
34
  return Object.assign(Object.assign({}, data), { root,
35
35
  main });
36
36
  });
@@ -1 +1 @@
1
- {"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/common/inspect.ts"],"names":[],"mappings":";;;AAAA,+BAAyC;AACzC,uCAAwC;AAGxC,MAAM,WAAW,GAAG,UAAU,CAAC;AAE/B,SAAS,cAAc,CAAC,KAAmB;IACzC,MAAM,QAAQ,GAAG,GAAG,WAAW,cAAc,CAAC;IAC9C,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,OAAO,GAA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,qBAAW,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC;QAC5B,uCACK,IAAI,KACP,IAAI;YACJ,IAAI,IACJ;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAZD,oCAYC"}
@@ -1,2 +1,11 @@
1
+ /// <reference types="node" />
2
+ import { Agent } from 'https';
3
+ import { PiletPublishScheme } from '../types';
1
4
  export declare function promptSelect(message: string, values: Array<string>, defaultValue: string): Promise<string>;
2
5
  export declare function promptConfirm(message: string, defaultValue: boolean): Promise<boolean>;
6
+ type TokenResult = Promise<{
7
+ mode: PiletPublishScheme;
8
+ token: string;
9
+ }>;
10
+ export declare function getTokenInteractively(url: string, httpsAgent: Agent): TokenResult;
11
+ export {};
@@ -1,6 +1,18 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promptConfirm = exports.promptSelect = void 0;
12
+ exports.getTokenInteractively = exports.promptConfirm = exports.promptSelect = void 0;
13
+ const browser_1 = require("./browser");
14
+ const info_1 = require("./info");
15
+ const log_1 = require("./log");
4
16
  const external_1 = require("../external");
5
17
  function promptSelect(message, values, defaultValue) {
6
18
  const questions = [
@@ -27,4 +39,51 @@ function promptConfirm(message, defaultValue) {
27
39
  return external_1.inquirer.prompt(questions).then((answers) => answers.q);
28
40
  }
29
41
  exports.promptConfirm = promptConfirm;
42
+ const tokenRetrievers = {};
43
+ function getTokenInteractively(url, httpsAgent) {
44
+ if (!(url in tokenRetrievers)) {
45
+ const logResume = (0, log_1.logSuspend)();
46
+ tokenRetrievers[url] = external_1.axios.default
47
+ .post(url, {
48
+ clientId: 'piral-cli',
49
+ clientName: 'Piral CLI',
50
+ description: 'Authorize the Piral CLI temporarily to perform actions in your name.',
51
+ }, {
52
+ headers: Object.assign(Object.assign({}, info_1.standardHeaders), { 'content-type': 'application/json' }),
53
+ httpsAgent,
54
+ })
55
+ .then((res) => __awaiter(this, void 0, void 0, function* () {
56
+ const { loginUrl, callbackUrl, expires } = res.data;
57
+ const now = new Date();
58
+ const then = new Date(expires);
59
+ const diff = ~~((then.valueOf() - now.valueOf()) / (60 * 1000));
60
+ (0, log_1.logInfo)(`Use the URL below to complete the login. The link expires in ${diff} minutes (${then}).`);
61
+ (0, log_1.logInfo)('===');
62
+ (0, log_1.logInfo)(loginUrl);
63
+ (0, log_1.logInfo)('===');
64
+ (0, browser_1.openBrowserAt)(loginUrl);
65
+ try {
66
+ while (true) {
67
+ const { data, status } = yield external_1.axios.default.get(callbackUrl);
68
+ if (status === 202) {
69
+ yield new Promise(resolve => setTimeout(resolve, 5000));
70
+ continue;
71
+ }
72
+ if (status === 200) {
73
+ return Object.assign({}, data);
74
+ }
75
+ throw new Error(`Could not get status from interactive login endpoint.`);
76
+ }
77
+ }
78
+ catch (ex) {
79
+ throw ex;
80
+ }
81
+ finally {
82
+ logResume();
83
+ }
84
+ }));
85
+ }
86
+ return tokenRetrievers[url];
87
+ }
88
+ exports.getTokenInteractively = getTokenInteractively;
30
89
  //# sourceMappingURL=interactive.js.map