@intentius/chant-lexicon-terraform 0.102.0 → 0.104.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 (270) hide show
  1. package/dist/__fixtures__/terragrunt/affected-cases.d.ts +23 -0
  2. package/dist/__fixtures__/terragrunt/affected-cases.d.ts.map +1 -0
  3. package/dist/__fixtures__/terragrunt/record.d.ts +17 -0
  4. package/dist/__fixtures__/terragrunt/record.d.ts.map +1 -0
  5. package/dist/change-set.d.ts +67 -0
  6. package/dist/change-set.d.ts.map +1 -0
  7. package/dist/changed-roots.d.ts +30 -0
  8. package/dist/changed-roots.d.ts.map +1 -0
  9. package/dist/commands.d.ts +26 -0
  10. package/dist/commands.d.ts.map +1 -0
  11. package/dist/components/capability-plugin.d.ts +54 -0
  12. package/dist/components/capability-plugin.d.ts.map +1 -0
  13. package/dist/composites/terraform-pin-rollout-op.d.ts +44 -0
  14. package/dist/composites/terraform-pin-rollout-op.d.ts.map +1 -0
  15. package/dist/hcl/descend.d.ts +1 -1
  16. package/dist/hcl/descend.d.ts.map +1 -1
  17. package/dist/hcl/edges.d.ts +2 -2
  18. package/dist/hcl/edges.d.ts.map +1 -1
  19. package/dist/hcl/parse.d.ts +29 -1
  20. package/dist/hcl/parse.d.ts.map +1 -1
  21. package/dist/hcl/roots.d.ts +1 -1
  22. package/dist/hcl/roots.d.ts.map +1 -1
  23. package/dist/hcl/suppressions.d.ts.map +1 -1
  24. package/dist/index.d.ts +4 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/integrity.json +13 -4
  27. package/dist/lint/audit-catalog.d.ts.map +1 -1
  28. package/dist/lint/post-synth/index.d.ts.map +1 -1
  29. package/dist/lint/post-synth/module-source.d.ts +27 -1
  30. package/dist/lint/post-synth/module-source.d.ts.map +1 -1
  31. package/dist/lint/post-synth/terragrunt.d.ts +37 -0
  32. package/dist/lint/post-synth/terragrunt.d.ts.map +1 -0
  33. package/dist/lint/post-synth/tf002.d.ts +3 -1
  34. package/dist/lint/post-synth/tf002.d.ts.map +1 -1
  35. package/dist/lint/post-synth/tf038.d.ts +22 -0
  36. package/dist/lint/post-synth/tf038.d.ts.map +1 -0
  37. package/dist/lint/post-synth/tf039.d.ts +23 -0
  38. package/dist/lint/post-synth/tf039.d.ts.map +1 -0
  39. package/dist/lint/post-synth/tf040.d.ts +30 -0
  40. package/dist/lint/post-synth/tf040.d.ts.map +1 -0
  41. package/dist/lint/post-synth/tf041.d.ts +20 -0
  42. package/dist/lint/post-synth/tf041.d.ts.map +1 -0
  43. package/dist/lint/post-synth/tf042.d.ts +18 -0
  44. package/dist/lint/post-synth/tf042.d.ts.map +1 -0
  45. package/dist/lint/post-synth/tf043.d.ts +17 -0
  46. package/dist/lint/post-synth/tf043.d.ts.map +1 -0
  47. package/dist/lint/post-synth/tf044.d.ts +17 -0
  48. package/dist/lint/post-synth/tf044.d.ts.map +1 -0
  49. package/dist/lint/post-synth/tf045.d.ts +22 -0
  50. package/dist/lint/post-synth/tf045.d.ts.map +1 -0
  51. package/dist/manifest.json +1 -1
  52. package/dist/okf/index.md +8 -0
  53. package/dist/okf/rules/TF038.md +11 -0
  54. package/dist/okf/rules/TF039.md +11 -0
  55. package/dist/okf/rules/TF040.md +11 -0
  56. package/dist/okf/rules/TF041.md +11 -0
  57. package/dist/okf/rules/TF042.md +11 -0
  58. package/dist/okf/rules/TF043.md +11 -0
  59. package/dist/okf/rules/TF044.md +11 -0
  60. package/dist/okf/rules/TF045.md +11 -0
  61. package/dist/op/activities/index.d.ts +4 -0
  62. package/dist/op/activities/index.d.ts.map +1 -1
  63. package/dist/op/activities/pin-rollout.d.ts +46 -0
  64. package/dist/op/activities/pin-rollout.d.ts.map +1 -0
  65. package/dist/op/activities/terraform.d.ts +24 -50
  66. package/dist/op/activities/terraform.d.ts.map +1 -1
  67. package/dist/op/activity-contracts.d.ts +48 -0
  68. package/dist/op/activity-contracts.d.ts.map +1 -1
  69. package/dist/op/builders.d.ts +9 -0
  70. package/dist/op/builders.d.ts.map +1 -1
  71. package/dist/pin/edit-ts.d.ts +21 -0
  72. package/dist/pin/edit-ts.d.ts.map +1 -0
  73. package/dist/pin/edit.d.ts +52 -0
  74. package/dist/pin/edit.d.ts.map +1 -0
  75. package/dist/pin/forge.d.ts +39 -0
  76. package/dist/pin/forge.d.ts.map +1 -0
  77. package/dist/pin/index.d.ts +22 -0
  78. package/dist/pin/index.d.ts.map +1 -0
  79. package/dist/pin/rollout.d.ts +116 -0
  80. package/dist/pin/rollout.d.ts.map +1 -0
  81. package/dist/pin/scan.d.ts +54 -0
  82. package/dist/pin/scan.d.ts.map +1 -0
  83. package/dist/pin/source.d.ts +93 -0
  84. package/dist/pin/source.d.ts.map +1 -0
  85. package/dist/pin/waves.d.ts +66 -0
  86. package/dist/pin/waves.d.ts.map +1 -0
  87. package/dist/plan-digest.d.ts +59 -0
  88. package/dist/plan-digest.d.ts.map +1 -0
  89. package/dist/plugin.d.ts.map +1 -1
  90. package/dist/rules/module-source.ts +56 -1
  91. package/dist/rules/terragrunt.ts +76 -0
  92. package/dist/rules/tf002.ts +1 -1
  93. package/dist/rules/tf038.ts +71 -0
  94. package/dist/rules/tf039.ts +64 -0
  95. package/dist/rules/tf040.ts +76 -0
  96. package/dist/rules/tf041.ts +56 -0
  97. package/dist/rules/tf042.ts +42 -0
  98. package/dist/rules/tf043.ts +49 -0
  99. package/dist/rules/tf044.ts +51 -0
  100. package/dist/rules/tf045.ts +47 -0
  101. package/dist/terragrunt/affected.d.ts +119 -0
  102. package/dist/terragrunt/affected.d.ts.map +1 -0
  103. package/dist/terragrunt/index.d.ts +11 -0
  104. package/dist/terragrunt/index.d.ts.map +1 -0
  105. package/dist/terragrunt/mocks.d.ts +147 -0
  106. package/dist/terragrunt/mocks.d.ts.map +1 -0
  107. package/dist/terragrunt/run.d.ts +130 -0
  108. package/dist/terragrunt/run.d.ts.map +1 -0
  109. package/dist/terragrunt/units.d.ts +103 -0
  110. package/dist/terragrunt/units.d.ts.map +1 -0
  111. package/dist/terragrunt/wave.d.ts +89 -0
  112. package/dist/terragrunt/wave.d.ts.map +1 -0
  113. package/package.json +12 -2
  114. package/src/__fixtures__/change-set/choudoufu-set-plan.change-set.golden.json +95 -0
  115. package/src/__fixtures__/change-set/choudoufu-set-plan.json +76 -0
  116. package/src/__fixtures__/change-set/choudoufu.part.golden.json +173 -0
  117. package/src/__fixtures__/change-set/choudoufu.plan.json +610 -0
  118. package/src/__fixtures__/change-set/terraform.import-forget.plan.json +81 -0
  119. package/src/__fixtures__/change-set/terraform.part.golden.json +173 -0
  120. package/src/__fixtures__/change-set/terraform.plan.json +589 -0
  121. package/src/__fixtures__/change-set/tofu.part.golden.json +173 -0
  122. package/src/__fixtures__/change-set/tofu.plan.json +588 -0
  123. package/src/__fixtures__/change-set/v1.tf.txt +21 -0
  124. package/src/__fixtures__/change-set/v2-module-app.tf.txt +4 -0
  125. package/src/__fixtures__/change-set/v2.tf.txt +21 -0
  126. package/src/__fixtures__/pin/choudoufu-live-waves-n5.json +83 -0
  127. package/src/__fixtures__/pin/largeset-oci-n5/apply-order.txt +5 -0
  128. package/src/__fixtures__/pin/largeset-oci-n5/estates/e01/estate.chdf.hcl +6 -0
  129. package/src/__fixtures__/pin/largeset-oci-n5/estates/e01/main.tf +33 -0
  130. package/src/__fixtures__/pin/largeset-oci-n5/estates/e02/estate.chdf.hcl +6 -0
  131. package/src/__fixtures__/pin/largeset-oci-n5/estates/e02/main.tf +45 -0
  132. package/src/__fixtures__/pin/largeset-oci-n5/estates/e03/estate.chdf.hcl +6 -0
  133. package/src/__fixtures__/pin/largeset-oci-n5/estates/e03/main.tf +47 -0
  134. package/src/__fixtures__/pin/largeset-oci-n5/estates/e04/estate.chdf.hcl +6 -0
  135. package/src/__fixtures__/pin/largeset-oci-n5/estates/e04/main.tf +31 -0
  136. package/src/__fixtures__/pin/largeset-oci-n5/estates/e05/estate.chdf.hcl +6 -0
  137. package/src/__fixtures__/pin/largeset-oci-n5/estates/e05/main.tf +27 -0
  138. package/src/__fixtures__/pin/largeset-oci-n5/fixture.json +77 -0
  139. package/src/__fixtures__/plan-summary/largeset-n5-bump.json +2071 -0
  140. package/src/__fixtures__/plan-summary/largeset-n5.summary.golden.json +95 -0
  141. package/src/__fixtures__/plan-summary/largeset-n5.summary.golden.md +22 -0
  142. package/src/__fixtures__/plan-summary/largeset-n5.summary.golden.txt +12 -0
  143. package/src/__fixtures__/terragrunt/affected/catalog/units/web/terragrunt.hcl +3 -0
  144. package/src/__fixtures__/terragrunt/affected/gitignore +3 -0
  145. package/src/__fixtures__/terragrunt/affected/live/dev/app/terragrunt.hcl +3 -0
  146. package/src/__fixtures__/terragrunt/affected/live/dev/vpc/terragrunt.hcl +3 -0
  147. package/src/__fixtures__/terragrunt/affected/live/prod/app/terragrunt.hcl +3 -0
  148. package/src/__fixtures__/terragrunt/affected/live/stg/terragrunt.stack.hcl +5 -0
  149. package/src/__fixtures__/terragrunt/affected/modules/app/main.tf +6 -0
  150. package/src/__fixtures__/terragrunt/affected/modules/app/policy.json +1 -0
  151. package/src/__fixtures__/terragrunt/affected/modules/net/main.tf +2 -0
  152. package/src/__fixtures__/terragrunt/affected/modules/thing/main.tf +3 -0
  153. package/src/__fixtures__/terragrunt/affected/root.hcl +5 -0
  154. package/src/__fixtures__/terragrunt/affected-cases.ts +126 -0
  155. package/src/__fixtures__/terragrunt/five-units/catalog/units/thing/terragrunt.hcl +3 -0
  156. package/src/__fixtures__/terragrunt/five-units/live/dev/app/terragrunt.hcl +13 -0
  157. package/src/__fixtures__/terragrunt/five-units/live/dev/db/terragrunt.hcl +8 -0
  158. package/src/__fixtures__/terragrunt/five-units/live/dev/vpc/terragrunt.hcl +3 -0
  159. package/src/__fixtures__/terragrunt/five-units/live/prod/app/terragrunt.hcl +8 -0
  160. package/src/__fixtures__/terragrunt/five-units/live/prod/vpc/terragrunt.hcl +3 -0
  161. package/src/__fixtures__/terragrunt/five-units/modules/thing/main.tf +7 -0
  162. package/src/__fixtures__/terragrunt/five-units/root.hcl +5 -0
  163. package/src/__fixtures__/terragrunt/record.ts +56 -0
  164. package/src/__fixtures__/terragrunt/recorded/affected-find.json +50 -0
  165. package/src/__fixtures__/terragrunt/recorded/failed-plan-report.json +36 -0
  166. package/src/__fixtures__/terragrunt/recorded/find.json +67 -0
  167. package/src/__fixtures__/terragrunt/recorded/version.txt +1 -0
  168. package/src/__fixtures__/terragrunt/recorded/wave-1/apply-report.json +22 -0
  169. package/src/__fixtures__/terragrunt/recorded/wave-1/json/live/dev/vpc/tfplan.json +1 -0
  170. package/src/__fixtures__/terragrunt/recorded/wave-1/json/live/prod/vpc/tfplan.json +1 -0
  171. package/src/__fixtures__/terragrunt/recorded/wave-1/plan-report.json +22 -0
  172. package/src/__fixtures__/terragrunt/recorded/wave-2/json/live/dev/db/tfplan.json +1 -0
  173. package/src/__fixtures__/terragrunt/recorded/wave-2/json/live/prod/app/tfplan.json +1 -0
  174. package/src/__fixtures__/terragrunt/recorded/wave-2/plan-report.json +22 -0
  175. package/src/change-set-combined-run.test.ts +156 -0
  176. package/src/change-set.test.ts +151 -0
  177. package/src/change-set.ts +273 -0
  178. package/src/changed-roots.test.ts +58 -0
  179. package/src/changed-roots.ts +102 -0
  180. package/src/commands.ts +112 -0
  181. package/src/components/capability-plugin.test.ts +91 -0
  182. package/src/components/capability-plugin.ts +131 -0
  183. package/src/components/pr-loop.tofu.test.ts +244 -0
  184. package/src/composites/terraform-pin-rollout-op.test.ts +69 -0
  185. package/src/composites/terraform-pin-rollout-op.ts +60 -0
  186. package/src/hcl/descend.ts +1 -1
  187. package/src/hcl/edges.ts +2 -2
  188. package/src/hcl/parse.test.ts +25 -0
  189. package/src/hcl/parse.ts +91 -6
  190. package/src/hcl/roots.ts +1 -1
  191. package/src/hcl/suppressions.ts +8 -2
  192. package/src/index.ts +18 -0
  193. package/src/lint/audit-catalog.ts +82 -0
  194. package/src/lint/audit.test.ts +3 -1
  195. package/src/lint/post-synth/fixtures/TF038/positive.tf +3 -0
  196. package/src/lint/post-synth/fixtures/TF039/positive.tf +4 -0
  197. package/src/lint/post-synth/fixtures/TF041/negative/terragrunt.hcl +12 -0
  198. package/src/lint/post-synth/fixtures/TF041/positive/terragrunt.hcl +7 -0
  199. package/src/lint/post-synth/fixtures/TF041/positive-apply/terragrunt.hcl +8 -0
  200. package/src/lint/post-synth/fixtures/TF042/negative/terragrunt.hcl +13 -0
  201. package/src/lint/post-synth/fixtures/TF042/positive/terragrunt.hcl +9 -0
  202. package/src/lint/post-synth/fixtures/TF043/negative/terragrunt.hcl +3 -0
  203. package/src/lint/post-synth/fixtures/TF043/negative-other/terragrunt.hcl +3 -0
  204. package/src/lint/post-synth/fixtures/TF043/positive-git/terragrunt.hcl +3 -0
  205. package/src/lint/post-synth/fixtures/TF043/positive-oci/terragrunt.hcl +3 -0
  206. package/src/lint/post-synth/fixtures/TF043/positive-tfr/terragrunt.hcl +3 -0
  207. package/src/lint/post-synth/fixtures/TF044/negative/terragrunt.hcl +9 -0
  208. package/src/lint/post-synth/fixtures/TF044/positive/terragrunt.hcl +7 -0
  209. package/src/lint/post-synth/fixtures/TF044/positive-generate/terragrunt.hcl +9 -0
  210. package/src/lint/post-synth/fixtures/TF045/negative/root.hcl +1 -0
  211. package/src/lint/post-synth/fixtures/TF045/negative/terragrunt.hcl +3 -0
  212. package/src/lint/post-synth/fixtures/TF045/positive/root.hcl +9 -0
  213. package/src/lint/post-synth/fixtures/TF045/positive/terragrunt.hcl +3 -0
  214. package/src/lint/post-synth/fixtures/TF045/unit-only/terragrunt.hcl +3 -0
  215. package/src/lint/post-synth/index.ts +16 -0
  216. package/src/lint/post-synth/module-source.test.ts +42 -1
  217. package/src/lint/post-synth/module-source.ts +56 -1
  218. package/src/lint/post-synth/terragrunt.ts +76 -0
  219. package/src/lint/post-synth/tf002.ts +1 -1
  220. package/src/lint/post-synth/tf038.test.ts +51 -0
  221. package/src/lint/post-synth/tf038.ts +71 -0
  222. package/src/lint/post-synth/tf039.test.ts +40 -0
  223. package/src/lint/post-synth/tf039.ts +64 -0
  224. package/src/lint/post-synth/tf040.test.ts +55 -0
  225. package/src/lint/post-synth/tf040.ts +76 -0
  226. package/src/lint/post-synth/tf041.test.ts +50 -0
  227. package/src/lint/post-synth/tf041.ts +56 -0
  228. package/src/lint/post-synth/tf042.test.ts +19 -0
  229. package/src/lint/post-synth/tf042.ts +42 -0
  230. package/src/lint/post-synth/tf043.test.ts +65 -0
  231. package/src/lint/post-synth/tf043.ts +49 -0
  232. package/src/lint/post-synth/tf044.test.ts +27 -0
  233. package/src/lint/post-synth/tf044.ts +51 -0
  234. package/src/lint/post-synth/tf045.test.ts +30 -0
  235. package/src/lint/post-synth/tf045.ts +47 -0
  236. package/src/op/activities/index.ts +4 -0
  237. package/src/op/activities/pin-rollout.ts +77 -0
  238. package/src/op/activities/terraform.test.ts +13 -0
  239. package/src/op/activities/terraform.ts +46 -86
  240. package/src/op/activity-contracts.test.ts +4 -1
  241. package/src/op/activity-contracts.ts +42 -0
  242. package/src/op/builders.ts +13 -0
  243. package/src/pin/bundle.test.ts +53 -0
  244. package/src/pin/edit-ts.test.ts +39 -0
  245. package/src/pin/edit-ts.ts +77 -0
  246. package/src/pin/edit.test.ts +199 -0
  247. package/src/pin/edit.ts +157 -0
  248. package/src/pin/forge.ts +85 -0
  249. package/src/pin/index.ts +22 -0
  250. package/src/pin/rollout.test.ts +232 -0
  251. package/src/pin/rollout.ts +451 -0
  252. package/src/pin/scan.ts +309 -0
  253. package/src/pin/source.ts +206 -0
  254. package/src/pin/waves.test.ts +101 -0
  255. package/src/pin/waves.ts +125 -0
  256. package/src/plan-digest.ts +99 -0
  257. package/src/plan-summary.test.ts +154 -0
  258. package/src/plugin.ts +25 -2
  259. package/src/terragrunt/affected.acceptance.test.ts +83 -0
  260. package/src/terragrunt/affected.test.ts +177 -0
  261. package/src/terragrunt/affected.ts +348 -0
  262. package/src/terragrunt/index.ts +11 -0
  263. package/src/terragrunt/mocks.acceptance.test.ts +105 -0
  264. package/src/terragrunt/mocks.test.ts +309 -0
  265. package/src/terragrunt/mocks.ts +324 -0
  266. package/src/terragrunt/run.ts +369 -0
  267. package/src/terragrunt/terragrunt.acceptance.test.ts +122 -0
  268. package/src/terragrunt/terragrunt.test.ts +332 -0
  269. package/src/terragrunt/units.ts +235 -0
  270. package/src/terragrunt/wave.ts +181 -0
