@plugjs/plug 0.6.117 → 0.7.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 (388) hide show
  1. package/dist/asserts.d.ts +1 -0
  2. package/dist/asserts.d.ts.map +1 -0
  3. package/dist/asserts.js +68 -0
  4. package/dist/asserts.js.map +1 -0
  5. package/dist/async.d.ts +2 -1
  6. package/dist/async.d.ts.map +1 -0
  7. package/dist/async.js +52 -0
  8. package/dist/async.js.map +1 -0
  9. package/dist/build.d.ts +2 -1
  10. package/dist/build.d.ts.map +1 -0
  11. package/dist/build.js +236 -0
  12. package/dist/build.js.map +1 -0
  13. package/dist/{cli.d.mts → cli.d.ts} +3 -1
  14. package/dist/cli.d.ts.map +1 -0
  15. package/dist/cli.js +330 -0
  16. package/dist/cli.js.map +1 -0
  17. package/dist/files.d.ts +2 -1
  18. package/dist/files.d.ts.map +1 -0
  19. package/dist/files.js +93 -0
  20. package/dist/files.js.map +1 -0
  21. package/dist/fork.d.ts +5 -4
  22. package/dist/fork.d.ts.map +1 -0
  23. package/dist/fork.js +259 -0
  24. package/dist/fork.js.map +1 -0
  25. package/dist/fs.d.ts +1 -0
  26. package/dist/fs.d.ts.map +1 -0
  27. package/dist/fs.js +72 -0
  28. package/dist/fs.js.map +1 -0
  29. package/dist/globals.d.ts +4 -0
  30. package/dist/globals.d.ts.map +1 -0
  31. package/dist/globals.js +2 -0
  32. package/dist/globals.js.map +1 -0
  33. package/dist/helpers.d.ts +8 -7
  34. package/dist/helpers.d.ts.map +1 -0
  35. package/dist/helpers.js +231 -0
  36. package/dist/helpers.js.map +1 -0
  37. package/dist/index.d.ts +22 -21
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +21 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/logging/colors.d.ts +2 -1
  42. package/dist/logging/colors.d.ts.map +1 -0
  43. package/dist/logging/colors.js +121 -0
  44. package/dist/logging/colors.js.map +1 -0
  45. package/dist/logging/emit.d.ts +2 -1
  46. package/dist/logging/emit.d.ts.map +1 -0
  47. package/dist/logging/emit.js +137 -0
  48. package/dist/logging/emit.js.map +1 -0
  49. package/dist/logging/github.d.ts +2 -1
  50. package/dist/logging/github.d.ts.map +1 -0
  51. package/dist/logging/github.js +46 -0
  52. package/dist/logging/github.js.map +1 -0
  53. package/dist/logging/levels.d.ts +1 -0
  54. package/dist/logging/levels.d.ts.map +1 -0
  55. package/dist/logging/levels.js +50 -0
  56. package/dist/logging/levels.js.map +1 -0
  57. package/dist/logging/logger.d.ts +4 -3
  58. package/dist/logging/logger.d.ts.map +1 -0
  59. package/dist/logging/logger.js +161 -0
  60. package/dist/logging/logger.js.map +1 -0
  61. package/dist/logging/options.d.ts +2 -1
  62. package/dist/logging/options.d.ts.map +1 -0
  63. package/dist/logging/options.js +182 -0
  64. package/dist/logging/options.js.map +1 -0
  65. package/dist/logging/report.d.ts +4 -3
  66. package/dist/logging/report.d.ts.map +1 -0
  67. package/dist/logging/report.js +346 -0
  68. package/dist/logging/report.js.map +1 -0
  69. package/dist/logging/spinner.d.ts +1 -0
  70. package/dist/logging/spinner.d.ts.map +1 -0
  71. package/dist/logging/spinner.js +70 -0
  72. package/dist/logging/spinner.js.map +1 -0
  73. package/dist/logging.d.ts +8 -7
  74. package/dist/logging.d.ts.map +1 -0
  75. package/dist/logging.js +66 -0
  76. package/dist/logging.js.map +1 -0
  77. package/dist/paths.d.ts +33 -13
  78. package/dist/paths.d.ts.map +1 -0
  79. package/dist/paths.js +223 -0
  80. package/dist/paths.js.map +1 -0
  81. package/dist/pipe.d.ts +8 -5
  82. package/dist/pipe.d.ts.map +1 -0
  83. package/dist/pipe.js +205 -0
  84. package/dist/pipe.js.map +1 -0
  85. package/dist/plugs/build.d.ts +5 -4
  86. package/dist/plugs/build.d.ts.map +1 -0
  87. package/dist/plugs/build.js +56 -0
  88. package/dist/plugs/build.js.map +1 -0
  89. package/dist/plugs/copy.d.ts +1 -0
  90. package/dist/plugs/copy.d.ts.map +1 -0
  91. package/dist/plugs/copy.js +92 -0
  92. package/dist/plugs/copy.js.map +1 -0
  93. package/dist/plugs/debug.d.ts +1 -0
  94. package/dist/plugs/debug.d.ts.map +1 -0
  95. package/dist/plugs/debug.js +25 -0
  96. package/dist/plugs/debug.js.map +1 -0
  97. package/dist/plugs/edit.d.ts +2 -1
  98. package/dist/plugs/edit.d.ts.map +1 -0
  99. package/dist/plugs/edit.js +22 -0
  100. package/dist/plugs/edit.js.map +1 -0
  101. package/dist/plugs/esbuild/bundle-locals.d.ts +1 -0
  102. package/dist/plugs/esbuild/bundle-locals.d.ts.map +1 -0
  103. package/dist/plugs/esbuild/bundle-locals.js +29 -0
  104. package/dist/plugs/esbuild/bundle-locals.js.map +1 -0
  105. package/dist/plugs/esbuild/fix-extensions.d.ts +1 -0
  106. package/dist/plugs/esbuild/fix-extensions.d.ts.map +1 -0
  107. package/dist/plugs/esbuild/fix-extensions.js +98 -0
  108. package/dist/plugs/esbuild/fix-extensions.js.map +1 -0
  109. package/dist/plugs/esbuild.d.ts +21 -2
  110. package/dist/plugs/esbuild.d.ts.map +1 -0
  111. package/dist/plugs/esbuild.js +193 -0
  112. package/dist/plugs/esbuild.js.map +1 -0
  113. package/dist/plugs/exec.d.ts +2 -1
  114. package/dist/plugs/exec.d.ts.map +1 -0
  115. package/dist/plugs/exec.js +33 -0
  116. package/dist/plugs/exec.js.map +1 -0
  117. package/dist/plugs/exports.d.ts +1 -0
  118. package/dist/plugs/exports.d.ts.map +1 -0
  119. package/dist/plugs/exports.js +110 -0
  120. package/dist/plugs/exports.js.map +1 -0
  121. package/dist/plugs/filter.d.ts +2 -1
  122. package/dist/plugs/filter.d.ts.map +1 -0
  123. package/dist/plugs/filter.js +34 -0
  124. package/dist/plugs/filter.js.map +1 -0
  125. package/dist/plugs/rmf.d.ts +1 -0
  126. package/dist/plugs/rmf.d.ts.map +1 -0
  127. package/dist/plugs/rmf.js +24 -0
  128. package/dist/plugs/rmf.js.map +1 -0
  129. package/dist/plugs.d.ts +9 -8
  130. package/dist/plugs.d.ts.map +1 -0
  131. package/dist/plugs.js +9 -0
  132. package/dist/plugs.js.map +1 -0
  133. package/dist/types.d.ts +4 -3
  134. package/dist/types.d.ts.map +1 -0
  135. package/dist/types.js +2 -0
  136. package/dist/types.js.map +1 -0
  137. package/dist/utils/ansi.d.ts +1 -0
  138. package/dist/utils/ansi.d.ts.map +1 -0
  139. package/dist/utils/ansi.js +10 -0
  140. package/dist/utils/ansi.js.map +1 -0
  141. package/dist/utils/caller.d.ts +2 -1
  142. package/dist/utils/caller.d.ts.map +1 -0
  143. package/dist/utils/caller.js +33 -0
  144. package/dist/utils/caller.js.map +1 -0
  145. package/dist/utils/diff.d.ts +1 -0
  146. package/dist/utils/diff.d.ts.map +1 -0
  147. package/dist/utils/diff.js +278 -0
  148. package/dist/utils/diff.js.map +1 -0
  149. package/dist/utils/exec.d.ts +2 -1
  150. package/dist/utils/exec.d.ts.map +1 -0
  151. package/dist/utils/exec.js +84 -0
  152. package/dist/utils/exec.js.map +1 -0
  153. package/dist/utils/jsonc.d.ts +1 -0
  154. package/dist/utils/jsonc.d.ts.map +1 -0
  155. package/dist/utils/jsonc.js +46 -0
  156. package/dist/utils/jsonc.js.map +1 -0
  157. package/dist/utils/match.d.ts +1 -0
  158. package/dist/utils/match.d.ts.map +1 -0
  159. package/dist/utils/match.js +40 -0
  160. package/dist/utils/match.js.map +1 -0
  161. package/dist/utils/options.d.ts +1 -0
  162. package/dist/utils/options.d.ts.map +1 -0
  163. package/dist/utils/options.js +17 -0
  164. package/dist/utils/options.js.map +1 -0
  165. package/dist/utils/singleton.d.ts +1 -0
  166. package/dist/utils/singleton.d.ts.map +1 -0
  167. package/dist/utils/singleton.js +20 -0
  168. package/dist/utils/singleton.js.map +1 -0
  169. package/dist/utils/walk.d.ts +3 -2
  170. package/dist/utils/walk.d.ts.map +1 -0
  171. package/dist/utils/walk.js +84 -0
  172. package/dist/utils/walk.js.map +1 -0
  173. package/dist/utils.d.ts +9 -8
  174. package/dist/utils.d.ts.map +1 -0
  175. package/dist/utils.js +9 -0
  176. package/dist/utils.js.map +1 -0
  177. package/package.json +27 -87
  178. package/src/asserts.ts +2 -2
  179. package/src/async.ts +3 -3
  180. package/src/build.ts +10 -10
  181. package/src/{cli.mts → cli.ts} +27 -16
  182. package/src/files.ts +4 -4
  183. package/src/fork.ts +17 -17
  184. package/src/globals.ts +3 -0
  185. package/src/helpers.ts +20 -20
  186. package/src/index.ts +21 -21
  187. package/src/logging/colors.ts +4 -4
  188. package/src/logging/emit.ts +6 -6
  189. package/src/logging/github.ts +3 -3
  190. package/src/logging/logger.ts +12 -12
  191. package/src/logging/options.ts +10 -10
  192. package/src/logging/report.ts +10 -10
  193. package/src/logging/spinner.ts +3 -3
  194. package/src/logging.ts +14 -14
  195. package/src/paths.ts +42 -23
  196. package/src/pipe.ts +13 -8
  197. package/src/plugs/build.ts +8 -8
  198. package/src/plugs/copy.ts +8 -8
  199. package/src/plugs/debug.ts +4 -4
  200. package/src/plugs/edit.ts +5 -5
  201. package/src/plugs/esbuild/fix-extensions.ts +8 -10
  202. package/src/plugs/esbuild.ts +88 -27
  203. package/src/plugs/exec.ts +6 -6
  204. package/src/plugs/exports.ts +32 -35
  205. package/src/plugs/filter.ts +7 -7
  206. package/src/plugs/rmf.ts +5 -5
  207. package/src/plugs.ts +8 -8
  208. package/src/types.ts +3 -3
  209. package/src/utils/caller.ts +4 -4
  210. package/src/utils/diff.ts +2 -2
  211. package/src/utils/exec.ts +7 -7
  212. package/src/utils/jsonc.ts +1 -1
  213. package/src/utils/walk.ts +6 -6
  214. package/src/utils.ts +8 -8
  215. package/dist/asserts.cjs +0 -86
  216. package/dist/asserts.cjs.map +0 -6
  217. package/dist/asserts.mjs +0 -58
  218. package/dist/asserts.mjs.map +0 -6
  219. package/dist/async.cjs +0 -64
  220. package/dist/async.cjs.map +0 -6
  221. package/dist/async.mjs +0 -36
  222. package/dist/async.mjs.map +0 -6
  223. package/dist/build.cjs +0 -222
  224. package/dist/build.cjs.map +0 -6
  225. package/dist/build.mjs +0 -192
  226. package/dist/build.mjs.map +0 -6
  227. package/dist/cli.mjs +0 -258
  228. package/dist/cli.mjs.map +0 -6
  229. package/dist/files.cjs +0 -113
  230. package/dist/files.cjs.map +0 -6
  231. package/dist/files.mjs +0 -93
  232. package/dist/files.mjs.map +0 -6
  233. package/dist/fork.cjs +0 -224
  234. package/dist/fork.cjs.map +0 -6
  235. package/dist/fork.mjs +0 -198
  236. package/dist/fork.mjs.map +0 -6
  237. package/dist/fs.cjs +0 -146
  238. package/dist/fs.cjs.map +0 -6
  239. package/dist/fs.mjs +0 -82
  240. package/dist/fs.mjs.map +0 -6
  241. package/dist/globals.cjs +0 -2
  242. package/dist/globals.cjs.map +0 -6
  243. package/dist/globals.mjs +0 -1
  244. package/dist/globals.mjs.map +0 -6
  245. package/dist/helpers.cjs +0 -182
  246. package/dist/helpers.cjs.map +0 -6
  247. package/dist/helpers.mjs +0 -151
  248. package/dist/helpers.mjs.map +0 -6
  249. package/dist/index.cjs +0 -114
  250. package/dist/index.cjs.map +0 -6
  251. package/dist/index.mjs +0 -48
  252. package/dist/index.mjs.map +0 -6
  253. package/dist/logging/colors.cjs +0 -136
  254. package/dist/logging/colors.cjs.map +0 -6
  255. package/dist/logging/colors.mjs +0 -99
  256. package/dist/logging/colors.mjs.map +0 -6
  257. package/dist/logging/emit.cjs +0 -134
  258. package/dist/logging/emit.cjs.map +0 -6
  259. package/dist/logging/emit.mjs +0 -106
  260. package/dist/logging/emit.mjs.map +0 -6
  261. package/dist/logging/github.cjs +0 -60
  262. package/dist/logging/github.cjs.map +0 -6
  263. package/dist/logging/github.mjs +0 -35
  264. package/dist/logging/github.mjs.map +0 -6
  265. package/dist/logging/levels.cjs +0 -69
  266. package/dist/logging/levels.cjs.map +0 -6
  267. package/dist/logging/levels.mjs +0 -35
  268. package/dist/logging/levels.mjs.map +0 -6
  269. package/dist/logging/logger.cjs +0 -165
  270. package/dist/logging/logger.cjs.map +0 -6
  271. package/dist/logging/logger.mjs +0 -139
  272. package/dist/logging/logger.mjs.map +0 -6
  273. package/dist/logging/options.cjs +0 -192
  274. package/dist/logging/options.cjs.map +0 -6
  275. package/dist/logging/options.mjs +0 -167
  276. package/dist/logging/options.mjs.map +0 -6
  277. package/dist/logging/report.cjs +0 -298
  278. package/dist/logging/report.cjs.map +0 -6
  279. package/dist/logging/report.mjs +0 -273
  280. package/dist/logging/report.mjs.map +0 -6
  281. package/dist/logging/spinner.cjs +0 -100
  282. package/dist/logging/spinner.cjs.map +0 -6
  283. package/dist/logging/spinner.mjs +0 -72
  284. package/dist/logging/spinner.mjs.map +0 -6
  285. package/dist/logging.cjs +0 -91
  286. package/dist/logging.cjs.map +0 -6
  287. package/dist/logging.mjs +0 -58
  288. package/dist/logging.mjs.map +0 -6
  289. package/dist/paths.cjs +0 -170
  290. package/dist/paths.cjs.map +0 -6
  291. package/dist/paths.mjs +0 -132
  292. package/dist/paths.mjs.map +0 -6
  293. package/dist/pipe.cjs +0 -163
  294. package/dist/pipe.cjs.map +0 -6
  295. package/dist/pipe.mjs +0 -135
  296. package/dist/pipe.mjs.map +0 -6
  297. package/dist/plugs/build.cjs +0 -73
  298. package/dist/plugs/build.cjs.map +0 -6
  299. package/dist/plugs/build.mjs +0 -47
  300. package/dist/plugs/build.mjs.map +0 -6
  301. package/dist/plugs/copy.cjs +0 -86
  302. package/dist/plugs/copy.cjs.map +0 -6
  303. package/dist/plugs/copy.mjs +0 -69
  304. package/dist/plugs/copy.mjs.map +0 -6
  305. package/dist/plugs/debug.cjs +0 -24
  306. package/dist/plugs/debug.cjs.map +0 -6
  307. package/dist/plugs/debug.mjs +0 -22
  308. package/dist/plugs/debug.mjs.map +0 -6
  309. package/dist/plugs/edit.cjs +0 -20
  310. package/dist/plugs/edit.cjs.map +0 -6
  311. package/dist/plugs/edit.mjs +0 -18
  312. package/dist/plugs/edit.mjs.map +0 -6
  313. package/dist/plugs/esbuild/bundle-locals.cjs +0 -48
  314. package/dist/plugs/esbuild/bundle-locals.cjs.map +0 -6
  315. package/dist/plugs/esbuild/bundle-locals.mjs +0 -23
  316. package/dist/plugs/esbuild/bundle-locals.mjs.map +0 -6
  317. package/dist/plugs/esbuild/fix-extensions.cjs +0 -89
  318. package/dist/plugs/esbuild/fix-extensions.cjs.map +0 -6
  319. package/dist/plugs/esbuild/fix-extensions.mjs +0 -54
  320. package/dist/plugs/esbuild/fix-extensions.mjs.map +0 -6
  321. package/dist/plugs/esbuild.cjs +0 -139
  322. package/dist/plugs/esbuild.cjs.map +0 -6
  323. package/dist/plugs/esbuild.mjs +0 -116
  324. package/dist/plugs/esbuild.mjs.map +0 -6
  325. package/dist/plugs/exec.cjs +0 -42
  326. package/dist/plugs/exec.cjs.map +0 -6
  327. package/dist/plugs/exec.mjs +0 -25
  328. package/dist/plugs/exec.mjs.map +0 -6
  329. package/dist/plugs/exports.cjs +0 -117
  330. package/dist/plugs/exports.cjs.map +0 -6
  331. package/dist/plugs/exports.mjs +0 -100
  332. package/dist/plugs/exports.mjs.map +0 -6
  333. package/dist/plugs/filter.cjs +0 -47
  334. package/dist/plugs/filter.cjs.map +0 -6
  335. package/dist/plugs/filter.mjs +0 -30
  336. package/dist/plugs/filter.mjs.map +0 -6
  337. package/dist/plugs/rmf.cjs +0 -25
  338. package/dist/plugs/rmf.cjs.map +0 -6
  339. package/dist/plugs/rmf.mjs +0 -23
  340. package/dist/plugs/rmf.mjs.map +0 -6
  341. package/dist/plugs.cjs +0 -39
  342. package/dist/plugs.cjs.map +0 -6
  343. package/dist/plugs.mjs +0 -10
  344. package/dist/plugs.mjs.map +0 -6
  345. package/dist/types.cjs +0 -19
  346. package/dist/types.cjs.map +0 -6
  347. package/dist/types.mjs +0 -1
  348. package/dist/types.mjs.map +0 -6
  349. package/dist/utils/ansi.cjs +0 -39
  350. package/dist/utils/ansi.cjs.map +0 -6
  351. package/dist/utils/ansi.mjs +0 -13
  352. package/dist/utils/ansi.mjs.map +0 -6
  353. package/dist/utils/caller.cjs +0 -57
  354. package/dist/utils/caller.cjs.map +0 -6
  355. package/dist/utils/caller.mjs +0 -32
  356. package/dist/utils/caller.mjs.map +0 -6
  357. package/dist/utils/diff.cjs +0 -282
  358. package/dist/utils/diff.cjs.map +0 -6
  359. package/dist/utils/diff.mjs +0 -256
  360. package/dist/utils/diff.mjs.map +0 -6
  361. package/dist/utils/exec.cjs +0 -113
  362. package/dist/utils/exec.cjs.map +0 -6
  363. package/dist/utils/exec.mjs +0 -78
  364. package/dist/utils/exec.mjs.map +0 -6
  365. package/dist/utils/jsonc.cjs +0 -74
  366. package/dist/utils/jsonc.cjs.map +0 -6
  367. package/dist/utils/jsonc.mjs +0 -48
  368. package/dist/utils/jsonc.mjs.map +0 -6
  369. package/dist/utils/match.cjs +0 -74
  370. package/dist/utils/match.cjs.map +0 -6
  371. package/dist/utils/match.mjs +0 -39
  372. package/dist/utils/match.mjs.map +0 -6
  373. package/dist/utils/options.cjs +0 -39
  374. package/dist/utils/options.cjs.map +0 -6
  375. package/dist/utils/options.mjs +0 -14
  376. package/dist/utils/options.mjs.map +0 -6
  377. package/dist/utils/singleton.cjs +0 -37
  378. package/dist/utils/singleton.cjs.map +0 -6
  379. package/dist/utils/singleton.mjs +0 -12
  380. package/dist/utils/singleton.mjs.map +0 -6
  381. package/dist/utils/walk.cjs +0 -98
  382. package/dist/utils/walk.cjs.map +0 -6
  383. package/dist/utils/walk.mjs +0 -73
  384. package/dist/utils/walk.mjs.map +0 -6
  385. package/dist/utils.cjs +0 -39
  386. package/dist/utils.cjs.map +0 -6
  387. package/dist/utils.mjs +0 -10
  388. package/dist/utils.mjs.map +0 -6
