@sous-io/sous 0.2.37 → 1.0.2

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 (244) hide show
  1. package/README.md +14 -256
  2. package/dist/bin.js +11 -0
  3. package/dist/sous.js +1094 -0
  4. package/docs/markdown/README.md +5 -4
  5. package/docs/markdown/_sidebar.md +21 -1
  6. package/docs/markdown/commands.md +294 -431
  7. package/docs/markdown/config-discovery.md +25 -14
  8. package/docs/markdown/config-inspection.md +53 -31
  9. package/docs/markdown/config-layers.md +168 -66
  10. package/docs/markdown/config-variables.md +44 -11
  11. package/docs/markdown/configuration.md +104 -17
  12. package/docs/markdown/design-principles.md +4 -1
  13. package/docs/markdown/repositories-authoring.md +30 -0
  14. package/docs/markdown/repositories-consuming.md +72 -14
  15. package/docs/markdown/repositories-file-formats.md +31 -13
  16. package/docs/markdown/repositories-providers.md +48 -57
  17. package/docs/markdown/repositories-quickstart.md +3 -2
  18. package/docs/markdown/repositories-troubleshooting.md +27 -1
  19. package/docs/markdown/repositories-variables.md +6 -1
  20. package/docs/markdown/repositories.md +18 -8
  21. package/package.json +48 -107
  22. package/recipes/core/sous-skills/skills/about-liquid-templates/SKILL.tpl.md +4 -6
  23. package/recipes/core/sous-skills/skills/about-liquid-templates/references/liquid-filters.tpl.md +2 -0
  24. package/recipes/core/sous-skills/skills/about-sous/SKILL.tpl.md +10 -9
  25. package/recipes/core/sous-skills/skills/about-sous-configuration/SKILL.tpl.md +35 -14
  26. package/recipes/core/sous-skills/skills/about-sous-recipes/SKILL.tpl.md +51 -20
  27. package/recipes/core/sous-skills/sous.recipe.yaml +1 -1
  28. package/sous.config.schema.json +351 -132
  29. package/bin/run.js +0 -51
  30. package/src/base-command.ts +0 -457
  31. package/src/commands/build.ts +0 -181
  32. package/src/commands/clear.ts +0 -79
  33. package/src/commands/compile.ts +0 -155
  34. package/src/commands/config/get.ts +0 -110
  35. package/src/commands/config/show.ts +0 -32
  36. package/src/commands/config/validate.ts +0 -53
  37. package/src/commands/help.ts +0 -46
  38. package/src/commands/init.ts +0 -289
  39. package/src/commands/launch.ts +0 -139
  40. package/src/commands/lock/rebuild.ts +0 -239
  41. package/src/commands/lock/show.ts +0 -115
  42. package/src/commands/namespace/list.ts +0 -138
  43. package/src/commands/namespace/show.ts +0 -130
  44. package/src/commands/prune.ts +0 -43
  45. package/src/commands/recipe/list.ts +0 -112
  46. package/src/commands/recipe/show.ts +0 -439
  47. package/src/commands/repo/add.ts +0 -145
  48. package/src/commands/repo/contribute.ts +0 -604
  49. package/src/commands/repo/gc.ts +0 -173
  50. package/src/commands/repo/init.ts +0 -136
  51. package/src/commands/repo/link.ts +0 -899
  52. package/src/commands/repo/list.ts +0 -236
  53. package/src/commands/repo/release.ts +0 -685
  54. package/src/commands/repo/remove.ts +0 -194
  55. package/src/commands/repo/search.ts +0 -243
  56. package/src/commands/repo/submit.ts +0 -341
  57. package/src/commands/repo/unlink.ts +0 -461
  58. package/src/commands/subscription/add.ts +0 -286
  59. package/src/commands/subscription/list.ts +0 -208
  60. package/src/commands/subscription/remove.ts +0 -182
  61. package/src/commands/subscription/update.ts +0 -216
  62. package/src/commands/update.ts +0 -178
  63. package/src/commands/vars/ask.ts +0 -417
  64. package/src/commands/vars/index.ts +0 -79
  65. package/src/commands/vars/list.ts +0 -67
  66. package/src/commands/vars/show.ts +0 -77
  67. package/src/config-command.ts +0 -30
  68. package/src/lib/build-preparation.ts +0 -128
  69. package/src/lib/build-service.ts +0 -580
  70. package/src/lib/config-discovery.ts +0 -378
  71. package/src/lib/config-inspect.ts +0 -145
  72. package/src/lib/config-kernel.mjs +0 -379
  73. package/src/lib/config-schema.ts +0 -401
  74. package/src/lib/env-file.ts +0 -328
  75. package/src/lib/env-local.ts +0 -212
  76. package/src/lib/errors.ts +0 -32
  77. package/src/lib/glob-pattern.ts +0 -24
  78. package/src/lib/include-resolver.ts +0 -523
  79. package/src/lib/interactive.ts +0 -165
  80. package/src/lib/markdown-compiler.ts +0 -947
  81. package/src/lib/package-info.ts +0 -25
  82. package/src/lib/pid-service.ts +0 -99
  83. package/src/lib/project-install.d.mts +0 -44
  84. package/src/lib/project-install.mjs +0 -234
  85. package/src/lib/project-scaffold/index.ts +0 -332
  86. package/src/lib/project-scaffold/templates.ts +0 -240
  87. package/src/lib/repos/catalog-display.ts +0 -215
  88. package/src/lib/repos/catalog-inputs.ts +0 -288
  89. package/src/lib/repos/catalog.ts +0 -842
  90. package/src/lib/repos/contribute.ts +0 -452
  91. package/src/lib/repos/core-recipe.ts +0 -105
  92. package/src/lib/repos/declarations.ts +0 -187
  93. package/src/lib/repos/defaults.ts +0 -175
  94. package/src/lib/repos/formats/common.ts +0 -440
  95. package/src/lib/repos/formats/index-file.ts +0 -253
  96. package/src/lib/repos/formats/links-map.ts +0 -98
  97. package/src/lib/repos/formats/lockfile.ts +0 -169
  98. package/src/lib/repos/formats/patterns.ts +0 -57
  99. package/src/lib/repos/formats/recipe-manifest.ts +0 -205
  100. package/src/lib/repos/formats/repo-manifest.ts +0 -97
  101. package/src/lib/repos/formats/store-entry.ts +0 -84
  102. package/src/lib/repos/formats/variable-definition.ts +0 -268
  103. package/src/lib/repos/freshness.ts +0 -264
  104. package/src/lib/repos/git-clone.ts +0 -850
  105. package/src/lib/repos/identity.ts +0 -89
  106. package/src/lib/repos/index.ts +0 -57
  107. package/src/lib/repos/links.ts +0 -356
  108. package/src/lib/repos/load-manifest.ts +0 -237
  109. package/src/lib/repos/lock-service.ts +0 -454
  110. package/src/lib/repos/locked-namespace-resolver.ts +0 -232
  111. package/src/lib/repos/locked-recipe-lookup.ts +0 -123
  112. package/src/lib/repos/locked-recipes.ts +0 -254
  113. package/src/lib/repos/managed-layer.ts +0 -422
  114. package/src/lib/repos/memories-hash-name.ts +0 -33
  115. package/src/lib/repos/namespace-resolver.ts +0 -527
  116. package/src/lib/repos/providers/base.ts +0 -268
  117. package/src/lib/repos/providers/git.ts +0 -245
  118. package/src/lib/repos/providers/github.ts +0 -589
  119. package/src/lib/repos/providers/gitlab.ts +0 -332
  120. package/src/lib/repos/providers/http.ts +0 -128
  121. package/src/lib/repos/providers/index-cache.ts +0 -421
  122. package/src/lib/repos/providers/index.ts +0 -106
  123. package/src/lib/repos/providers/local.ts +0 -410
  124. package/src/lib/repos/providers/provider.ts +0 -615
  125. package/src/lib/repos/recipe-config-layers.ts +0 -316
  126. package/src/lib/repos/recipe-key-matcher.ts +0 -62
  127. package/src/lib/repos/recipe-memories.ts +0 -178
  128. package/src/lib/repos/recipe-targets.ts +0 -236
  129. package/src/lib/repos/ref-search.ts +0 -46
  130. package/src/lib/repos/release/bump.ts +0 -161
  131. package/src/lib/repos/release/changelog.ts +0 -461
  132. package/src/lib/repos/release/git-state.ts +0 -460
  133. package/src/lib/repos/release/index-builder.ts +0 -1108
  134. package/src/lib/repos/release/index.ts +0 -19
  135. package/src/lib/repos/release/plan.ts +0 -521
  136. package/src/lib/repos/release/settle.ts +0 -154
  137. package/src/lib/repos/release/submissions.ts +0 -214
  138. package/src/lib/repos/release/submit-checkout.ts +0 -290
  139. package/src/lib/repos/release/submit-questions.ts +0 -153
  140. package/src/lib/repos/release/submit-service.ts +0 -898
  141. package/src/lib/repos/release/tags.ts +0 -239
  142. package/src/lib/repos/release/validate.ts +0 -463
  143. package/src/lib/repos/resolver.ts +0 -1028
  144. package/src/lib/repos/scaffold/index.ts +0 -245
  145. package/src/lib/repos/scaffold/templates.ts +0 -517
  146. package/src/lib/repos/seed.ts +0 -473
  147. package/src/lib/repos/store/contract.ts +0 -64
  148. package/src/lib/repos/store/hash.ts +0 -191
  149. package/src/lib/repos/store/recipe-store.ts +0 -599
  150. package/src/lib/repos/store/settings.ts +0 -58
  151. package/src/lib/repos/subscription-service.ts +0 -3859
  152. package/src/lib/repos/trust.ts +0 -447
  153. package/src/lib/repos/update-plan.ts +0 -235
  154. package/src/lib/self-update/index.ts +0 -14
  155. package/src/lib/self-update/installs.ts +0 -413
  156. package/src/lib/self-update/managers.ts +0 -126
  157. package/src/lib/self-update/plan.ts +0 -315
  158. package/src/lib/self-update/registry.ts +0 -99
  159. package/src/lib/self-update/run.ts +0 -506
  160. package/src/lib/self-update/versions.ts +0 -243
  161. package/src/lib/settings.ts +0 -1107
  162. package/src/lib/sous-home.ts +0 -104
  163. package/src/lib/state.ts +0 -167
  164. package/src/lib/vars/answers.ts +0 -192
  165. package/src/lib/vars/ask.ts +0 -1152
  166. package/src/lib/vars/definition-source.ts +0 -261
  167. package/src/lib/vars/display.ts +0 -231
  168. package/src/lib/vars/index.ts +0 -20
  169. package/src/lib/vars/ladder.ts +0 -282
  170. package/src/lib/vars/mappings.ts +0 -260
  171. package/src/lib/vars/names.ts +0 -94
  172. package/src/lib/vars/preanswers.ts +0 -395
  173. package/src/lib/vars/question-plan.ts +0 -241
  174. package/src/lib/vars/report.ts +0 -228
  175. package/src/lib/vars/safe-regex.ts +0 -235
  176. package/src/lib/vars/secrets.ts +0 -131
  177. package/src/lib/vars/validate.ts +0 -312
  178. package/src/lib/version-report.ts +0 -90
  179. package/src/lib/watch-loop.ts +0 -148
  180. package/src/lib/watch-service.ts +0 -116
  181. package/src/services/ref-resolver/container.ts +0 -107
  182. package/src/services/ref-resolver/dependency.ts +0 -60
  183. package/src/services/ref-resolver/format.ts +0 -197
  184. package/src/services/ref-resolver/glob.ts +0 -115
  185. package/src/services/ref-resolver/hash-names.ts +0 -155
  186. package/src/services/ref-resolver/index.ts +0 -55
  187. package/src/services/ref-resolver/injectable.ts +0 -36
  188. package/src/services/ref-resolver/location.ts +0 -62
  189. package/src/services/ref-resolver/lookups/cached-index-lookup.ts +0 -53
  190. package/src/services/ref-resolver/lookups/catalog-lookup.ts +0 -23
  191. package/src/services/ref-resolver/lookups/catalog-matcher.ts +0 -261
  192. package/src/services/ref-resolver/lookups/chained-lookup.ts +0 -27
  193. package/src/services/ref-resolver/lookups/env-var-lookup.ts +0 -65
  194. package/src/services/ref-resolver/lookups/fetched-index-lookup.ts +0 -150
  195. package/src/services/ref-resolver/lookups/recorded-dependency-lookup.ts +0 -62
  196. package/src/services/ref-resolver/lookups/ref-lookup.ts +0 -54
  197. package/src/services/ref-resolver/lookups/variable-lookup.ts +0 -123
  198. package/src/services/ref-resolver/named-refs.ts +0 -144
  199. package/src/services/ref-resolver/parser/env-var-splitter.ts +0 -27
  200. package/src/services/ref-resolver/parser/location-splitter.ts +0 -239
  201. package/src/services/ref-resolver/parser/name-path-splitter.ts +0 -200
  202. package/src/services/ref-resolver/parser/partial-ref.ts +0 -84
  203. package/src/services/ref-resolver/parser/query-splitter.ts +0 -61
  204. package/src/services/ref-resolver/parser/range-splitter.ts +0 -52
  205. package/src/services/ref-resolver/parser/ref-parser.ts +0 -115
  206. package/src/services/ref-resolver/parser/repo-qualifier-splitter.ts +0 -51
  207. package/src/services/ref-resolver/parts.ts +0 -115
  208. package/src/services/ref-resolver/pruners/command-line-pruner.ts +0 -47
  209. package/src/services/ref-resolver/pruners/include-pruner.ts +0 -66
  210. package/src/services/ref-resolver/pruners/manifest-pruner.ts +0 -130
  211. package/src/services/ref-resolver/pruners/ref-pruner.ts +0 -135
  212. package/src/services/ref-resolver/pruners/rule-helpers.ts +0 -44
  213. package/src/services/ref-resolver/pruners/stored-key-pruner.ts +0 -136
  214. package/src/services/ref-resolver/ref-helpers.ts +0 -62
  215. package/src/services/ref-resolver/ref-picker-service.ts +0 -204
  216. package/src/services/ref-resolver/ref-report.ts +0 -84
  217. package/src/services/ref-resolver/ref-resolve-arguments.ts +0 -47
  218. package/src/services/ref-resolver/ref-resolve-result.ts +0 -36
  219. package/src/services/ref-resolver/ref-resolver-service.ts +0 -323
  220. package/src/services/ref-resolver/source.ts +0 -48
  221. package/src/services/ref-resolver/tokens.ts +0 -25
  222. package/src/services/ref-resolver/types.ts +0 -155
  223. package/src/templating/filters/bullet-list.ts +0 -9
  224. package/src/templating/filters/index.ts +0 -8
  225. package/src/templating/init-liquid-engine.ts +0 -139
  226. package/src/templating/lib/glob-files.ts +0 -74
  227. package/src/templating/lib/import-export.ts +0 -32
  228. package/src/templating/lib/secret-scope.ts +0 -41
  229. package/src/templating/lib/tag-args.ts +0 -19
  230. package/src/templating/tags/exportScalarVarsJs.ts +0 -46
  231. package/src/templating/tags/getFiles.ts +0 -89
  232. package/src/templating/tags/index.ts +0 -14
  233. package/src/templating/tags/listFiles.ts +0 -54
  234. package/src/templating/tags/showVars.ts +0 -28
  235. package/src/utils/choice-prompt.ts +0 -143
  236. package/src/utils/command-errors.ts +0 -186
  237. package/src/utils/command-help.ts +0 -45
  238. package/src/utils/confirm-prompt.ts +0 -110
  239. package/src/utils/flags.ts +0 -177
  240. package/src/utils/formatting.ts +0 -849
  241. package/src/utils/prompts.ts +0 -53
  242. package/src/utils/sous-directory.ts +0 -245
  243. package/src/utils/table.ts +0 -603
  244. package/src/utils/value-prompt.ts +0 -119
