@seasb/metafab 0.0.1 → 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 (369) hide show
  1. package/README.md +46 -1
  2. package/dist/cli.d.ts +11 -0
  3. package/dist/cli.js +317 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/build.d.ts +2 -0
  6. package/dist/commands/build.js +70 -0
  7. package/dist/commands/build.js.map +1 -0
  8. package/dist/commands/check.d.ts +2 -0
  9. package/dist/commands/check.js +41 -0
  10. package/dist/commands/check.js.map +1 -0
  11. package/dist/commands/create.d.ts +2 -0
  12. package/dist/commands/create.js +74 -0
  13. package/dist/commands/create.js.map +1 -0
  14. package/dist/commands/detach.d.ts +2 -0
  15. package/dist/commands/detach.js +24 -0
  16. package/dist/commands/detach.js.map +1 -0
  17. package/dist/commands/diff.d.ts +2 -0
  18. package/dist/commands/diff.js +35 -0
  19. package/dist/commands/diff.js.map +1 -0
  20. package/dist/commands/import.d.ts +2 -0
  21. package/dist/commands/import.js +107 -0
  22. package/dist/commands/import.js.map +1 -0
  23. package/dist/commands/init.d.ts +2 -0
  24. package/dist/commands/init.js +77 -0
  25. package/dist/commands/init.js.map +1 -0
  26. package/dist/commands/map.d.ts +2 -0
  27. package/dist/commands/map.js +43 -0
  28. package/dist/commands/map.js.map +1 -0
  29. package/dist/commands/not-implemented.d.ts +2 -0
  30. package/dist/commands/not-implemented.js +19 -0
  31. package/dist/commands/not-implemented.js.map +1 -0
  32. package/dist/commands/pipeline-add.d.ts +2 -0
  33. package/dist/commands/pipeline-add.js +67 -0
  34. package/dist/commands/pipeline-add.js.map +1 -0
  35. package/dist/commands/pipeline-remove.d.ts +2 -0
  36. package/dist/commands/pipeline-remove.js +44 -0
  37. package/dist/commands/pipeline-remove.js.map +1 -0
  38. package/dist/commands/publish.d.ts +2 -0
  39. package/dist/commands/publish.js +147 -0
  40. package/dist/commands/publish.js.map +1 -0
  41. package/dist/commands/types.d.ts +45 -0
  42. package/dist/commands/types.js +2 -0
  43. package/dist/commands/types.js.map +1 -0
  44. package/dist/commands/update.d.ts +2 -0
  45. package/dist/commands/update.js +97 -0
  46. package/dist/commands/update.js.map +1 -0
  47. package/dist/core/adopt.d.ts +53 -0
  48. package/dist/core/adopt.js +676 -0
  49. package/dist/core/adopt.js.map +1 -0
  50. package/dist/core/build/agents.d.ts +23 -0
  51. package/dist/core/build/agents.js +60 -0
  52. package/dist/core/build/agents.js.map +1 -0
  53. package/dist/core/build/index.d.ts +4 -0
  54. package/dist/core/build/index.js +5 -0
  55. package/dist/core/build/index.js.map +1 -0
  56. package/dist/core/build/markers.d.ts +34 -0
  57. package/dist/core/build/markers.js +97 -0
  58. package/dist/core/build/markers.js.map +1 -0
  59. package/dist/core/build/plan.d.ts +48 -0
  60. package/dist/core/build/plan.js +792 -0
  61. package/dist/core/build/plan.js.map +1 -0
  62. package/dist/core/build/skill.d.ts +60 -0
  63. package/dist/core/build/skill.js +275 -0
  64. package/dist/core/build/skill.js.map +1 -0
  65. package/dist/core/check/drift.d.ts +13 -0
  66. package/dist/core/check/drift.js +205 -0
  67. package/dist/core/check/drift.js.map +1 -0
  68. package/dist/core/check/index.d.ts +12 -0
  69. package/dist/core/check/index.js +78 -0
  70. package/dist/core/check/index.js.map +1 -0
  71. package/dist/core/check/markers.d.ts +9 -0
  72. package/dist/core/check/markers.js +220 -0
  73. package/dist/core/check/markers.js.map +1 -0
  74. package/dist/core/config/destinations.d.ts +5 -0
  75. package/dist/core/config/destinations.js +20 -0
  76. package/dist/core/config/destinations.js.map +1 -0
  77. package/dist/core/config/load.d.ts +4 -0
  78. package/dist/core/config/load.js +41 -0
  79. package/dist/core/config/load.js.map +1 -0
  80. package/dist/core/config/parse.d.ts +8 -0
  81. package/dist/core/config/parse.js +198 -0
  82. package/dist/core/config/parse.js.map +1 -0
  83. package/dist/core/config/source.d.ts +14 -0
  84. package/dist/core/config/source.js +44 -0
  85. package/dist/core/config/source.js.map +1 -0
  86. package/dist/core/config/types.d.ts +48 -0
  87. package/dist/core/config/types.js +2 -0
  88. package/dist/core/config/types.js.map +1 -0
  89. package/dist/core/config/validate.d.ts +11 -0
  90. package/dist/core/config/validate.js +351 -0
  91. package/dist/core/config/validate.js.map +1 -0
  92. package/dist/core/config/writers.d.ts +14 -0
  93. package/dist/core/config/writers.js +261 -0
  94. package/dist/core/config/writers.js.map +1 -0
  95. package/dist/core/config.d.ts +7 -0
  96. package/dist/core/config.js +8 -0
  97. package/dist/core/config.js.map +1 -0
  98. package/dist/core/discovery.d.ts +34 -0
  99. package/dist/core/discovery.js +272 -0
  100. package/dist/core/discovery.js.map +1 -0
  101. package/dist/core/edit/create.d.ts +18 -0
  102. package/dist/core/edit/create.js +190 -0
  103. package/dist/core/edit/create.js.map +1 -0
  104. package/dist/core/edit/document.d.ts +4 -0
  105. package/dist/core/edit/document.js +16 -0
  106. package/dist/core/edit/document.js.map +1 -0
  107. package/dist/core/edit/factory-yaml.d.ts +17 -0
  108. package/dist/core/edit/factory-yaml.js +211 -0
  109. package/dist/core/edit/factory-yaml.js.map +1 -0
  110. package/dist/core/edit/files.d.ts +6 -0
  111. package/dist/core/edit/files.js +47 -0
  112. package/dist/core/edit/files.js.map +1 -0
  113. package/dist/core/edit/index.d.ts +9 -0
  114. package/dist/core/edit/index.js +10 -0
  115. package/dist/core/edit/index.js.map +1 -0
  116. package/dist/core/edit/map.d.ts +24 -0
  117. package/dist/core/edit/map.js +82 -0
  118. package/dist/core/edit/map.js.map +1 -0
  119. package/dist/core/edit/names.d.ts +2 -0
  120. package/dist/core/edit/names.js +17 -0
  121. package/dist/core/edit/names.js.map +1 -0
  122. package/dist/core/edit/paths.d.ts +8 -0
  123. package/dist/core/edit/paths.js +76 -0
  124. package/dist/core/edit/paths.js.map +1 -0
  125. package/dist/core/edit/pipeline.d.ts +19 -0
  126. package/dist/core/edit/pipeline.js +146 -0
  127. package/dist/core/edit/pipeline.js.map +1 -0
  128. package/dist/core/edit/skill.d.ts +1 -0
  129. package/dist/core/edit/skill.js +10 -0
  130. package/dist/core/edit/skill.js.map +1 -0
  131. package/dist/core/factory/discovery.d.ts +9 -0
  132. package/dist/core/factory/discovery.js +139 -0
  133. package/dist/core/factory/discovery.js.map +1 -0
  134. package/dist/core/factory/factory-yaml.d.ts +16 -0
  135. package/dist/core/factory/factory-yaml.js +375 -0
  136. package/dist/core/factory/factory-yaml.js.map +1 -0
  137. package/dist/core/factory/index.d.ts +5 -0
  138. package/dist/core/factory/index.js +6 -0
  139. package/dist/core/factory/index.js.map +1 -0
  140. package/dist/core/factory/lines.d.ts +8 -0
  141. package/dist/core/factory/lines.js +11 -0
  142. package/dist/core/factory/lines.js.map +1 -0
  143. package/dist/core/factory/load.d.ts +4 -0
  144. package/dist/core/factory/load.js +81 -0
  145. package/dist/core/factory/load.js.map +1 -0
  146. package/dist/core/factory/requires.d.ts +9 -0
  147. package/dist/core/factory/requires.js +123 -0
  148. package/dist/core/factory/requires.js.map +1 -0
  149. package/dist/core/factory/types.d.ts +45 -0
  150. package/dist/core/factory/types.js +2 -0
  151. package/dist/core/factory/types.js.map +1 -0
  152. package/dist/core/factory/validate.d.ts +41 -0
  153. package/dist/core/factory/validate.js +441 -0
  154. package/dist/core/factory/validate.js.map +1 -0
  155. package/dist/core/hooks/index.d.ts +8 -0
  156. package/dist/core/hooks/index.js +15 -0
  157. package/dist/core/hooks/index.js.map +1 -0
  158. package/dist/core/hooks/script.d.ts +21 -0
  159. package/dist/core/hooks/script.js +34 -0
  160. package/dist/core/hooks/script.js.map +1 -0
  161. package/dist/core/hooks/sync.d.ts +17 -0
  162. package/dist/core/hooks/sync.js +262 -0
  163. package/dist/core/hooks/sync.js.map +1 -0
  164. package/dist/core/import/conflicts.d.ts +82 -0
  165. package/dist/core/import/conflicts.js +256 -0
  166. package/dist/core/import/conflicts.js.map +1 -0
  167. package/dist/core/import/copy.d.ts +10 -0
  168. package/dist/core/import/copy.js +76 -0
  169. package/dist/core/import/copy.js.map +1 -0
  170. package/dist/core/import/file-tree.d.ts +43 -0
  171. package/dist/core/import/file-tree.js +107 -0
  172. package/dist/core/import/file-tree.js.map +1 -0
  173. package/dist/core/import/index.d.ts +5 -0
  174. package/dist/core/import/index.js +6 -0
  175. package/dist/core/import/index.js.map +1 -0
  176. package/dist/core/import/pipeline-changes.d.ts +8 -0
  177. package/dist/core/import/pipeline-changes.js +89 -0
  178. package/dist/core/import/pipeline-changes.js.map +1 -0
  179. package/dist/core/import/run.d.ts +76 -0
  180. package/dist/core/import/run.js +258 -0
  181. package/dist/core/import/run.js.map +1 -0
  182. package/dist/core/init/gitattributes.d.ts +20 -0
  183. package/dist/core/init/gitattributes.js +89 -0
  184. package/dist/core/init/gitattributes.js.map +1 -0
  185. package/dist/core/init/index.d.ts +4 -0
  186. package/dist/core/init/index.js +5 -0
  187. package/dist/core/init/index.js.map +1 -0
  188. package/dist/core/init/name.d.ts +1 -0
  189. package/dist/core/init/name.js +4 -0
  190. package/dist/core/init/name.js.map +1 -0
  191. package/dist/core/init/run.d.ts +51 -0
  192. package/dist/core/init/run.js +261 -0
  193. package/dist/core/init/run.js.map +1 -0
  194. package/dist/core/init/targets.d.ts +17 -0
  195. package/dist/core/init/targets.js +87 -0
  196. package/dist/core/init/targets.js.map +1 -0
  197. package/dist/core/merge.d.ts +88 -0
  198. package/dist/core/merge.js +239 -0
  199. package/dist/core/merge.js.map +1 -0
  200. package/dist/core/publish/exclude.d.ts +9 -0
  201. package/dist/core/publish/exclude.js +32 -0
  202. package/dist/core/publish/exclude.js.map +1 -0
  203. package/dist/core/publish/git-target.d.ts +32 -0
  204. package/dist/core/publish/git-target.js +447 -0
  205. package/dist/core/publish/git-target.js.map +1 -0
  206. package/dist/core/publish/index.d.ts +10 -0
  207. package/dist/core/publish/index.js +11 -0
  208. package/dist/core/publish/index.js.map +1 -0
  209. package/dist/core/publish/npm-target.d.ts +15 -0
  210. package/dist/core/publish/npm-target.js +170 -0
  211. package/dist/core/publish/npm-target.js.map +1 -0
  212. package/dist/core/publish/package-json.d.ts +31 -0
  213. package/dist/core/publish/package-json.js +74 -0
  214. package/dist/core/publish/package-json.js.map +1 -0
  215. package/dist/core/publish/prepare.d.ts +24 -0
  216. package/dist/core/publish/prepare.js +93 -0
  217. package/dist/core/publish/prepare.js.map +1 -0
  218. package/dist/core/publish/provenance.d.ts +1 -0
  219. package/dist/core/publish/provenance.js +20 -0
  220. package/dist/core/publish/provenance.js.map +1 -0
  221. package/dist/core/publish/publish.d.ts +13 -0
  222. package/dist/core/publish/publish.js +130 -0
  223. package/dist/core/publish/publish.js.map +1 -0
  224. package/dist/core/publish/readme.d.ts +22 -0
  225. package/dist/core/publish/readme.js +112 -0
  226. package/dist/core/publish/readme.js.map +1 -0
  227. package/dist/core/publish/stage.d.ts +19 -0
  228. package/dist/core/publish/stage.js +333 -0
  229. package/dist/core/publish/stage.js.map +1 -0
  230. package/dist/core/publish/types.d.ts +71 -0
  231. package/dist/core/publish/types.js +2 -0
  232. package/dist/core/publish/types.js.map +1 -0
  233. package/dist/core/requires/check.d.ts +15 -0
  234. package/dist/core/requires/check.js +83 -0
  235. package/dist/core/requires/check.js.map +1 -0
  236. package/dist/core/requires/index.d.ts +4 -0
  237. package/dist/core/requires/index.js +5 -0
  238. package/dist/core/requires/index.js.map +1 -0
  239. package/dist/core/requires/inspect.d.ts +44 -0
  240. package/dist/core/requires/inspect.js +114 -0
  241. package/dist/core/requires/inspect.js.map +1 -0
  242. package/dist/core/requires/paths.d.ts +29 -0
  243. package/dist/core/requires/paths.js +83 -0
  244. package/dist/core/requires/paths.js.map +1 -0
  245. package/dist/core/requires/setup.d.ts +37 -0
  246. package/dist/core/requires/setup.js +147 -0
  247. package/dist/core/requires/setup.js.map +1 -0
  248. package/dist/core/setup.d.ts +27 -0
  249. package/dist/core/setup.js +84 -0
  250. package/dist/core/setup.js.map +1 -0
  251. package/dist/core/sources/cache.d.ts +38 -0
  252. package/dist/core/sources/cache.js +200 -0
  253. package/dist/core/sources/cache.js.map +1 -0
  254. package/dist/core/sources/containment.d.ts +21 -0
  255. package/dist/core/sources/containment.js +50 -0
  256. package/dist/core/sources/containment.js.map +1 -0
  257. package/dist/core/sources/env.d.ts +12 -0
  258. package/dist/core/sources/env.js +28 -0
  259. package/dist/core/sources/env.js.map +1 -0
  260. package/dist/core/sources/extract.d.ts +25 -0
  261. package/dist/core/sources/extract.js +676 -0
  262. package/dist/core/sources/extract.js.map +1 -0
  263. package/dist/core/sources/git-process.d.ts +26 -0
  264. package/dist/core/sources/git-process.js +51 -0
  265. package/dist/core/sources/git-process.js.map +1 -0
  266. package/dist/core/sources/git.d.ts +41 -0
  267. package/dist/core/sources/git.js +511 -0
  268. package/dist/core/sources/git.js.map +1 -0
  269. package/dist/core/sources/https.d.ts +21 -0
  270. package/dist/core/sources/https.js +208 -0
  271. package/dist/core/sources/https.js.map +1 -0
  272. package/dist/core/sources/index.d.ts +13 -0
  273. package/dist/core/sources/index.js +14 -0
  274. package/dist/core/sources/index.js.map +1 -0
  275. package/dist/core/sources/npm-cli.d.ts +19 -0
  276. package/dist/core/sources/npm-cli.js +43 -0
  277. package/dist/core/sources/npm-cli.js.map +1 -0
  278. package/dist/core/sources/npm.d.ts +29 -0
  279. package/dist/core/sources/npm.js +386 -0
  280. package/dist/core/sources/npm.js.map +1 -0
  281. package/dist/core/sources/parse.d.ts +32 -0
  282. package/dist/core/sources/parse.js +389 -0
  283. package/dist/core/sources/parse.js.map +1 -0
  284. package/dist/core/sources/path.d.ts +10 -0
  285. package/dist/core/sources/path.js +316 -0
  286. package/dist/core/sources/path.js.map +1 -0
  287. package/dist/core/sources/redact.d.ts +2 -0
  288. package/dist/core/sources/redact.js +70 -0
  289. package/dist/core/sources/redact.js.map +1 -0
  290. package/dist/core/sources/resolve.d.ts +9 -0
  291. package/dist/core/sources/resolve.js +29 -0
  292. package/dist/core/sources/resolve.js.map +1 -0
  293. package/dist/core/sources/types.d.ts +86 -0
  294. package/dist/core/sources/types.js +2 -0
  295. package/dist/core/sources/types.js.map +1 -0
  296. package/dist/core/sources/validate.d.ts +9 -0
  297. package/dist/core/sources/validate.js +111 -0
  298. package/dist/core/sources/validate.js.map +1 -0
  299. package/dist/core/summary.d.ts +77 -0
  300. package/dist/core/summary.js +405 -0
  301. package/dist/core/summary.js.map +1 -0
  302. package/dist/core/update/clashes.d.ts +63 -0
  303. package/dist/core/update/clashes.js +192 -0
  304. package/dist/core/update/clashes.js.map +1 -0
  305. package/dist/core/update/detach.d.ts +21 -0
  306. package/dist/core/update/detach.js +38 -0
  307. package/dist/core/update/detach.js.map +1 -0
  308. package/dist/core/update/diff.d.ts +58 -0
  309. package/dist/core/update/diff.js +180 -0
  310. package/dist/core/update/diff.js.map +1 -0
  311. package/dist/core/update/fetch.d.ts +34 -0
  312. package/dist/core/update/fetch.js +73 -0
  313. package/dist/core/update/fetch.js.map +1 -0
  314. package/dist/core/update/index.d.ts +6 -0
  315. package/dist/core/update/index.js +7 -0
  316. package/dist/core/update/index.js.map +1 -0
  317. package/dist/core/update/restore.d.ts +20 -0
  318. package/dist/core/update/restore.js +195 -0
  319. package/dist/core/update/restore.js.map +1 -0
  320. package/dist/core/update/run.d.ts +113 -0
  321. package/dist/core/update/run.js +1132 -0
  322. package/dist/core/update/run.js.map +1 -0
  323. package/dist/core/update/select.d.ts +39 -0
  324. package/dist/core/update/select.js +157 -0
  325. package/dist/core/update/select.js.map +1 -0
  326. package/dist/core/update/spelling.d.ts +51 -0
  327. package/dist/core/update/spelling.js +185 -0
  328. package/dist/core/update/spelling.js.map +1 -0
  329. package/dist/core/update/trees.d.ts +24 -0
  330. package/dist/core/update/trees.js +72 -0
  331. package/dist/core/update/trees.js.map +1 -0
  332. package/dist/errors.d.ts +29 -0
  333. package/dist/errors.js +24 -0
  334. package/dist/errors.js.map +1 -0
  335. package/dist/help.d.ts +46 -0
  336. package/dist/help.js +103 -0
  337. package/dist/help.js.map +1 -0
  338. package/dist/input.d.ts +25 -0
  339. package/dist/input.js +173 -0
  340. package/dist/input.js.map +1 -0
  341. package/dist/output.d.ts +21 -0
  342. package/dist/output.js +37 -0
  343. package/dist/output.js.map +1 -0
  344. package/dist/util/frontmatter.d.ts +12 -0
  345. package/dist/util/frontmatter.js +58 -0
  346. package/dist/util/frontmatter.js.map +1 -0
  347. package/dist/util/fs.d.ts +32 -0
  348. package/dist/util/fs.js +126 -0
  349. package/dist/util/fs.js.map +1 -0
  350. package/dist/util/git-names.d.ts +8 -0
  351. package/dist/util/git-names.js +25 -0
  352. package/dist/util/git-names.js.map +1 -0
  353. package/dist/util/git.d.ts +12 -0
  354. package/dist/util/git.js +33 -0
  355. package/dist/util/git.js.map +1 -0
  356. package/dist/util/suggest.d.ts +6 -0
  357. package/dist/util/suggest.js +48 -0
  358. package/dist/util/suggest.js.map +1 -0
  359. package/dist/util/text.d.ts +8 -0
  360. package/dist/util/text.js +19 -0
  361. package/dist/util/text.js.map +1 -0
  362. package/dist/util/version.d.ts +7 -0
  363. package/dist/util/version.js +13 -0
  364. package/dist/util/version.js.map +1 -0
  365. package/dist/util/yaml.d.ts +30 -0
  366. package/dist/util/yaml.js +201 -0
  367. package/dist/util/yaml.js.map +1 -0
  368. package/package.json +50 -3
  369. package/resources/metafab-skill/SKILL.md +99 -0