package/src/plugs/exec.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { install } from '../pipe'
2
- import { execChild } from '../utils/exec'
3
- import { parseOptions } from '../utils/options'
1
+ import { install } from '../pipe.ts'
2
+ import { execChild } from '../utils/exec.ts'
3
+ import { parseOptions } from '../utils/options.ts'
4
4
 
5
- import type { Files } from '../files'
6
- import type { Context, PipeParameters, Plug } from '../pipe'
7
- import type { ExecChildOptions } from '../utils/exec'
5
+ import type { Files } from '../files.ts'
6
+ import type { Context, PipeParameters, Plug } from '../pipe.ts'
7
+ import type { ExecChildOptions } from '../utils/exec.ts'
8
8
 
9
9
  /** Options for executing scripts */
10
10
  export interface ExecOptions extends ExecChildOptions {
@@ -1,14 +1,14 @@
1
1
  import { EOL } from 'node:os'
2
2
  import { sep } from 'node:path'
3
3
 
4
- import { assert } from '../asserts'
5
- import { Files } from '../files'
6
- import { readFile, writeFile } from '../fs'
7
- import { $p } from '../logging'
8
- import { assertRelativeChildPath, getAbsoluteParent } from '../paths'
9
- import { install } from '../pipe'
4
+ import { assert } from '../asserts.ts'
5
+ import { Files } from '../files.ts'
6
+ import { readFile, writeFile } from '../fs.ts'
7
+ import { $p } from '../logging.ts'
8
+ import { assertRelativeChildPath, getAbsoluteParent } from '../paths.ts'
9
+ import { install } from '../pipe.ts'
10
10
 
11
- import type { Context, PipeParameters, Plug } from '../pipe'
11
+ import type { Context, PipeParameters, Plug } from '../pipe.ts'
12
12
 
13
13
  /** Options for our `exports` plug. */
14
14
  export interface ExportsOptions {
@@ -35,9 +35,10 @@ declare module '../index' {
35
35
 
36
36
  type ExportsDeclaration = {
37
37
  [ name in string ]? : {
38
- [ type in 'require' | 'import' ]? : {
39
- [ kind in 'types' | 'default' ]? : string
40
- }
38
+ require?: string
39
+ import?: string
40
+ types?: string
41
+ default?: string
41
42
  }
42
43
  }
43
44
 
@@ -90,17 +91,16 @@ install('exports', class Exports implements Plug<Files> {
90
91
  const exports: ExportsDeclaration = {}
91
92
  function addExport(
92
93
  name: string,
93
- type: 'require' | 'import',
94
- kind: 'types' | 'default',
94
+ type: 'require' | 'import' | 'types' | 'default',
95
95
  file: string,
96
96
  ): void {
97
97
  if (! exports[name]) exports[name] = {}
98
- if (! exports[name]![type]) exports[name]![type] = {}
99
- exports[name]![type]![kind] = file
98
+ // if (! exports[name]![type]) exports[name]![type] = {}
99
+ exports[name]![type] = file
100
100
  }
101
101
 
102
102
  // all extensions to match in the incoming files
103
- const exts = [ '.d.mts', '.d.cts', '.d.ts', cjsExtension, esmExtension ]
103
+ const exts = [ '.d.ts', '.d.cts', '.d.mts', cjsExtension, esmExtension ]
104
104
 
105
105
  // look up all the files we were piped in
106
106
  for (const [ name, absolute ] of files.pathMappings()) {
@@ -114,20 +114,19 @@ install('exports', class Exports implements Plug<Files> {
114
114
 
115
115
  switch (ext) {
116
116
  case cjsExtension:
117
- addExport(exp, 'require', 'default', `.${sep}${relative}`)
117
+ addExport(exp, type === 'commonjs' ? 'default' : 'require', `.${sep}${relative}`)
118
118
  break
119
119
  case esmExtension:
120
- addExport(exp, 'import', 'default', `.${sep}${relative}`)
120
+ addExport(exp, type === 'module' ? 'default' : 'import', `.${sep}${relative}`)
121
121
  break
122
122
  case '.d.cts':
123
- addExport(exp, 'require', 'types', `.${sep}${relative}`)
123
+ addExport(exp, 'types', `.${sep}${relative}`)
124
124
  break
125
125
  case '.d.mts':
126
- addExport(exp, 'import', 'types', `.${sep}${relative}`)
126
+ addExport(exp, 'types', `.${sep}${relative}`)
127
127
  break
128
128
  case '.d.ts':
129
- addExport(exp, 'require', 'types', `.${sep}${relative}`)
130
- addExport(exp, 'import', 'types', `.${sep}${relative}`)
129
+ addExport(exp, 'types', `.${sep}${relative}`)
131
130
  break
132
131
  }
133
132
  }
@@ -136,10 +135,12 @@ install('exports', class Exports implements Plug<Files> {
136
135
  // if we have a "." export, inject the "main", "module" and "types" fields
137
136
  if ('.' in exports) {
138
137
  const rootExport = exports['.']
139
- packageData['main'] = rootExport?.require?.default
140
- packageData['module'] = rootExport?.import?.default
141
- packageData['types'] = packageData['type'] === 'module' ?
142
- rootExport?.import?.types : rootExport?.require?.types
138
+ packageData['module'] = undefined // wipe existing...
139
+ packageData['main'] =
140
+ type === 'commonjs' ? rootExport?.require || rootExport?.default :
141
+ type === 'module' ? rootExport?.import || rootExport?.default :
142
+ undefined
143
+ packageData['types'] = rootExport?.types
143
144
  }
144
145
 
145
146
  // correctly order the exports record (e.g. types comes before default)
@@ -149,16 +150,12 @@ install('exports', class Exports implements Plug<Files> {
149
150
 
150
151
  // json serialization will scrub all undefined... here we export the types
151
152
  // only if the "default" export is available, or we scrub the whole thing!
152
- obj[name] = current.require?.default || current.import?.default ? {
153
- require: current.require?.default ? {
154
- types: current.require.types || undefined,
155
- default: current.require.default || undefined,
156
- } : undefined,
157
- import: current.import?.default ? {
158
- types: current.import.types || undefined,
159
- default: current.import.default || undefined,
160
- } : undefined,
161
- } : undefined
153
+ obj[name] = {
154
+ types: current.types,
155
+ require: current.require,
156
+ import: current.import,
157
+ default: current.default,
158
+ }
162
159
 
163
160
  return obj
164
161
  }, {} as ExportsDeclaration)
@@ -1,11 +1,11 @@
1
- import { Files } from '../files'
2
- import { resolveRelativeChildPath } from '../paths'
3
- import { install } from '../pipe'
4
- import { match } from '../utils/match'
5
- import { parseOptions } from '../utils/options'
1
+ import { Files } from '../files.ts'
2
+ import { resolveRelativeChildPath } from '../paths.ts'
3
+ import { install } from '../pipe.ts'
4
+ import { match } from '../utils/match.ts'
5
+ import { parseOptions } from '../utils/options.ts'
6
6
 
7
- import type { Context, PipeParameters, Plug } from '../pipe'
8
- import type { MatchOptions } from '../utils/match'
7
+ import type { Context, PipeParameters, Plug } from '../pipe.ts'
8
+ import type { MatchOptions } from '../utils/match.ts'
9
9
 
10
10
  /** Options for filtering {@link Files}. */
11
11
  export interface FilterOptions extends MatchOptions {
package/src/plugs/rmf.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { rm } from '../fs'
2
- import { $gry, $p } from '../logging'
3
- import { install } from '../pipe'
1
+ import { rm } from '../fs.ts'
2
+ import { $gry, $p } from '../logging.ts'
3
+ import { install } from '../pipe.ts'
4
4
 
5
- import type { Files } from '../files'
6
- import type { Context, PipeParameters, Plug } from '../pipe'
5
+ import type { Files } from '../files.ts'
6
+ import type { Context, PipeParameters, Plug } from '../pipe.ts'
7
7
 
8
8
  declare module '../index' {
9
9
  export interface Pipe {
package/src/plugs.ts CHANGED
@@ -1,8 +1,8 @@
1
- export * from './plugs/copy'
2
- export * from './plugs/debug'
3
- export * from './plugs/edit'
4
- export * from './plugs/esbuild'
5
- export * from './plugs/exec'
6
- export * from './plugs/exports'
7
- export * from './plugs/filter'
8
- export * from './plugs/rmf'
1
+ export * from './plugs/copy.ts'
2
+ export * from './plugs/debug.ts'
3
+ export * from './plugs/edit.ts'
4
+ export * from './plugs/esbuild.ts'
5
+ export * from './plugs/exec.ts'
6
+ export * from './plugs/exports.ts'
7
+ export * from './plugs/filter.ts'
8
+ export * from './plugs/rmf.ts'
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { Files } from './files'
2
- import type { Pipe } from './index'
3
- import type { AbsolutePath } from './paths'
1
+ import type { Files } from './files.ts'
2
+ import type { Pipe } from './index.ts'
3
+ import type { AbsolutePath } from './paths.ts'
4
4
 
5
5
  /**
6
6
  * A type describing the ultimate result of a {@link Plug}, {@link Pipe} or
@@ -1,11 +1,11 @@
1
1
  import { statSync } from 'node:fs'
2
2
  import { fileURLToPath } from 'node:url'
3
3
 
4
- import { assert } from '../asserts'
5
- import { $p } from '../logging'
6
- import { assertAbsolutePath } from '../paths'
4
+ import { assert } from '../asserts.ts'
5
+ import { $p } from '../logging.ts'
6
+ import { assertAbsolutePath } from '../paths.ts'
7
7
 
8
- import type { AbsolutePath } from '../paths'
8
+ import type { AbsolutePath } from '../paths.ts'
9
9
 
10
10
  export function findCaller(of: (...args: any[]) => any): AbsolutePath {
11
11
  const oldPrepareStackTrace = Error.prepareStackTrace
package/src/utils/diff.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { fail } from 'node:assert'
2
2
  import { inspect, isDeepStrictEqual } from 'node:util'
3
3
 
4
- import { assert } from '../asserts'
5
- import { $grn, $red, logOptions } from '../logging'
4
+ import { assert } from '../asserts.ts'
5
+ import { $grn, $red, logOptions } from '../logging.ts'
6
6
 
7
7
  import type { InspectOptions } from 'node:util'
8
8
 
package/src/utils/exec.ts CHANGED
@@ -2,13 +2,13 @@ import { spawn } from 'node:child_process'
2
2
  import path from 'node:path'
3
3
  import readline from 'node:readline'
4
4
 
5
- import { assert, BuildFailure } from '../asserts'
6
- import { $p, logOptions } from '../logging'
7
- import { getCurrentWorkingDirectory, resolveDirectory } from '../paths'
5
+ import { assert, BuildFailure } from '../asserts.ts'
6
+ import { $p, logOptions } from '../logging.ts'
7
+ import { getCurrentWorkingDirectory, resolveDirectory } from '../paths.ts'
8
8
 
9
9
  import type { SpawnOptions } from 'node:child_process'
10
- import type { AbsolutePath } from '../paths'
11
- import type { Context } from '../pipe'
10
+ import type { AbsolutePath } from '../paths.ts'
11
+ import type { Context } from '../pipe.ts'
12
12
 
13
13
  /** Options for executing scripts */
14
14
  export interface ExecChildOptions {
@@ -51,7 +51,7 @@ export async function execChild(
51
51
  if (resolveDirectory(buildNodePath)) childPaths.push(buildNodePath)
52
52
 
53
53
  // Any other paths either from `process.env` or `env` (which overrides it)
54
- const extraPath = env.PATH || process.env.PATH
54
+ const extraPath = env['PATH'] || process.env['PATH']
55
55
  if (extraPath) childPaths.push(extraPath)
56
56
 
57
57
  // Build our environment variables record
@@ -64,7 +64,7 @@ export async function execChild(
64
64
  }
65
65
 
66
66
  // Instrument coverage directory if needed
67
- if (coverageDir) childEnv.NODE_V8_COVERAGE = context.resolve(coverageDir)
67
+ if (coverageDir) childEnv['NODE_V8_COVERAGE'] = context.resolve(coverageDir)
68
68
 
69
69
  // Prepare the options for calling `spawn`
70
70
  const childOptions: SpawnOptions = {
@@ -2,7 +2,7 @@ import { EOL } from 'node:os'
2
2
 
3
3
  import { parse, printParseErrorCode } from 'jsonc-parser'
4
4
 
5
- import { $plur } from '../logging/colors'
5
+ import { $plur } from '../logging/colors.ts'
6
6
 
7
7
  import type { ParseError } from 'jsonc-parser'
8
8
 
package/src/utils/walk.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { basename, join } from 'node:path'
2
2
 
3
- import { opendir, stat } from '../fs'
4
- import { $p, log } from '../logging'
5
- import { resolveAbsolutePath } from '../paths'
6
- import { match } from './match'
3
+ import { opendir, stat } from '../fs.ts'
4
+ import { $p, log } from '../logging.ts'
5
+ import { resolveAbsolutePath } from '../paths.ts'
6
+ import { match } from './match.ts'
7
7
 
8
8
  import type { Dir } from 'node:fs'
9
- import type { AbsolutePath } from '../paths'
10
- import type { MatchOptions } from './match'
9
+ import type { AbsolutePath } from '../paths.ts'
10
+ import type { MatchOptions } from './match.ts'
11
11
 
12
12
  /** Specific options for walking a directory */
13
13
  export interface WalkOptions extends MatchOptions {
package/src/utils.ts CHANGED
@@ -1,8 +1,8 @@
1
- export * from './utils/ansi'
2
- export * from './utils/diff'
3
- export * from './utils/exec'
4
- export * from './utils/jsonc'
5
- export * from './utils/match'
6
- export * from './utils/options'
7
- export * from './utils/singleton'
8
- export * from './utils/walk'
1
+ export * from './utils/ansi.ts'
2
+ export * from './utils/diff.ts'
3
+ export * from './utils/exec.ts'
4
+ export * from './utils/jsonc.ts'
5
+ export * from './utils/match.ts'
6
+ export * from './utils/options.ts'
7
+ export * from './utils/singleton.ts'
8
+ export * from './utils/walk.ts'
package/dist/asserts.cjs DELETED
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // asserts.ts
21
- var asserts_exports = {};
22
- __export(asserts_exports, {
23
- BuildFailure: () => BuildFailure,
24
- assert: () => assert,
25
- assertPromises: () => assertPromises,
26
- fail: () => fail
27
- });
28
- module.exports = __toCommonJS(asserts_exports);
29
- var import_github = require("./logging/github.cjs");
30
- var buildFailure = /* @__PURE__ */ Symbol.for("plugjs:plug:types:BuildFailure");
31
- var BuildFailure = class _BuildFailure extends Error {
32
- errors;
33
- /** Construct a {@link BuildFailure} */
34
- constructor(message, errors = []) {
35
- super(message || "");
36
- if (message) {
37
- (0, import_github.githubAnnotation)({ type: "error", title: "Build Failure" }, message);
38
- }
39
- Error.captureStackTrace(this, _BuildFailure);
40
- if (errors.length) this.errors = Object.freeze([...errors]);
41
- }
42
- static fail() {
43
- return new _BuildFailure(void 0, []);
44
- }
45
- static withMessage(message) {
46
- return new _BuildFailure(message, []);
47
- }
48
- static withErrors(errors) {
49
- return new _BuildFailure(void 0, errors);
50
- }
51
- static [Symbol.hasInstance](instance) {
52
- return instance && instance[buildFailure] === buildFailure;
53
- }
54
- static {
55
- this.prototype[buildFailure] = buildFailure;
56
- this.prototype.name = this.name;
57
- }
58
- };
59
- async function assertPromises(promises) {
60
- const settlements = await Promise.allSettled(promises);
61
- const results = [];
62
- const failures = /* @__PURE__ */ new Set();
63
- settlements.forEach((settlement) => {
64
- if (settlement.status === "fulfilled") {
65
- results.push(settlement.value);
66
- } else {
67
- failures.add(settlement.reason);
68
- }
69
- });
70
- if (failures.size) throw BuildFailure.withErrors([...failures]);
71
- return results;
72
- }
73
- function assert(assertion, message) {
74
- if (!assertion) throw BuildFailure.withMessage(message);
75
- }
76
- function fail(message) {
77
- throw BuildFailure.withMessage(message);
78
- }
79
- // Annotate the CommonJS export names for ESM import in node:
80
- 0 && (module.exports = {
81
- BuildFailure,
82
- assert,
83
- assertPromises,
84
- fail
85
- });
86
- //# sourceMappingURL=asserts.cjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/asserts.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAiC;AAGjC,IAAM,eAAe,uBAAO,IAAI,gCAAgC;AAGzD,IAAM,eAAN,MAAM,sBAAqB,MAAM;AAAA,EAC7B;AAAA;AAAA,EAGT,YAAY,SAA8B,SAAgB,CAAC,GAAG;AAC5D,UAAM,WAAW,EAAE;AAGnB,QAAI,SAAS;AACX,0CAAiB,EAAE,MAAM,SAAS,OAAO,gBAAgB,GAAG,OAAO;AAAA,IACrE;AAGA,UAAM,kBAAkB,MAAM,aAAY;AAC1C,QAAI,OAAO,OAAQ,MAAK,SAAS,OAAO,OAAO,CAAE,GAAG,MAAO,CAAC;AAAA,EAC9D;AAAA,EAEA,OAAO,OAAqB;AAC1B,WAAO,IAAI,cAAa,QAAW,CAAC,CAAC;AAAA,EACvC;AAAA,EAEA,OAAO,YAAY,SAA+B;AAChD,WAAO,IAAI,cAAa,SAAS,CAAC,CAAC;AAAA,EACrC;AAAA,EAEA,OAAO,WAAW,QAA6B;AAC7C,WAAO,IAAI,cAAa,QAAW,MAAM;AAAA,EAC3C;AAAA,EAEA,QAAQ,OAAO,WAAW,EAAE,UAAwB;AAClD,WAAO,YAAY,SAAS,YAAY,MAAM;AAAA,EAChD;AAAA,EAEA,OAAO;AACL,IAAC,KAAK,UAAkB,YAAY,IAAI;AACxC,SAAK,UAAU,OAAO,KAAK;AAAA,EAC7B;AACF;AAGA,eAAsB,eAAkB,UAA4C;AAElF,QAAM,cAAc,MAAM,QAAQ,WAAW,QAAQ;AAGrD,QAAM,UAAe,CAAC;AACtB,QAAM,WAAW,oBAAI,IAAS;AAE9B,cAAY,QAAQ,CAAC,eAAe;AAClC,QAAI,WAAW,WAAW,aAAa;AACrC,cAAQ,KAAK,WAAW,KAAK;AAAA,IAC/B,OAAO;AACL,eAAS,IAAI,WAAW,MAAM;AAAA,IAChC;AAAA,EACF,CAAC;AAGD,MAAI,SAAS,KAAM,OAAM,aAAa,WAAW,CAAE,GAAG,QAAS,CAAC;AAEhE,SAAO;AACT;AAGO,SAAS,OAAO,WAAgB,SAAoC;AACzE,MAAI,CAAE,UAAW,OAAM,aAAa,YAAY,OAAO;AACzD;AAGO,SAAS,KAAK,SAAwB;AAC3C,QAAM,aAAa,YAAY,OAAO;AACxC;",
5
- "names": []
6
- }
package/dist/asserts.mjs DELETED
@@ -1,58 +0,0 @@
1
- // asserts.ts
2
- import { githubAnnotation } from "./logging/github.mjs";
3
- var buildFailure = /* @__PURE__ */ Symbol.for("plugjs:plug:types:BuildFailure");
4
- var BuildFailure = class _BuildFailure extends Error {
5
- errors;
6
- /** Construct a {@link BuildFailure} */
7
- constructor(message, errors = []) {
8
- super(message || "");
9
- if (message) {
10
- githubAnnotation({ type: "error", title: "Build Failure" }, message);
11
- }
12
- Error.captureStackTrace(this, _BuildFailure);
13
- if (errors.length) this.errors = Object.freeze([...errors]);
14
- }
15
- static fail() {
16
- return new _BuildFailure(void 0, []);
17
- }
18
- static withMessage(message) {
19
- return new _BuildFailure(message, []);
20
- }
21
- static withErrors(errors) {
22
- return new _BuildFailure(void 0, errors);
23
- }
24
- static [Symbol.hasInstance](instance) {
25
- return instance && instance[buildFailure] === buildFailure;
26
- }
27
- static {
28
- this.prototype[buildFailure] = buildFailure;
29
- this.prototype.name = this.name;
30
- }
31
- };
32
- async function assertPromises(promises) {
33
- const settlements = await Promise.allSettled(promises);
34
- const results = [];
35
- const failures = /* @__PURE__ */ new Set();
36
- settlements.forEach((settlement) => {
37
- if (settlement.status === "fulfilled") {
38
- results.push(settlement.value);
39
- } else {
40
- failures.add(settlement.reason);
41
- }
42
- });
43
- if (failures.size) throw BuildFailure.withErrors([...failures]);
44
- return results;
45
- }
46
- function assert(assertion, message) {
47
- if (!assertion) throw BuildFailure.withMessage(message);
48
- }
49
- function fail(message) {
50
- throw BuildFailure.withMessage(message);
51
- }
52
- export {
53
- BuildFailure,
54
- assert,
55
- assertPromises,
56
- fail
57
- };
58
- //# sourceMappingURL=asserts.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/asserts.ts"],
4
- "mappings": ";AAIA,SAAS,wBAAwB;AAGjC,IAAM,eAAe,uBAAO,IAAI,gCAAgC;AAGzD,IAAM,eAAN,MAAM,sBAAqB,MAAM;AAAA,EAC7B;AAAA;AAAA,EAGT,YAAY,SAA8B,SAAgB,CAAC,GAAG;AAC5D,UAAM,WAAW,EAAE;AAGnB,QAAI,SAAS;AACX,uBAAiB,EAAE,MAAM,SAAS,OAAO,gBAAgB,GAAG,OAAO;AAAA,IACrE;AAGA,UAAM,kBAAkB,MAAM,aAAY;AAC1C,QAAI,OAAO,OAAQ,MAAK,SAAS,OAAO,OAAO,CAAE,GAAG,MAAO,CAAC;AAAA,EAC9D;AAAA,EAEA,OAAO,OAAqB;AAC1B,WAAO,IAAI,cAAa,QAAW,CAAC,CAAC;AAAA,EACvC;AAAA,EAEA,OAAO,YAAY,SAA+B;AAChD,WAAO,IAAI,cAAa,SAAS,CAAC,CAAC;AAAA,EACrC;AAAA,EAEA,OAAO,WAAW,QAA6B;AAC7C,WAAO,IAAI,cAAa,QAAW,MAAM;AAAA,EAC3C;AAAA,EAEA,QAAQ,OAAO,WAAW,EAAE,UAAwB;AAClD,WAAO,YAAY,SAAS,YAAY,MAAM;AAAA,EAChD;AAAA,EAEA,OAAO;AACL,IAAC,KAAK,UAAkB,YAAY,IAAI;AACxC,SAAK,UAAU,OAAO,KAAK;AAAA,EAC7B;AACF;AAGA,eAAsB,eAAkB,UAA4C;AAElF,QAAM,cAAc,MAAM,QAAQ,WAAW,QAAQ;AAGrD,QAAM,UAAe,CAAC;AACtB,QAAM,WAAW,oBAAI,IAAS;AAE9B,cAAY,QAAQ,CAAC,eAAe;AAClC,QAAI,WAAW,WAAW,aAAa;AACrC,cAAQ,KAAK,WAAW,KAAK;AAAA,IAC/B,OAAO;AACL,eAAS,IAAI,WAAW,MAAM;AAAA,IAChC;AAAA,EACF,CAAC;AAGD,MAAI,SAAS,KAAM,OAAM,aAAa,WAAW,CAAE,GAAG,QAAS,CAAC;AAEhE,SAAO;AACT;AAGO,SAAS,OAAO,WAAgB,SAAoC;AACzE,MAAI,CAAE,UAAW,OAAM,aAAa,YAAY,OAAO;AACzD;AAGO,SAAS,KAAK,SAAwB;AAC3C,QAAM,aAAa,YAAY,OAAO;AACxC;",
5
- "names": []
6
- }
package/dist/async.cjs DELETED
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // async.ts
21
- var async_exports = {};
22
- __export(async_exports, {
23
- currentContext: () => currentContext,
24
- requireContext: () => requireContext,
25
- runAsync: () => runAsync,
26
- runningTasks: () => runningTasks
27
- });
28
- module.exports = __toCommonJS(async_exports);
29
- var import_node_async_hooks = require("node:async_hooks");
30
- var import_asserts = require("./asserts.cjs");
31
- var import_singleton = require("./utils/singleton.cjs");
32
- function runAsync(context, callback) {
33
- return storage.run(context, async () => {
34
- try {
35
- tasks.add(context.taskName);
36
- return await callback();
37
- } finally {
38
- tasks.delete(context.taskName);
39
- }
40
- });
41
- }
42
- function currentContext() {
43
- return storage.getStore();
44
- }
45
- function requireContext() {
46
- const context = storage.getStore();
47
- (0, import_asserts.assert)(context, "Unable to retrieve current context");
48
- return context;
49
- }
50
- function runningTasks() {
51
- return [...tasks].sort();
52
- }
53
- var storageKey = /* @__PURE__ */ Symbol.for("plugjs:plug:singleton:contextStorage");
54
- var tasksKey = /* @__PURE__ */ Symbol.for("plugjs:plug:singleton:runningTasksStorage");
55
- var storage = (0, import_singleton.getSingleton)(storageKey, () => new import_node_async_hooks.AsyncLocalStorage());
56
- var tasks = (0, import_singleton.getSingleton)(tasksKey, () => /* @__PURE__ */ new Set());
57
- // Annotate the CommonJS export names for ESM import in node:
58
- 0 && (module.exports = {
59
- currentContext,
60
- requireContext,
61
- runAsync,
62
- runningTasks
63
- });
64
- //# sourceMappingURL=async.cjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/async.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAkC;AAElC,qBAAuB;AACvB,uBAA6B;AAYtB,SAAS,SACZ,SACA,UACU;AACZ,SAAO,QAAQ,IAAI,SAAS,YAAY;AACtC,QAAI;AACF,YAAM,IAAI,QAAQ,QAAQ;AAC1B,aAAO,MAAM,SAAS;AAAA,IACxB,UAAE;AACA,YAAM,OAAO,QAAQ,QAAQ;AAAA,IAC/B;AAAA,EACF,CAAC;AACH;AAMO,SAAS,iBAAsC;AACpD,SAAO,QAAQ,SAAS;AAC1B;AAMO,SAAS,iBAA0B;AACxC,QAAM,UAAU,QAAQ,SAAS;AACjC,6BAAO,SAAS,oCAAoC;AACpD,SAAO;AACT;AAKO,SAAS,eAAyB;AACvC,SAAO,CAAE,GAAG,KAAM,EAAE,KAAK;AAC3B;AAOA,IAAM,aAAa,uBAAO,IAAI,sCAAsC;AACpE,IAAM,WAAW,uBAAO,IAAI,2CAA2C;AAEvE,IAAM,cAAU,+BAAa,YAAY,MAAM,IAAI,0CAA2B,CAAC;AAC/E,IAAM,YAAQ,+BAAa,UAAU,MAAM,oBAAI,IAAY,CAAC;",
5
- "names": []
6
- }
package/dist/async.mjs DELETED
@@ -1,36 +0,0 @@
1
- // async.ts
2
- import { AsyncLocalStorage } from "node:async_hooks";
3
- import { assert } from "./asserts.mjs";
4
- import { getSingleton } from "./utils/singleton.mjs";
5
- function runAsync(context, callback) {
6
- return storage.run(context, async () => {
7
- try {
8
- tasks.add(context.taskName);
9
- return await callback();
10
- } finally {
11
- tasks.delete(context.taskName);
12
- }
13
- });
14
- }
15
- function currentContext() {
16
- return storage.getStore();
17
- }
18
- function requireContext() {
19
- const context = storage.getStore();
20
- assert(context, "Unable to retrieve current context");
21
- return context;
22
- }
23
- function runningTasks() {
24
- return [...tasks].sort();
25
- }
26
- var storageKey = /* @__PURE__ */ Symbol.for("plugjs:plug:singleton:contextStorage");
27
- var tasksKey = /* @__PURE__ */ Symbol.for("plugjs:plug:singleton:runningTasksStorage");
28
- var storage = getSingleton(storageKey, () => new AsyncLocalStorage());
29
- var tasks = getSingleton(tasksKey, () => /* @__PURE__ */ new Set());
30
- export {
31
- currentContext,
32
- requireContext,
33
- runAsync,
34
- runningTasks
35
- };
36
- //# sourceMappingURL=async.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/async.ts"],
4
- "mappings": ";AAAA,SAAS,yBAAyB;AAElC,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAYtB,SAAS,SACZ,SACA,UACU;AACZ,SAAO,QAAQ,IAAI,SAAS,YAAY;AACtC,QAAI;AACF,YAAM,IAAI,QAAQ,QAAQ;AAC1B,aAAO,MAAM,SAAS;AAAA,IACxB,UAAE;AACA,YAAM,OAAO,QAAQ,QAAQ;AAAA,IAC/B;AAAA,EACF,CAAC;AACH;AAMO,SAAS,iBAAsC;AACpD,SAAO,QAAQ,SAAS;AAC1B;AAMO,SAAS,iBAA0B;AACxC,QAAM,UAAU,QAAQ,SAAS;AACjC,SAAO,SAAS,oCAAoC;AACpD,SAAO;AACT;AAKO,SAAS,eAAyB;AACvC,SAAO,CAAE,GAAG,KAAM,EAAE,KAAK;AAC3B;AAOA,IAAM,aAAa,uBAAO,IAAI,sCAAsC;AACpE,IAAM,WAAW,uBAAO,IAAI,2CAA2C;AAEvE,IAAM,UAAU,aAAa,YAAY,MAAM,IAAI,kBAA2B,CAAC;AAC/E,IAAM,QAAQ,aAAa,UAAU,MAAM,oBAAI,IAAY,CAAC;",
5
- "names": []
6
- }