@@ -1,341 +0,0 @@
1
- import { Args, Command, Flags } from "@oclif/core";
2
- import { discoverConfig, refreshDiscoveredConfig } from "../../lib/config-discovery.js";
3
- import { loadEnvFiles } from "../../lib/env-local.js";
4
- import { isInteractive } from "../../lib/interactive.js";
5
- import { enabledRepos } from "../../lib/repos/defaults.js";
6
- import {
7
- findRepoRoot,
8
- renderChangelog,
9
- submitRepo,
10
- type SubmitResult,
11
- } from "../../lib/repos/release/index.js";
12
- import {
13
- findSubmitCheckout,
14
- type SubmitProject,
15
- } from "../../lib/repos/release/submit-checkout.js";
16
- import { submitQuestions } from "../../lib/repos/release/submit-questions.js";
17
- import type { ProposalStatus } from "../../lib/repos/providers/provider.js";
18
- import { loadSettings } from "../../lib/settings.js";
19
- import { reportCommandError } from "../../utils/command-errors.js";
20
- import { confirmationFlag, nonInteractiveFlag } from "../../utils/flags.js";
21
- import {
22
- BULLET,
23
- blankLine,
24
- dryRunNotice,
25
- footer,
26
- header,
27
- log,
28
- note,
29
- paragraph,
30
- section,
31
- showCommandVars,
32
- showVariables,
33
- warning,
34
- } from "../../utils/formatting.js";
35
-
36
- /**
37
- * `sous repo submit` carries a proposed change to a recipe repository's
38
- * maintainers through its whole life: it opens the proposal, updates it when
39
- * there is more to send, reports where it stands, and starts the next one once
40
- * it was merged.
41
- *
42
- * Like `sous repo init` and `sous repo release`, this command does NOT extend
43
- * BaseCommand: it runs inside a RECIPE repository, which is not a sous project.
44
- * It can also be run from a project, naming a repository the project links, and
45
- * then looks for the project's config itself, optionally: finding none is not a
46
- * failure while the working directory is inside a recipe repository.
47
- *
48
- * Submitting never publishes and never writes to a repository directly. Sous
49
- * validates first, then hands the fork, branch and pull request mechanics to the
50
- * provider's own command line tool, which already holds the contributor's
51
- * credentials. Every step is printed before it runs, so a failure halfway
52
- * through leaves no doubt about what did happen.
53
- */
54
- export default class RepoSubmit extends Command {
55
- static description =
56
- "Propose a recipe repository's changes to its maintainers, and follow the proposal through";
57
-
58
- /**
59
- * The other spelling of the topic. It lives under a hidden topic, so it is
60
- * typable everywhere without ever reaching the top-level listing.
61
- */
62
- static aliases = ["repos:submit"];
63
-
64
- static examples = [
65
- '<%= config.bin %> repo submit --title "Add a linting recipe" --body "Adds lint rules."',
66
- "<%= config.bin %> repo submit sous-recipes",
67
- "<%= config.bin %> repo submit --status",
68
- "<%= config.bin %> repo submit --commit --yes --title \"Fix a typo\" --body \"Fixes it.\"",
69
- "<%= config.bin %> repo submit --dry-run",
70
- ];
71
-
72
- static args = {
73
- repo: Args.string({
74
- description: "The linked repository to propose a change from, when run inside a project",
75
- required: false,
76
- }),
77
- };
78
-
79
- static flags = {
80
- title: Flags.string({
81
- description: "The proposal's title; required for a new proposal, and replaces an open one's",
82
- }),
83
- body: Flags.string({
84
- description:
85
- "The proposal's description; required for a new proposal, and replaces an open one's",
86
- }),
87
- branch: Flags.string({
88
- description: "The branch to work with, instead of the one that is checked out",
89
- }),
90
- status: Flags.boolean({
91
- description: "Only report where the branch's proposal stands",
92
- default: false,
93
- }),
94
- commit: Flags.boolean({
95
- description: "Commit uncommitted changes for you, after listing them and asking once",
96
- default: false,
97
- }),
98
- draft: Flags.boolean({
99
- description: "Open a new proposal as a draft",
100
- default: false,
101
- }),
102
- yes: confirmationFlag(),
103
- "dry-run": Flags.boolean({
104
- description: "Check everything and print the plan without writing or sending anything",
105
- default: false,
106
- }),
107
- // This command does not extend BaseCommand, so it declares the global
108
- // non-interactive flag itself; the rule is the same everywhere.
109
- "non-interactive": nonInteractiveFlag(),
110
- };
111
-
112
- async init(): Promise<void> {
113
- await super.init();
114
- header();
115
- }
116
-
117
- async run(): Promise<void> {
118
- const { args, flags } = await this.parse(RepoSubmit);
119
- const dryRun = flags["dry-run"];
120
- const interactive = isInteractive();
121
- const cwd = process.cwd();
122
-
123
- showCommandVars({
124
- "Working directory": cwd,
125
- Repository: args.repo ?? "(the one the working directory is in)",
126
- Branch: flags.branch ?? "(the one that is checked out)",
127
- Mode: flags.status ? "Status only" : dryRun ? "Dry run" : "Propose",
128
- });
129
-
130
- const checkout = await findSubmitCheckout({
131
- cwd,
132
- ...(args.repo === undefined ? {} : { repo: args.repo }),
133
- ...(await this.projectFor(cwd, args.repo)),
134
- interactive,
135
- });
136
-
137
- section("The checkout");
138
- showVariables({
139
- Checkout: checkout.rootDir,
140
- ...(checkout.repo === undefined ? {} : { Repository: checkout.repo }),
141
- });
142
- blankLine();
143
- note(checkout.reason);
144
- for (const entry of checkout.notes) note(entry);
145
-
146
- section(flags.status ? "Looking the proposal up" : "Proposing a change");
147
-
148
- const result = await submitRepo({
149
- rootDir: checkout.rootDir,
150
- ...(flags.title === undefined ? {} : { title: flags.title }),
151
- ...(flags.body === undefined ? {} : { body: flags.body }),
152
- ...(flags.branch === undefined ? {} : { branch: flags.branch }),
153
- statusOnly: flags.status,
154
- commit: flags.commit,
155
- draft: flags.draft,
156
- dryRun,
157
- questions: submitQuestions({ interactive, yes: flags.yes }),
158
- onStep: (message) => log(` ${message}`),
159
- onNotice: (message) => (dryRun ? dryRunNotice(message) : note(message)),
160
- onWarning: (message) => warning(message),
161
- });
162
-
163
- this.report(result);
164
- footer();
165
- }
166
-
167
- /**
168
- * The project around the working directory, when the run needs one: always
169
- * when a repository was named, and otherwise only when the working directory
170
- * is not a recipe repository itself (the checkout finder decides that; a
171
- * project found here is simply handed to it). A project whose config does not
172
- * load is an error, because the run cannot say what the argument names.
173
- *
174
- * @param cwd - The working directory.
175
- * @param repo - The repository the command line named, when it named one.
176
- */
177
- private async projectFor(
178
- cwd: string,
179
- repo: string | undefined
180
- ): Promise<{ project?: SubmitProject }> {
181
- const discovered = discoverConfig(cwd, undefined);
182
- if (discovered === null) return {};
183
- if (repo === undefined && insideRecipeRepo(cwd)) return {};
184
-
185
- loadEnvFiles(discovered.sousDir);
186
- const refreshed = refreshDiscoveredConfig(discovered);
187
- const settings = await loadSettings(refreshed);
188
- return { project: { sousDir: refreshed.sousDir, repos: enabledRepos(settings) } };
189
- }
190
-
191
- /**
192
- * Prints what the run did, or would do, as a key and value list followed by
193
- * one sentence, and the changelog when one was generated.
194
- *
195
- * @param result - What the submission reported.
196
- */
197
- private report(result: SubmitResult): void {
198
- const noun = result.proposalNoun;
199
-
200
- if (result.outcome === "cancelled") {
201
- blankLine();
202
- log(" Nothing was written and nothing was sent.");
203
- return;
204
- }
205
-
206
- if (result.outcome === "status") {
207
- section(`The ${noun} for '${result.branch}'`);
208
- if (result.status === undefined) {
209
- showVariables({ Repository: `${result.repo.owner}/${result.repo.name}`, Branch: result.branch });
210
- blankLine();
211
- paragraph(`The branch '${result.branch}' has no ${noun}.`);
212
- return;
213
- }
214
- showVariables(statusFacts(result, result.status));
215
- return;
216
- }
217
-
218
- if (result.changelog !== undefined) {
219
- section("What merging this changes");
220
- printChangelog(renderChangelog(result.changelog));
221
- }
222
-
223
- const heading =
224
- result.outcome === "created"
225
- ? result.dryRun
226
- ? `The ${noun} this would open`
227
- : `The ${noun} that was opened`
228
- : result.dryRun
229
- ? `The ${noun} this would update`
230
- : `The ${noun} for '${result.branch}'`;
231
- section(heading);
232
-
233
- showVariables({
234
- Provider: result.provider,
235
- Repository: `${result.repo.owner}/${result.repo.name}`,
236
- Branch: result.branch,
237
- "Target branch": result.baseBranch,
238
- "Pushed to": result.dryRun ? "(nothing was pushed)" : result.pushedTo,
239
- "Through a fork": result.usedFork,
240
- ...(result.title === undefined ? {} : { Title: result.title }),
241
- ...(result.committed === undefined ? {} : { Committed: result.committed.join(", ") }),
242
- Address: result.url ?? (result.dryRun ? "(not opened yet)" : "(the provider printed no address)"),
243
- });
244
-
245
- if (result.status !== undefined && !result.dryRun) {
246
- blankLine();
247
- showVariables(statusFacts(result, result.status));
248
- }
249
-
250
- blankLine();
251
- if (result.dryRun) {
252
- log(" Nothing was written and nothing was sent.");
253
- } else if (result.outcome === "created") {
254
- paragraph(
255
- `The ${noun} is open for review. The maintainers decide what happens next; sous ` +
256
- `never publishes on their behalf.`
257
- );
258
- } else if (result.outcome === "updated") {
259
- paragraph(`The ${noun} was updated with what this run sent.`);
260
- } else {
261
- paragraph(`There was nothing new to send, so the ${noun} was left as it was.`);
262
- }
263
- }
264
-
265
- /**
266
- * Renders a configuration error as a plain, readable message rather than an
267
- * oclif stack trace, matching what BaseCommand does for every other command.
268
- * An error raised because a question could not be asked also gets this
269
- * command's own help underneath it.
270
- */
271
- protected async catch(error: Error & { exitCode?: number }): Promise<unknown> {
272
- const exitCode = await reportCommandError(this, error);
273
- if (exitCode === undefined) return super.catch(error);
274
- return this.exit(exitCode);
275
- }
276
- }
277
-
278
- /**
279
- * Prints the Markdown changelog for a terminal: the heading is already the
280
- * section's, emphasis and code marks are dropped, a list item becomes a real
281
- * bullet, and every line is wrapped.
282
- *
283
- * @param markdown - The changelog as it goes into the proposal.
284
- */
285
- function printChangelog(markdown: string): void {
286
- const lines = markdown.split("\n").slice(2);
287
- for (const raw of lines) {
288
- const line = raw.replace(/\*\*/g, "").replace(/`/g, "");
289
- if (line.trim().length === 0) {
290
- blankLine();
291
- } else if (line.startsWith("- ")) {
292
- paragraph(`${BULLET} ${line.slice(2)}`, { indent: 4, hangingIndent: 2 });
293
- } else {
294
- paragraph(line);
295
- }
296
- }
297
- }
298
-
299
- /** True when the directory is inside a recipe repository. */
300
- function insideRecipeRepo(cwd: string): boolean {
301
- try {
302
- findRepoRoot(cwd);
303
- return true;
304
- } catch {
305
- return false;
306
- }
307
- }
308
-
309
- /**
310
- * The facts about where a proposal stands, as a key and value list.
311
- *
312
- * @param result - The submission, for the repository and the noun.
313
- * @param status - What the provider reported.
314
- */
315
- function statusFacts(result: SubmitResult, status: ProposalStatus): Record<string, unknown> {
316
- const { proposal } = status;
317
- const state =
318
- proposal.state === "open"
319
- ? proposal.draft
320
- ? "open, as a draft"
321
- : "open"
322
- : proposal.state === "merged"
323
- ? "merged"
324
- : "closed without being merged";
325
- return {
326
- [`The ${result.proposalNoun}`]: proposal.title,
327
- State: state,
328
- ...(status.review === undefined ? {} : { Review: status.review }),
329
- ...(status.checks === undefined
330
- ? {}
331
- : {
332
- Checks:
333
- `${status.checks.passed} passed, ${status.checks.failed} failed, ` +
334
- `${status.checks.pending} still running`,
335
- }),
336
- ...(status.mergeable === undefined
337
- ? {}
338
- : { Mergeable: status.mergeable ? "yes" : "no, it conflicts with its target branch" }),
339
- ...(proposal.url === undefined ? {} : { Address: proposal.url }),
340
- };
341
- }