@@ -0,0 +1,316 @@
1
+ import { lstat, mkdir, mkdtemp, readdir, readlink, realpath, rm, stat, symlink } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import path from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ import { ExitCode, MetafabError } from "../../errors.js";
6
+ import { copyFileWithMode } from "../../util/fs.js";
7
+ import { isInsideAbsolute } from "./containment.js";
8
+ import { MAX_FAB_ENTRIES, MAX_FAB_FILE_SIZE, MAX_FAB_TOTAL_SIZE } from "./extract.js";
9
+ import { redact, stripSourceCredentials } from "./redact.js";
10
+ import { dropPayloadFiles, validateFab } from "./validate.js";
11
+ function fetchError(message, cause) {
12
+ return new MetafabError(redact(message), {
13
+ exitCode: ExitCode.FetchFailed,
14
+ code: "fetch-failed",
15
+ cause,
16
+ });
17
+ }
18
+ function invalidFab(sourceLabel, problems) {
19
+ return new MetafabError(`Invalid fab from ${redact(sourceLabel)}`, {
20
+ exitCode: ExitCode.InvalidFab,
21
+ code: "invalid-fab",
22
+ problems,
23
+ });
24
+ }
25
+ function problemFile(sourceLabel, relativePath) {
26
+ return `${redact(sourceLabel).replace(/\/+$/, "")}/.factory/${relativePath}`;
27
+ }
28
+ /**
29
+ * The cleanup hook for a fetch that copied a fab into a temporary directory.
30
+ * Best effort: a failed removal never throws, so it cannot hide the caller's
31
+ * own error or result.
32
+ */
33
+ function tempCleanup(directory) {
34
+ return async () => {
35
+ try {
36
+ await rm(directory, { recursive: true, force: true });
37
+ }
38
+ catch {
39
+ // Nothing to report: the directory is temporary either way.
40
+ }
41
+ };
42
+ }
43
+ /**
44
+ * A path source that turns out to be a bare Git repository cannot be read as a
45
+ * working tree, but it is exactly what `git+file://` imports. Recognise the
46
+ * markers Git itself needs so the error can say which form to use.
47
+ */
48
+ async function isBareRepository(directory) {
49
+ try {
50
+ const head = await stat(path.join(directory, "HEAD"));
51
+ if (!head.isFile())
52
+ return false;
53
+ const objects = await stat(path.join(directory, "objects"));
54
+ const refs = await stat(path.join(directory, "refs"));
55
+ return objects.isDirectory() && refs.isDirectory();
56
+ }
57
+ catch {
58
+ return false;
59
+ }
60
+ }
61
+ export async function locateFactoryDir(specPath) {
62
+ const candidate = path.basename(specPath) === ".factory" ? specPath : path.join(specPath, ".factory");
63
+ let entry;
64
+ try {
65
+ entry = await lstat(candidate);
66
+ }
67
+ catch {
68
+ if (await isBareRepository(specPath)) {
69
+ throw fetchError(`Cannot read local fab "${specPath}": it is a bare Git repository. Import it as git+${pathToFileURL(specPath).href}`);
70
+ }
71
+ throw fetchError(`Cannot read local fab "${specPath}": the .factory directory does not exist`);
72
+ }
73
+ if (entry.isSymbolicLink()) {
74
+ throw invalidFab(specPath, [
75
+ {
76
+ level: "error",
77
+ file: problemFile(specPath, ""),
78
+ line: 1,
79
+ message: "links are not allowed in a fab",
80
+ },
81
+ ]);
82
+ }
83
+ if (!entry.isDirectory()) {
84
+ throw fetchError(`Cannot read local fab "${specPath}": ${candidate} is not a directory`);
85
+ }
86
+ return candidate;
87
+ }
88
+ async function targetExists(target) {
89
+ try {
90
+ await stat(target);
91
+ return true;
92
+ }
93
+ catch {
94
+ return false;
95
+ }
96
+ }
97
+ async function linkTargetType(target) {
98
+ try {
99
+ return (await stat(target)).isDirectory() ? "dir" : "file";
100
+ }
101
+ catch {
102
+ return "file";
103
+ }
104
+ }
105
+ async function createSymlink(factoryDir, link, type) {
106
+ const destination = path.join(factoryDir, ...link.path.split("/"));
107
+ await mkdir(path.dirname(destination), { recursive: true });
108
+ await rm(destination, { recursive: true, force: true });
109
+ await symlink(link.target, destination, type);
110
+ }
111
+ async function createLinks(factoryDir, sourceLabel, links) {
112
+ const problems = [];
113
+ const failed = new Set();
114
+ let pending = links;
115
+ while (pending.length > 0) {
116
+ const remaining = [];
117
+ let progress = false;
118
+ for (const link of pending) {
119
+ const destination = path.join(factoryDir, ...link.path.split("/"));
120
+ const absoluteTarget = path.resolve(path.dirname(destination), link.target);
121
+ if (!(await targetExists(absoluteTarget))) {
122
+ remaining.push(link);
123
+ continue;
124
+ }
125
+ try {
126
+ await createSymlink(factoryDir, link, await linkTargetType(absoluteTarget));
127
+ progress = true;
128
+ }
129
+ catch (error) {
130
+ problems.push({
131
+ level: "error",
132
+ file: problemFile(sourceLabel, link.path),
133
+ line: 1,
134
+ message: `links could not be created: ${error instanceof Error ? error.message : String(error)}`,
135
+ });
136
+ failed.add(link.path);
137
+ progress = true;
138
+ }
139
+ }
140
+ if (!progress) {
141
+ for (const link of remaining) {
142
+ try {
143
+ await createSymlink(factoryDir, link, "file");
144
+ }
145
+ catch (error) {
146
+ problems.push({
147
+ level: "error",
148
+ file: problemFile(sourceLabel, link.path),
149
+ line: 1,
150
+ message: `links could not be created: ${error instanceof Error ? error.message : String(error)}`,
151
+ });
152
+ failed.add(link.path);
153
+ }
154
+ }
155
+ break;
156
+ }
157
+ pending = remaining;
158
+ }
159
+ return { problems, failed };
160
+ }
161
+ async function verifyLinks(factoryDir, sourceLabel, links) {
162
+ const problems = [];
163
+ const root = await realpath(factoryDir).catch(() => path.resolve(factoryDir));
164
+ for (const link of links) {
165
+ let resolved;
166
+ try {
167
+ resolved = await realpath(path.join(factoryDir, ...link.path.split("/")));
168
+ }
169
+ catch {
170
+ problems.push({
171
+ level: "error",
172
+ file: problemFile(sourceLabel, link.path),
173
+ line: 1,
174
+ message: "links whose target does not exist are not allowed",
175
+ });
176
+ continue;
177
+ }
178
+ if (!isInsideAbsolute(root, resolved)) {
179
+ problems.push({
180
+ level: "error",
181
+ file: problemFile(sourceLabel, link.path),
182
+ line: 1,
183
+ message: "links that point outside .factory are not allowed",
184
+ });
185
+ }
186
+ }
187
+ return problems;
188
+ }
189
+ async function copyFactory(sourceDir, destination, sourceLabel, options) {
190
+ const maxEntries = options.maxEntries ?? MAX_FAB_ENTRIES;
191
+ const maxTotalSize = options.maxTotalSize ?? MAX_FAB_TOTAL_SIZE;
192
+ const problems = [];
193
+ const links = [];
194
+ const factoryDir = path.join(destination, ".factory");
195
+ const factoryRoot = path.resolve(sourceDir);
196
+ let entries = 0;
197
+ let totalSize = 0;
198
+ let stopped = false;
199
+ await mkdir(factoryDir, { recursive: true });
200
+ // Every file, directory and link is one entry, the same things an archive
201
+ // counts, so the cap behaves the same for a path and for a tarball.
202
+ function countEntry(relativePath) {
203
+ entries += 1;
204
+ if (entries <= maxEntries)
205
+ return true;
206
+ problems.push({
207
+ level: "error",
208
+ file: problemFile(sourceLabel, relativePath),
209
+ line: 1,
210
+ message: `fabs with more than ${maxEntries} files, directories and links are not allowed`,
211
+ });
212
+ stopped = true;
213
+ return false;
214
+ }
215
+ async function walk(directory, prefix) {
216
+ if (stopped)
217
+ return;
218
+ const names = await readdir(directory);
219
+ names.sort();
220
+ for (const name of names) {
221
+ if (stopped)
222
+ return;
223
+ const absolute = path.join(directory, name);
224
+ const relativePath = prefix === "" ? name : `${prefix}/${name}`;
225
+ const entry = await lstat(absolute);
226
+ if (entry.isSymbolicLink()) {
227
+ if (!countEntry(relativePath))
228
+ return;
229
+ const target = await readlink(absolute);
230
+ const resolved = path.resolve(path.dirname(absolute), target);
231
+ if (path.isAbsolute(target) || !isInsideAbsolute(factoryRoot, resolved)) {
232
+ problems.push({
233
+ level: "error",
234
+ file: problemFile(sourceLabel, relativePath),
235
+ line: 1,
236
+ message: "links that point outside .factory are not allowed",
237
+ });
238
+ continue;
239
+ }
240
+ links.push({ path: relativePath, target });
241
+ continue;
242
+ }
243
+ if (entry.isDirectory()) {
244
+ if (!countEntry(relativePath))
245
+ return;
246
+ await mkdir(path.join(factoryDir, ...relativePath.split("/")), { recursive: true });
247
+ await walk(absolute, relativePath);
248
+ continue;
249
+ }
250
+ if (!entry.isFile()) {
251
+ problems.push({
252
+ level: "error",
253
+ file: problemFile(sourceLabel, relativePath),
254
+ line: 1,
255
+ message: "device files and FIFOs are not allowed in a fab",
256
+ });
257
+ continue;
258
+ }
259
+ if (!countEntry(relativePath))
260
+ return;
261
+ if (entry.size > MAX_FAB_FILE_SIZE) {
262
+ problems.push({
263
+ level: "error",
264
+ file: problemFile(sourceLabel, relativePath),
265
+ line: 1,
266
+ message: `files larger than ${MAX_FAB_FILE_SIZE} bytes are not allowed in a fab`,
267
+ });
268
+ continue;
269
+ }
270
+ totalSize += entry.size;
271
+ if (totalSize > maxTotalSize) {
272
+ problems.push({
273
+ level: "error",
274
+ file: problemFile(sourceLabel, relativePath),
275
+ line: 1,
276
+ message: `files larger than ${maxTotalSize} bytes in total are not allowed in a fab`,
277
+ });
278
+ stopped = true;
279
+ return;
280
+ }
281
+ await copyFileWithMode(absolute, path.join(factoryDir, ...relativePath.split("/")));
282
+ }
283
+ }
284
+ await walk(sourceDir, "");
285
+ if (problems.length === 0) {
286
+ const created = await createLinks(factoryDir, sourceLabel, links);
287
+ problems.push(...created.problems);
288
+ // A link whose creation already failed keeps its creation message: the
289
+ // realpath check would only repeat it as "target does not exist".
290
+ const stillValid = links.filter((link) => !created.failed.has(link.path));
291
+ problems.push(...(await verifyLinks(factoryDir, sourceLabel, stillValid)));
292
+ }
293
+ if (problems.length > 0)
294
+ throw invalidFab(sourceLabel, problems);
295
+ }
296
+ export async function fetchPath(source, options = {}) {
297
+ const sourceLabel = source.spec.source;
298
+ const factoryDir = await locateFactoryDir(source.spec.path);
299
+ const destination = await mkdtemp(path.join(tmpdir(), "metafab-path-"));
300
+ try {
301
+ await copyFactory(factoryDir, destination, sourceLabel, options);
302
+ await dropPayloadFiles(destination);
303
+ await validateFab(destination, { sourceLabel });
304
+ }
305
+ catch (error) {
306
+ await rm(destination, { recursive: true, force: true });
307
+ throw error;
308
+ }
309
+ return {
310
+ factoryDir: path.join(destination, ".factory"),
311
+ upstream: { kind: "unversioned", source: stripSourceCredentials(sourceLabel) },
312
+ versioned: false,
313
+ cleanup: tempCleanup(destination),
314
+ };
315
+ }
316
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/core/sources/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACzG,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,e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AAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAoB,EACpB,OAAO,GAAgB,EAAE;IAEzB,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;IACvC,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IAExE,IAAI,CAAC;QACH,MAAM,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACjE,MAAM,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACpC,MAAM,WAAW,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC;QAC9C,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,EAAE;QAC9E,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC;KAClC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function stripSourceCredentials(source: string): string;
2
+ export declare function redact(value: string): string;
@@ -0,0 +1,70 @@
1
+ const URL_USERINFO = /\b([A-Za-z][A-Za-z0-9+.-]*:\/\/)[^/\s@]+@/g;
2
+ const URL_QUERY = /([A-Za-z][A-Za-z0-9+.-]*:\/\/[^\s?#]+)\?[^\s#'"]*/g;
3
+ const URL_FRAGMENT_TOKEN = /([A-Za-z][A-Za-z0-9+.-]*:\/\/[^\s#]+)#[^\s'"]*(?:token|signature|secret|auth|key|credential|access)[^\s'"]*/gi;
4
+ const AUTH_SETTING = /(_authToken|_auth|password)\s*[=:]\s*\S+/gi;
5
+ const AUTH_HEADER = /\b(Bearer|Basic)\s+[A-Za-z0-9._~+/-]+=*/gi;
6
+ const SOURCE_SCHEME = /^([A-Za-z][A-Za-z0-9+.-]*):\/\//;
7
+ const HTTP_PROTOCOLS = new Set(["http:", "https:", "git+http:", "git+https:"]);
8
+ function isHttpProtocol(protocol) {
9
+ return HTTP_PROTOCOLS.has(protocol.toLowerCase());
10
+ }
11
+ // Where the authority (the `host` part) ends: the first `/`, `?` or `#` after
12
+ // the scheme. Everything before it is userinfo plus host.
13
+ function authorityEnd(value, start) {
14
+ let end = value.length;
15
+ for (const delimiter of ["/", "?", "#"]) {
16
+ const index = value.indexOf(delimiter, start);
17
+ if (index !== -1 && index < end)
18
+ end = index;
19
+ }
20
+ return end;
21
+ }
22
+ // A URL that is safe to write down: no password or token in the userinfo, and
23
+ // no query string on an HTTP(S) URL, because a signed query is a credential.
24
+ // A bare SSH username stays: ssh needs it to find the key, and it is not a
25
+ // secret. Everything that is not a URL (a path, `github:owner/repo`) is kept.
26
+ //
27
+ // The rewrite is done by cutting the secret out of the original text, never by
28
+ // re-serialising a parsed URL: `new URL()` normalises what it keeps, and a
29
+ // Windows `file://C:\a\b.git` would come back as `file:///C:/a/b.git`, so a
30
+ // recorded source or a mirror cache key would change for no reason. A source
31
+ // with nothing to remove is returned exactly as it was given.
32
+ export function stripSourceCredentials(source) {
33
+ const scheme = SOURCE_SCHEME.exec(source);
34
+ if (scheme === null)
35
+ return source;
36
+ const http = isHttpProtocol(`${scheme[1]}:`);
37
+ const start = scheme[0].length;
38
+ // The last `@` of the authority separates userinfo from the host.
39
+ const at = source.lastIndexOf("@", authorityEnd(source, start) - 1);
40
+ let value = source;
41
+ if (at !== -1 && at >= start) {
42
+ const colon = source.indexOf(":", start);
43
+ if (http) {
44
+ // HTTP(S) userinfo is a credential: even a bare username can be a token.
45
+ value = source.slice(0, start) + source.slice(at + 1);
46
+ }
47
+ else if (colon !== -1 && colon < at) {
48
+ // Elsewhere only the password is secret; ssh still needs the username.
49
+ // A password with no username leaves no `@` behind.
50
+ value = source.slice(0, colon) + (colon === start ? source.slice(at + 1) : source.slice(at));
51
+ }
52
+ }
53
+ if (!http)
54
+ return value;
55
+ const end = authorityEnd(value, start);
56
+ const question = value.indexOf("?", end);
57
+ const hash = value.indexOf("#", end);
58
+ if (question === -1 || (hash !== -1 && hash < question))
59
+ return value;
60
+ return value.slice(0, question) + (hash === -1 ? "" : value.slice(hash));
61
+ }
62
+ export function redact(value) {
63
+ return value
64
+ .replace(URL_USERINFO, "$1***@")
65
+ .replace(URL_QUERY, "$1?<redacted>")
66
+ .replace(URL_FRAGMENT_TOKEN, "$1#<redacted>")
67
+ .replace(AUTH_SETTING, "$1=***")
68
+ .replace(AUTH_HEADER, "$1 ***");
69
+ }
70
+ //# sourceMappingURL=redact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/core/sources/redact.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAClE,MAAM,SAAS,GAAG,oDAAoD,CAAC;AACvE,MAAM,kBAAkB,GACtB,+GAA+G,CAAC;AAClH,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAClE,MAAM,WAAW,GAAG,2CAA2C,CAAC;AAChE,MAAM,aAAa,GAAG,iCAAiC,CAAC;AAExD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;AAE/E,SAAS,cAAc,CAAC,QAAgB;IACtC,OAAO,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,8E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eAAe,CAAC;SACnC,OAAO,CAAC,kBAAkB,EAAE,eAAe,CAAC;SAC5C,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC;SAC/B,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { GitOptions, GitResolveOptions } from "./git.js";
2
+ import type { HttpsOptions } from "./https.js";
3
+ import type { NpmOptions, ResolveNpmOptions } from "./npm.js";
4
+ import type { PathOptions } from "./path.js";
5
+ import type { FetchedFab, Resolved, SourceSpec } from "./types.js";
6
+ export type SourceOptions = NpmOptions & GitOptions & HttpsOptions & PathOptions;
7
+ export type ResolveSourceOptions = ResolveNpmOptions & GitResolveOptions & HttpsOptions;
8
+ export declare function resolve(spec: SourceSpec, options?: ResolveSourceOptions): Promise<Resolved>;
9
+ export declare function fetchFab(resolved: Resolved, options?: SourceOptions): Promise<FetchedFab>;
@@ -0,0 +1,29 @@
1
+ import { fetchGit, resolveGit } from "./git.js";
2
+ import { fetchHttps } from "./https.js";
3
+ import { fetchNpm, resolveNpm } from "./npm.js";
4
+ import { fetchPath } from "./path.js";
5
+ export async function resolve(spec, options = {}) {
6
+ switch (spec.kind) {
7
+ case "npm":
8
+ return resolveNpm(spec, options);
9
+ case "git":
10
+ return resolveGit(spec, options);
11
+ case "https":
12
+ return { kind: "https", spec, versioned: false };
13
+ case "path":
14
+ return { kind: "path", spec, versioned: false };
15
+ }
16
+ }
17
+ export async function fetchFab(resolved, options = {}) {
18
+ switch (resolved.kind) {
19
+ case "npm":
20
+ return fetchNpm(resolved, options);
21
+ case "git":
22
+ return fetchGit(resolved, options);
23
+ case "https":
24
+ return fetchHttps(resolved, options);
25
+ case "path":
26
+ return fetchPath(resolved, options);
27
+ }
28
+ }
29
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../src/core/sources/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,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
6
+ type: "name";
7
+ name: string;
8
+ };
9
+ export type SourceSpec = {
10
+ kind: "npm";
11
+ name: string;
12
+ requested?: string;
13
+ } | {
14
+ kind: "git";
15
+ url: string;
16
+ source: string;
17
+ ref?: GitRef;
18
+ } | {
19
+ kind: "https";
20
+ url: string;
21
+ } | {
22
+ kind: "path";
23
+ path: string;
24
+ source: string;
25
+ };
26
+ export type NpmSourceSpec = Extract<SourceSpec, {
27
+ kind: "npm";
28
+ }>;
29
+ export type GitSourceSpec = Extract<SourceSpec, {
30
+ kind: "git";
31
+ }>;
32
+ export type HttpsSourceSpec = Extract<SourceSpec, {
33
+ kind: "https";
34
+ }>;
35
+ export type PathSourceSpec = Extract<SourceSpec, {
36
+ kind: "path";
37
+ }>;
38
+ export type Resolved = {
39
+ kind: "npm";
40
+ spec: NpmSourceSpec;
41
+ requested: string;
42
+ version: string;
43
+ tarball: string;
44
+ integrity?: string;
45
+ deprecated?: string;
46
+ /** The registry's reported unpacked size, when it gave one. */
47
+ unpackedSize?: number;
48
+ /** The registry's reported file count, when it gave one. */
49
+ fileCount?: number;
50
+ versioned: true;
51
+ } | {
52
+ kind: "git";
53
+ spec: GitSourceSpec;
54
+ commit: string;
55
+ version?: string;
56
+ requested?: string;
57
+ versioned: true;
58
+ } | {
59
+ kind: "https";
60
+ spec: HttpsSourceSpec;
61
+ versioned: false;
62
+ } | {
63
+ kind: "path";
64
+ spec: PathSourceSpec;
65
+ versioned: false;
66
+ };
67
+ export interface FetchedFab {
68
+ factoryDir: string;
69
+ upstream: UpstreamEntry;
70
+ deprecated?: string;
71
+ versioned: boolean;
72
+ /**
73
+ * Removes the temporary directory a fetch created. Only fetches that copy a
74
+ * fab into a `mkdtemp` directory set it: Git and npm return cache paths, which
75
+ * stay. Best effort and never throws, so it cannot hide the caller's error.
76
+ */
77
+ cleanup?: () => Promise<void>;
78
+ }
79
+ export interface ValidateFabOptions {
80
+ sourceLabel: string;
81
+ packageJson?: unknown;
82
+ }
83
+ export interface ValidatedFab {
84
+ factoryDir: string;
85
+ format: 1;
86
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/sources/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { ValidateFabOptions, ValidatedFab } from "./types.js";
2
+ /**
3
+ * Remove the files that never travel in a fab payload. This mutates `root`, so
4
+ * it is for the temporary or cache copy that a fetcher owns. `validateFab`
5
+ * never changes the tree it reads: a caller can validate a repository by
6
+ * mistake and keep it intact.
7
+ */
8
+ export declare function dropPayloadFiles(root: string): Promise<void>;
9
+ export declare function validateFab(root: string, options: ValidateFabOptions): Promise<ValidatedFab>;