@@ -0,0 +1,47 @@
1
+ /**
2
+ * TF045: no Terragrunt config sets `terragrunt_version_constraint`.
3
+ *
4
+ * The attribute makes Terragrunt refuse to run on a release outside the range.
5
+ * Without it each machine and each CI image runs whatever Terragrunt it
6
+ * installed, and a behaviour change between releases reaches a plan with no
7
+ * diff. It is usually set once, in the root config every unit includes.
8
+ *
9
+ * The rule looks at the whole set of configs in the scan and reports once. It
10
+ * reports only when the set holds a config that includes no other file (the
11
+ * root config, or a self-contained unit) and none of the configs sets the
12
+ * attribute. A set made only of units that include a parent it did not read,
13
+ * such as one unit directory passed alone, is not determined: the parent may
14
+ * set it. The finding is anchored on `root.hcl` when the set has one.
15
+ *
16
+ * Off by default: the `report-only` tier keeps it out of the `recommended`
17
+ * preset, since many repos pin Terragrunt in the toolchain (`.tool-versions`,
18
+ * a CI image) rather than in config.
19
+ */
20
+
21
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
22
+ import { TERRAGRUNT_CONFIG_TYPE } from "../../hcl/parse";
23
+ import { terragruntEntities } from "./terragrunt";
24
+
25
+ export const tf045: PostSynthCheck = {
26
+ id: "TF045",
27
+ description: "No Terragrunt config sets terragrunt_version_constraint",
28
+
29
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
30
+ const configs = terragruntEntities(ctx.entities, TERRAGRUNT_CONFIG_TYPE);
31
+ if (configs.some((c) => c.body.terragrunt_version_constraint !== undefined)) return [];
32
+ const tops = configs.filter((c) => Array.isArray(c.body.includes) && c.body.includes.length === 0);
33
+ if (tops.length === 0) return [];
34
+ const anchor = [...tops].sort((a, b) => Number(b.file === "root.hcl") - Number(a.file === "root.hcl") || a.key.localeCompare(b.key))[0];
35
+ return [
36
+ {
37
+ checkId: "TF045",
38
+ severity: "warning",
39
+ message:
40
+ `No Terragrunt config sets \`terragrunt_version_constraint\` (${anchor.file} is the top config read). ` +
41
+ 'Set it once in the root config, for example `terragrunt_version_constraint = ">= 1.1.0"`, so every machine runs a release the repo was tested with.',
42
+ entity: anchor.key,
43
+ lexicon: "terraform",
44
+ },
45
+ ];
46
+ },
47
+ };
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Affected Terragrunt units for a git range (#3415): what Terragrunt's own
3
+ * git filter selects, plus three cases it misses, each unit with its reasons.
4
+ *
5
+ * Terragrunt's `[base...head]` filter is the starting point, so the selection
6
+ * matches what `run --all` with that filter would run. Terragrunt 1.1.6 and
7
+ * 1.2.0-rc1 both miss these (observed on `../__fixtures__/terragrunt/affected`):
8
+ *
9
+ * - `module-file`: a file under a unit's local module directory that is not a
10
+ * configuration file, such as one the module reads with `file()`. A unit's
11
+ * module directory is where the `.tf` and `.tofu` files in its `reading`
12
+ * list live, so an interpolated `terraform.source` resolves the way
13
+ * Terragrunt resolved it. A file Terragrunt lists in `reading` is its own
14
+ * to track and is not counted here.
15
+ * - `module-call`: a file under a local module that the unit's module calls,
16
+ * followed through modules that call modules with the same reader
17
+ * `../changed-roots.ts` uses for plain roots.
18
+ * - `stack-template`: a file under a stack's local unit template selects the
19
+ * units generated from it. A stack template (a `stack` block) selects every
20
+ * unit generated under it.
21
+ *
22
+ * Dependents of the selected units are the caller's to add (`terragruntDependents`).
23
+ */
24
+ import { type TerragruntFindOptions, type TerragruntUnit } from "./units.js";
25
+ import { type TerragruntRunOptions } from "./run.js";
26
+ /** Why a unit is affected. */
27
+ export type TerragruntAffectedKind =
28
+ /** Terragrunt's git filter selected it. */
29
+ "terragrunt"
30
+ /** Terragrunt's git filter selected it and it is gone at head: Terragrunt plans its destroy from the base checkout. */
31
+ | "removed"
32
+ /** A changed file under the unit's module directory that Terragrunt does not track. */
33
+ | "module-file"
34
+ /** A changed file under a local module the unit's module calls. */
35
+ | "module-call"
36
+ /** A changed file under the stack template the unit is generated from. */
37
+ | "stack-template";
38
+ export interface TerragruntAffectedReason {
39
+ kind: TerragruntAffectedKind;
40
+ /** The changed files behind this reason, sorted. Empty when Terragrunt selected the unit for files chant cannot attribute. */
41
+ files: string[];
42
+ /** The module directory or template directory the files sit under. Unset for `terragrunt` and `removed`. */
43
+ via?: string;
44
+ }
45
+ export interface TerragruntAffectedUnit {
46
+ /** The unit's path, as discovery reports it. */
47
+ path: string;
48
+ /** Terragrunt's reason first, then the supplements in the order of {@link TerragruntAffectedKind}. */
49
+ reasons: TerragruntAffectedReason[];
50
+ }
51
+ export interface TerragruntAffected {
52
+ /** The affected units, sorted by path. */
53
+ units: TerragruntAffectedUnit[];
54
+ /** What the selection could not do, one line each: a unit Terragrunt selected that discovery left out, a generated unit not generated yet. */
55
+ notes: string[];
56
+ }
57
+ export interface TerragruntAffectedInput {
58
+ /** The project directory. Unit paths, `reading` entries and changed files are relative to it. */
59
+ dir: string;
60
+ /** The project's units at head, from discovery, with stacks generated. */
61
+ units: readonly TerragruntUnit[];
62
+ /** Unit paths Terragrunt's own `[base...head]` filter selected. */
63
+ terragruntSelected: readonly string[];
64
+ /** Files the range changed, relative to `dir`, `/`-separated, as `git diff --name-only --relative` prints them. */
65
+ changedFiles: readonly string[];
66
+ }
67
+ /** Arguments to `terragrunt find` for the units Terragrunt's git filter selects between `base` and `head`. */
68
+ export declare function terragruntAffectedFindArgs(options: {
69
+ base: string;
70
+ head?: string;
71
+ } & TerragruntFindOptions): string[];
72
+ /** Arguments to `git` for the files the range changed, relative to the project directory. */
73
+ export declare function terragruntAffectedDiffArgs(options: {
74
+ base: string;
75
+ head?: string;
76
+ }): string[];
77
+ /** The unit's local module directories: where the `.tf` and `.tofu` files Terragrunt reports it reading live, outside the unit's own directory. */
78
+ export declare function terragruntModuleDirs(unit: TerragruntUnit): string[];
79
+ /** A `unit` or `stack` block of a `terragrunt.stack.hcl`, as far as affected selection needs it. */
80
+ export interface TerragruntStackBlock {
81
+ type: "unit" | "stack";
82
+ name: string;
83
+ /** The template directory, relative to the project, for a local source; unset for a remote one. */
84
+ template?: string;
85
+ /** Where the block generates, relative to the project. */
86
+ generated: string;
87
+ }
88
+ /**
89
+ * The `unit` and `stack` blocks of a stack file at `stackFile` (relative to
90
+ * `dir`). Sources that are relative paths or start with `${get_terragrunt_dir()}`
91
+ * are local; anything else (git, registry, other functions) is left without a
92
+ * template, since its version lives in the stack file and a change to it is
93
+ * Terragrunt's to see.
94
+ */
95
+ export declare function readTerragruntStackFile(dir: string, stackFile: string, text: string): TerragruntStackBlock[];
96
+ /** Every `terragrunt.stack.hcl` under `dir`, generated ones included, relative to `dir`. */
97
+ export declare function findTerragruntStackFiles(dir: string): string[];
98
+ /**
99
+ * The affected units: what Terragrunt selected, each with the changed files
100
+ * that explain it, plus the three supplements. A unit Terragrunt selected
101
+ * that discovery does not list is `removed` when its `terragrunt.hcl` is gone,
102
+ * and otherwise left out with a note (discovery excluded it).
103
+ */
104
+ export declare function terragruntAffected(input: TerragruntAffectedInput): TerragruntAffected;
105
+ /** One line per reason, for a report or a job log. */
106
+ export declare function describeTerragruntAffectedReason(reason: TerragruntAffectedReason): string;
107
+ export interface FindTerragruntAffectedOptions extends TerragruntRunOptions, TerragruntFindOptions {
108
+ /** The range's base commit or ref (`origin/main`). */
109
+ base: string;
110
+ /** The range's head. Default `HEAD`. */
111
+ head?: string;
112
+ /** The project's units at head; discovered when unset. Stacks must be generated before discovery. */
113
+ units?: readonly TerragruntUnit[];
114
+ /** The `git` executable. Default `git` on PATH. */
115
+ git?: string;
116
+ }
117
+ /** Run git and Terragrunt's git filter in `dir` and return the affected units with their reasons. */
118
+ export declare function findTerragruntAffected(options: FindTerragruntAffectedOptions): Promise<TerragruntAffected>;
119
+ //# sourceMappingURL=affected.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3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AC,kBAAkB,CAAC,CAuBhH"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Terragrunt units as roots (#3414). `./units`, `./wave` and `./mocks` are pure and
3
+ * bundle without TypeScript; `./run` spawns `terragrunt`. `./affected` picks
4
+ * the units a git range touches (#3415).
5
+ */
6
+ export * from "./units.js";
7
+ export * from "./wave.js";
8
+ export * from "./mocks.js";
9
+ export * from "./run.js";
10
+ export * from "./affected.js";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/terragrunt/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Mock outputs in Terragrunt waves (#3416): which plans of a wave would read
3
+ * a dependency's `mock_outputs`, and the provisional mark a preview carries.
4
+ *
5
+ * A plan built on `mock_outputs` looks like a real one: Terragrunt says so in
6
+ * one log line only, and the plan JSON holds the mock values as if they were
7
+ * the upstream's (observed on 1.1.6). Gruntwork closed mocks in saved plans
8
+ * as won't-fix (gruntwork-io/terragrunt#2178). So a wave is checked before it
9
+ * is planned, and a wave that would read a mock is refused: it is not gated,
10
+ * and the refusal names the upstream that must apply first.
11
+ *
12
+ * The rules follow Terragrunt's own (`pkg/config/dependency.go` at v1.1.6,
13
+ * `getTerragruntOutputIfAppliedElseConfiguredDefault` and
14
+ * `shouldReturnMockOutputs`). For one `dependency` block, read at `plan`:
15
+ *
16
+ * - `enabled = false` or `skip_outputs = true`: Terragrunt never reads the
17
+ * upstream, so with `mock_outputs` set the unit always reads the mock.
18
+ * - The upstream has no outputs (`output -json` prints `{}`, as it does for
19
+ * a unit never applied): Terragrunt returns `mock_outputs` when they are
20
+ * set and allowed for `plan`, and fails otherwise. Either way the wave
21
+ * cannot plan on real values yet.
22
+ * - The upstream has outputs and the block sets a merge strategy
23
+ * (`mock_outputs_merge_strategy_with_state`, or the older
24
+ * `mock_outputs_merge_with_state = true`): every mock key the real outputs
25
+ * lack is filled from the mock. That is a partial mock, and it counts.
26
+ *
27
+ * The blocks come from `terragrunt render --json`, so includes, locals and
28
+ * expressions in `config_path` are Terragrunt's to evaluate, not chant's.
29
+ *
30
+ * A provisional plan is the other side: a dependent planned at PR time
31
+ * (`dependents: plan`), before its upstream applied. It may read mocks. Its
32
+ * change-set members carry `provisional: true`, which keeps it out of the
33
+ * change-set digest, out of any wave's set digest and out of every group of
34
+ * real plans, and its saved plans are never applied.
35
+ *
36
+ * Pure: nothing here spawns or reads files. `./run.ts` runs the commands.
37
+ */
38
+ import type { ChangeSetPart } from "@intentius/chant/change-set";
39
+ /** One `dependency` block as `terragrunt render --json` prints it. */
40
+ export interface RenderedDependency {
41
+ /** The block's label. */
42
+ name: string;
43
+ /** The upstream unit, relative to where Terragrunt runs, with `/` separators. */
44
+ upstream: string;
45
+ /** `mock_outputs`, when set. */
46
+ mockOutputs?: Record<string, unknown>;
47
+ /** `mock_outputs_allowed_terraform_commands`, when set. Unset or empty allows every command. */
48
+ mockAllowed?: string[];
49
+ /** `no_merge`, `shallow`, `deep_map_only` or `deep`, from either merge attribute. Unset is `no_merge`. */
50
+ mergeStrategy?: string;
51
+ /** `skip_outputs = true`. */
52
+ skipOutputs?: boolean;
53
+ /** `enabled = false`. */
54
+ disabled?: boolean;
55
+ }
56
+ /**
57
+ * The upstream a `config_path` names, relative to where Terragrunt runs. A
58
+ * relative path is taken from the unit's directory. An absolute one is made
59
+ * relative to the first of `dirs` it sits under (a directory and its real
60
+ * path, when a symlink leads to it), and kept absolute when it sits under
61
+ * none. A path to the upstream's `terragrunt.hcl` names its directory.
62
+ */
63
+ export declare function upstreamOfConfigPath(unit: string, configPath: string, dirs: string | readonly string[]): string;
64
+ /**
65
+ * The `dependency` blocks of one unit, from `terragrunt render --json` run
66
+ * in it. `unit` is the unit's path relative to where Terragrunt runs (`dirs`).
67
+ * Throws when the output is not the rendered config.
68
+ */
69
+ export declare function parseRenderedDependencies(unit: string, output: string | unknown, dirs: string | readonly string[]): RenderedDependency[];
70
+ /**
71
+ * The outputs `output -json` prints, by name, with their values. Undefined
72
+ * when the text holds no JSON object.
73
+ */
74
+ export declare function parseTerragruntOutputs(output: string): Record<string, unknown> | undefined;
75
+ /** Arguments to `terragrunt` that print one unit's outputs as JSON. */
76
+ export declare function terragruntOutputArgs(unit: string): string[];
77
+ /** Arguments to `terragrunt` that print one unit's evaluated configuration as JSON. */
78
+ export declare function terragruntRenderArgs(unit: string): string[];
79
+ /** Why one dependency of a wave's unit would read `mock_outputs`. */
80
+ export type TerragruntMockReason =
81
+ /** The upstream has no outputs: never applied, or applied with none. */
82
+ "no-outputs"
83
+ /** A merge strategy fills keys the upstream's outputs lack from the mock. */
84
+ | "partial"
85
+ /** `skip_outputs = true` with `mock_outputs` set: the mock is always read. */
86
+ | "skip-outputs"
87
+ /** `enabled = false` with `mock_outputs` set: the mock is always read. */
88
+ | "disabled";
89
+ /** One dependency of a wave's unit that would plan on mock values. */
90
+ export interface TerragruntMockRead {
91
+ /** The wave's unit. */
92
+ unit: string;
93
+ /** The `dependency` block's label. */
94
+ dependency: string;
95
+ /** The upstream unit it names. */
96
+ upstream: string;
97
+ reason: TerragruntMockReason;
98
+ /** For `partial`: the mock keys the upstream's outputs lack, as dotted paths. */
99
+ keys?: string[];
100
+ }
101
+ export interface TerragruntMockReadsInput {
102
+ /** Each wave unit's `dependency` blocks, by unit. */
103
+ dependencies: ReadonlyMap<string, readonly RenderedDependency[]>;
104
+ /**
105
+ * Each upstream's outputs, by unit path. `{}` for an upstream with none;
106
+ * a missing entry is read as none.
107
+ */
108
+ outputs: ReadonlyMap<string, Record<string, unknown>>;
109
+ }
110
+ /**
111
+ * Every dependency of the wave's units that would read `mock_outputs` at
112
+ * plan, sorted by unit and dependency. Empty when the wave plans on real
113
+ * outputs only.
114
+ *
115
+ * An upstream with no outputs is listed whether or not the block sets
116
+ * mocks: without them Terragrunt fails the plan, and with them it plans on
117
+ * fake values. Both mean the upstream must apply first.
118
+ */
119
+ export declare function terragruntMockReads(input: TerragruntMockReadsInput): TerragruntMockRead[];
120
+ /** The upstreams a wave's `dependency` blocks read outputs from, sorted. */
121
+ export declare function terragruntOutputUpstreams(dependencies: ReadonlyMap<string, readonly RenderedDependency[]>): string[];
122
+ /** The refusal for a wave whose plans would read mocks: each unit, the upstream, and what must happen first. */
123
+ export declare function describeMockRefusal(reads: readonly TerragruntMockRead[]): string;
124
+ /**
125
+ * The units a plan log says read mocks, with the upstream each read,
126
+ * relative to where Terragrunt ran (`dirs`, as for
127
+ * {@link upstreamOfConfigPath}). This is the check after the fact: the check
128
+ * before planning ({@link terragruntMockReads}) is what refuses a wave, and
129
+ * this catches an upstream whose state went away in between.
130
+ */
131
+ export declare function terragruntMockWarnings(log: string, dirs: string | readonly string[]): Array<{
132
+ unit: string;
133
+ upstream: string;
134
+ }>;
135
+ /**
136
+ * The parts with each member whose unit the plan log says read mocks turned
137
+ * into a failed member, so a mock plan never reaches a gate.
138
+ */
139
+ export declare function failMockedParts(parts: readonly ChangeSetPart[], mocked: ReadonlyArray<{
140
+ unit: string;
141
+ upstream: string;
142
+ }>): ChangeSetPart[];
143
+ /** The parts of a provisional plan: each member marked, so no digest or group of real plans takes it. */
144
+ export declare function markProvisional(parts: readonly ChangeSetPart[]): ChangeSetPart[];
145
+ /** The file a provisional plan leaves in its work directory, so its saved plans are never applied. */
146
+ export declare const PROVISIONAL_MARKER = "PROVISIONAL";
147
+ //# sourceMappingURL=mocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/terragrunt/mocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BA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AAgB,eAAe,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,EAAE,CAEhF;AAED,sGAAsG;AACtG,eAAO,MAAM,kBAAkB,gBAAgB,CAAC"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * The Terragrunt runner (#3414): discovery and one wave, run against a real
3
+ * `terragrunt`. The pure halves are `./units.ts` and `./wave.ts`.
4
+ *
5
+ * Every call takes an injectable `exec`, so tests stub the process and the
6
+ * acceptance test runs the real binary.
7
+ */
8
+ import type { ChangeSetPart, ChangeSetPlanner } from "@intentius/chant/change-set";
9
+ import { type TerragruntFindOptions, type TerragruntUnit } from "./units.js";
10
+ import { type TerragruntMockRead } from "./mocks.js";
11
+ import { type TerragruntUnitResult } from "./wave.js";
12
+ export interface ExecResult {
13
+ /** The exit code; null when the process did not exit on its own. */
14
+ code: number | null;
15
+ stdout: string;
16
+ stderr: string;
17
+ }
18
+ /** Runs `file args` in `cwd` with `env` added to the process environment. Never throws on a non-zero exit. */
19
+ export type TerragruntExec = (file: string, args: readonly string[], options: {
20
+ cwd: string;
21
+ env: Record<string, string>;
22
+ }) => Promise<ExecResult>;
23
+ export declare const defaultTerragruntExec: TerragruntExec;
24
+ export interface TerragruntRunOptions {
25
+ /** The project directory Terragrunt runs in. Unit paths are relative to it. */
26
+ dir: string;
27
+ /** The `terragrunt` executable. Default `terragrunt` on PATH. */
28
+ terragrunt?: string;
29
+ /** The project's `binary`: what Terragrunt calls, via `TG_TF_PATH`. Unset leaves Terragrunt's own choice. */
30
+ binary?: string;
31
+ exec?: TerragruntExec;
32
+ }
33
+ /** Thrown when `terragrunt` is missing, too old or fails. */
34
+ export declare class TerragruntError extends Error {
35
+ constructor(message: string);
36
+ }
37
+ /** Refuse a Terragrunt older than 1.1. Returns the version line. */
38
+ export declare function checkTerragruntVersion(options: TerragruntRunOptions): Promise<string>;
39
+ export interface TerragruntDiscovery {
40
+ units: TerragruntUnit[];
41
+ /** Units whose own configuration names a `terraform_binary` that `TG_TF_PATH` overrides. */
42
+ warnings: string[];
43
+ }
44
+ /**
45
+ * The project's units, from `terragrunt find`, with catalog templates and the
46
+ * module cache left out and `.terragrunt-filters` honoured.
47
+ */
48
+ export declare function discoverTerragruntUnits(options: TerragruntRunOptions & TerragruntFindOptions): Promise<TerragruntDiscovery>;
49
+ /**
50
+ * A warning per unit whose `terragrunt.hcl`, or a file it includes, sets
51
+ * `terraform_binary` to something other than `binary`. `TG_TF_PATH` wins over
52
+ * it (observed on 1.1.6), so the unit runs `binary`, not what it names.
53
+ */
54
+ export declare function terraformBinaryWarnings(dir: string, units: readonly TerragruntUnit[], binary: string): string[];
55
+ /** The planner a wave's plans come from: the project's binary, else Terragrunt's default of tofu. */
56
+ export declare function terragruntPlanner(binary: string | undefined): ChangeSetPlanner;
57
+ export interface TerragruntWaveRunInput extends TerragruntRunOptions {
58
+ units: readonly string[];
59
+ /** A directory for this wave's plans, plan JSON and reports. Plan and apply of one wave share it. */
60
+ workDir: string;
61
+ destroy?: boolean;
62
+ parallelism?: number;
63
+ /**
64
+ * Plan a preview of units whose upstream has not applied (`dependents:
65
+ * plan` at PR time, #3416). It skips the mock check, so it may read
66
+ * `mock_outputs`; its members are marked provisional, and its saved plans
67
+ * are never applied. Unset, a wave that would read a mock is refused.
68
+ */
69
+ provisional?: boolean;
70
+ }
71
+ /**
72
+ * Thrown when a wave's plans would read `mock_outputs` (#3416). Nothing in
73
+ * the wave was planned, so there is nothing to gate. `reads` names each unit,
74
+ * dependency and upstream.
75
+ */
76
+ export declare class TerragruntMockRefusal extends TerragruntError {
77
+ readonly reads: TerragruntMockRead[];
78
+ constructor(reads: TerragruntMockRead[]);
79
+ }
80
+ export interface TerragruntMockCheckInput extends TerragruntRunOptions {
81
+ units: readonly string[];
82
+ /** How many `render` and `output` calls run at once. Default 8. */
83
+ parallelism?: number;
84
+ }
85
+ /**
86
+ * Which dependencies of the wave's units would read `mock_outputs` at plan,
87
+ * asked of Terragrunt: `render --json` in each unit for its evaluated
88
+ * `dependency` blocks, then `output -json` in each upstream they read. Empty
89
+ * when the wave would plan on real outputs only. Throws when Terragrunt
90
+ * cannot render a unit or read an upstream's outputs, since then nobody
91
+ * knows what the plan would read. A unit with no `terragrunt.hcl` in `dir`
92
+ * (removed by the change, so planned as a destroy) is not rendered.
93
+ */
94
+ export declare function checkTerragruntWaveMocks(input: TerragruntMockCheckInput): Promise<TerragruntMockRead[]>;
95
+ export interface TerragruntWavePlan {
96
+ /** The change-set parts, one per unit. Marked provisional for a provisional plan. */
97
+ parts: ChangeSetPart[];
98
+ /** Whether this was a provisional plan. */
99
+ provisional: boolean;
100
+ results: TerragruntUnitResult[];
101
+ /** Terragrunt's exit code. */
102
+ code: number | null;
103
+ /** Terragrunt's stderr, for the job log. */
104
+ log: string;
105
+ }
106
+ /**
107
+ * Plan one wave with one `terragrunt run --all`, and read each unit's plan
108
+ * JSON and run-report row.
109
+ *
110
+ * Unless the plan is provisional, the wave is first checked for mock reads
111
+ * ({@link checkTerragruntWaveMocks}) and refused with a
112
+ * {@link TerragruntMockRefusal} when any dependency would read
113
+ * `mock_outputs`; nothing is planned then. A unit the plan log still shows
114
+ * reading a mock (its upstream's state went away in between) becomes a
115
+ * failed member.
116
+ */
117
+ export declare function planTerragruntWave(input: TerragruntWaveRunInput): Promise<TerragruntWavePlan>;
118
+ export interface TerragruntWaveApply {
119
+ results: TerragruntUnitResult[];
120
+ code: number | null;
121
+ log: string;
122
+ }
123
+ /**
124
+ * Apply one planned wave from its saved plans, with the same filters. Refuses
125
+ * before running anything when a unit of the wave has no saved plan, since
126
+ * Terragrunt would plan it afresh and apply a plan nobody saw, and when the
127
+ * plans are provisional.
128
+ */
129
+ export declare function applyTerragruntWave(input: TerragruntWaveRunInput): Promise<TerragruntWaveApply>;
130
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/terragrunt/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;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AAI,CAAC;IACpB,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA0CnG;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA6BrG"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Terragrunt units as roots (#3414): what a unit is, how discovery finds the
3
+ * units, and how the unit graph orders them into waves.
4
+ *
5
+ * A Terragrunt unit is a root: its own state, plan file and plan digest. The
6
+ * units and their edges come from `terragrunt find --json --dag
7
+ * --dependencies`, run by Terragrunt itself, so chant never evaluates
8
+ * Terragrunt's HCL to learn the graph. Directories that group units (implicit
9
+ * stacks) are labels: a unit's stack is its parent directory.
10
+ *
11
+ * This module runs nothing and imports only chant's `gated-waves` subpath, so
12
+ * terragucci can bundle it without TypeScript (#3421). `./run.ts` spawns.
13
+ */
14
+ import type { WaveNode } from "@intentius/chant/gated-waves";
15
+ /** The oldest Terragrunt this runner drives: `run --all`, `find --dag` and `--filter` as 1.1 ships them. */
16
+ export declare const TERRAGRUNT_MIN_VERSION = "1.1.0";
17
+ /**
18
+ * Filters every discovery adds: catalog unit templates, which parse only
19
+ * inside a stack, and Terragrunt's module cache. A project's own `exclude`
20
+ * globs are added after these.
21
+ */
22
+ export declare const TERRAGRUNT_DISCOVERY_EXCLUDES: readonly string[];
23
+ /** One unit as `find --json --dag --dependencies --include --reading` reports it. */
24
+ export interface TerragruntUnit {
25
+ /** The unit's directory, relative to where discovery ran, with `/` separators. Also its change-set member name. */
26
+ path: string;
27
+ /** Units this one must follow, from `dependency` and `dependencies` blocks alike. */
28
+ dependencies: string[];
29
+ /** Included files by include name, relative to where discovery ran. */
30
+ include?: Record<string, string>;
31
+ /** Files Terragrunt reports the unit reading. */
32
+ reading?: string[];
33
+ }
34
+ /** A Terragrunt version string, parsed. */
35
+ export interface TerragruntVersion {
36
+ major: number;
37
+ minor: number;
38
+ patch: number;
39
+ /** `rc1` in `1.2.0-rc1`. */
40
+ pre?: string;
41
+ raw: string;
42
+ }
43
+ /** Read `terragrunt --version` output (`terragrunt version v1.1.6`). Undefined when no version is in it. */
44
+ export declare function parseTerragruntVersion(output: string): TerragruntVersion | undefined;
45
+ /**
46
+ * Why this Terragrunt cannot run units, or undefined when it can. A release
47
+ * candidate of 1.1.0 or later counts as that release line.
48
+ */
49
+ export declare function terragruntVersionProblem(output: string): string | undefined;
50
+ /** A path filter that selects exactly one unit. Braced so a path with glob characters stays a path. */
51
+ export declare function unitPathFilter(path: string): string;
52
+ /** A filter that drops everything under `glob`, relative to where discovery runs. */
53
+ export declare function excludeFilter(glob: string): string;
54
+ export interface TerragruntFindOptions {
55
+ /** Globs to leave out beside {@link TERRAGRUNT_DISCOVERY_EXCLUDES}, relative to the project directory. */
56
+ exclude?: readonly string[];
57
+ }
58
+ /**
59
+ * Arguments to `terragrunt` for discovery. `.terragrunt-filters` is read, as
60
+ * Terragrunt reads it by default; the excludes narrow what it selects.
61
+ */
62
+ export declare function terragruntFindArgs(options?: TerragruntFindOptions): string[];
63
+ /**
64
+ * The units in `find --json` output, in the order Terragrunt printed them
65
+ * (its DAG order under `--dag`). Stacks and anything else that is not a unit
66
+ * are left out. Throws when the output is not a JSON array.
67
+ */
68
+ export declare function parseTerragruntFind(output: string | unknown): TerragruntUnit[];
69
+ /** A unit's implicit stack: its parent directory, or `.` for a unit at the top. */
70
+ export declare function stackOfUnit(path: string): string;
71
+ /** Whether `path` matches `glob` (`*` within a segment, `**` across segments, `?` one character). */
72
+ export declare function matchesUnitGlob(path: string, glob: string): boolean;
73
+ /** The units, as the nodes gated waves (#3049) and a fan-out (#2417) layer. */
74
+ export declare function terragruntWaveNodes(units: readonly TerragruntUnit[]): WaveNode[];
75
+ export interface TerragruntWavesOptions {
76
+ /** Unit globs that form wave 1 (`live/dev/**`). A glob matching no unit in the set adds nothing. */
77
+ canary?: readonly string[];
78
+ }
79
+ /** Thrown when units cannot be cut into waves. The message names the units. */
80
+ export declare class TerragruntWaveError extends Error {
81
+ constructor(message: string);
82
+ }
83
+ /**
84
+ * Cut units into waves by Terragrunt's unit graph: each unit after every unit
85
+ * it depends on. A dependency outside `units` holds nothing back; it is not
86
+ * part of this change. Each wave is sorted by path.
87
+ *
88
+ * Canaries go first, layered among themselves, so a canary that reads
89
+ * another canary still waits for it to apply. A canary that depends on a unit
90
+ * of the set that is not a canary is refused: it would apply before what it
91
+ * reads.
92
+ */
93
+ export declare function terragruntWaves(units: readonly TerragruntUnit[], options?: TerragruntWavesOptions): string[][];
94
+ /**
95
+ * Every unit that depends on one of `changed`, directly or through other
96
+ * units, not counting `changed` itself. Sorted by path.
97
+ *
98
+ * `find` reports `dependency` and ordering-only `dependencies` edges as one
99
+ * list, so this follows both. A caller that follows `dependency` edges only
100
+ * passes `edges` built from the units' own blocks.
101
+ */
102
+ export declare function terragruntDependents(units: readonly TerragruntUnit[], changed: readonly string[], edges?: (unit: TerragruntUnit) => readonly string[]): string[];
103
+ //# sourceMappingURL=units.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/terragrunt/units.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,4GAA4G;AAC5G,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,MAAM,EAA8C,CAAC;AAE1G,qFAAqF;AACrF,MAAM,WAAW,cAAc;IAC7B,mHAAmH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