@plexus-ms/lib 0.130.0 → 0.131.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 (92) hide show
  1. package/dist/apply.d.ts +25 -0
  2. package/dist/apply.d.ts.map +1 -0
  3. package/dist/apply.js +205 -0
  4. package/dist/apply.js.map +1 -0
  5. package/dist/bundled.d.ts +15 -0
  6. package/dist/bundled.d.ts.map +1 -0
  7. package/dist/bundled.js +42 -0
  8. package/dist/bundled.js.map +1 -0
  9. package/dist/consumers.d.ts +8 -21
  10. package/dist/consumers.d.ts.map +1 -1
  11. package/dist/consumers.js +62 -58
  12. package/dist/consumers.js.map +1 -1
  13. package/dist/doctor.d.ts +17 -1
  14. package/dist/doctor.d.ts.map +1 -1
  15. package/dist/doctor.js +154 -9
  16. package/dist/doctor.js.map +1 -1
  17. package/dist/engine.d.ts +2 -0
  18. package/dist/engine.d.ts.map +1 -0
  19. package/dist/engine.js +9 -0
  20. package/dist/engine.js.map +1 -0
  21. package/dist/frontmatter.d.ts.map +1 -1
  22. package/dist/frontmatter.js +6 -5
  23. package/dist/frontmatter.js.map +1 -1
  24. package/dist/index.d.ts +11 -4
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +11 -4
  27. package/dist/index.js.map +1 -1
  28. package/dist/marker.d.ts +38 -0
  29. package/dist/marker.d.ts.map +1 -1
  30. package/dist/marker.js +269 -16
  31. package/dist/marker.js.map +1 -1
  32. package/dist/model.d.ts +5 -2
  33. package/dist/model.d.ts.map +1 -1
  34. package/dist/model.js +8 -4
  35. package/dist/model.js.map +1 -1
  36. package/dist/need.d.ts +1 -1
  37. package/dist/need.d.ts.map +1 -1
  38. package/dist/need.js +2 -2
  39. package/dist/need.js.map +1 -1
  40. package/dist/newSite.d.ts +31 -0
  41. package/dist/newSite.d.ts.map +1 -0
  42. package/dist/newSite.js +185 -0
  43. package/dist/newSite.js.map +1 -0
  44. package/dist/overview.d.ts +4 -8
  45. package/dist/overview.d.ts.map +1 -1
  46. package/dist/overview.js +9 -32
  47. package/dist/overview.js.map +1 -1
  48. package/dist/pull.d.ts +48 -21
  49. package/dist/pull.d.ts.map +1 -1
  50. package/dist/pull.js +183 -67
  51. package/dist/pull.js.map +1 -1
  52. package/dist/recursive.d.ts.map +1 -1
  53. package/dist/recursive.js +7 -5
  54. package/dist/recursive.js.map +1 -1
  55. package/dist/siteTemplates.d.ts +14 -0
  56. package/dist/siteTemplates.d.ts.map +1 -0
  57. package/dist/siteTemplates.js +107 -0
  58. package/dist/siteTemplates.js.map +1 -0
  59. package/dist/sites.d.ts +24 -0
  60. package/dist/sites.d.ts.map +1 -0
  61. package/dist/sites.js +89 -0
  62. package/dist/sites.js.map +1 -0
  63. package/dist/standard-index.json +1 -1
  64. package/dist/summary.d.ts +1 -1
  65. package/dist/summary.d.ts.map +1 -1
  66. package/dist/summary.js +6 -1
  67. package/dist/summary.js.map +1 -1
  68. package/dist/sync.d.ts +86 -0
  69. package/dist/sync.d.ts.map +1 -0
  70. package/dist/sync.js +227 -0
  71. package/dist/sync.js.map +1 -0
  72. package/dist/take.d.ts +20 -25
  73. package/dist/take.d.ts.map +1 -1
  74. package/dist/take.js +48 -142
  75. package/dist/take.js.map +1 -1
  76. package/dist/templates.d.ts +1 -3
  77. package/dist/templates.d.ts.map +1 -1
  78. package/dist/templates.js +5 -9
  79. package/dist/templates.js.map +1 -1
  80. package/dist/templatesRoot.d.ts +5 -0
  81. package/dist/templatesRoot.d.ts.map +1 -0
  82. package/dist/templatesRoot.js +37 -0
  83. package/dist/templatesRoot.js.map +1 -0
  84. package/dist/update.d.ts +18 -9
  85. package/dist/update.d.ts.map +1 -1
  86. package/dist/update.js +166 -78
  87. package/dist/update.js.map +1 -1
  88. package/dist/versionTemplates.d.ts +24 -0
  89. package/dist/versionTemplates.d.ts.map +1 -0
  90. package/dist/versionTemplates.js +168 -0
  91. package/dist/versionTemplates.js.map +1 -0
  92. package/package.json +2 -1
package/dist/sync.js ADDED
@@ -0,0 +1,227 @@
1
+ // sync: merge a render of each site's templates into the working tree. `apply`
2
+ // and `update` share everything but where the two sides come from, so this is
3
+ // the one place that renders, merges and writes defaults; a verb only decides
4
+ // which sites to take and what each side is.
5
+ //
6
+ // A site has two sides, the render it was last brought to (old) and the one it
7
+ // is being brought to (new). A side is either a `Source`, templates with the
8
+ // answers to render them with, or a `Rendered` tree that arrived already
9
+ // rendered, with its policies and the answers it resolved, as another
10
+ // version's `plx-template render` leaves them. The new side is always a
11
+ // source: its resolved answers are where the defaults of newly applicable
12
+ // questions come from.
13
+ //
14
+ // Each side's sources are rendered from that side's `Templates`: a root of
15
+ // templates, one directory each, rendered by this plx's engine, or by the
16
+ // side's own `render` where it brings one. `apply` gives one root to both
17
+ // sides, the templates this plx bundles; `update` gives each side the
18
+ // templates of its version and, for a version other than the running one, the
19
+ // render of that version's plx-template (versionTemplates.ts), so that a
20
+ // version's templates are only ever rendered by its own engine.
21
+ //
22
+ // Planning reads and renders, and writes nothing: every site is rendered
23
+ // before any is merged, and every render error of every site is reported
24
+ // together, so that a failure costs nothing. Each site's merge is then
25
+ // planned by the engine (`planMerge`) against the site's directory in the
26
+ // working tree; a site's old and new tree are relative to that directory.
27
+ // The root is rendered first, whatever the order given, and what it resolved,
28
+ // its defaults included, is a root answer: a nested site's answers are the
29
+ // root marker's plus its own (§ 5), so the nested renders are given the
30
+ // root's resolved answers on each side. Where the root's resolved answer and a
31
+ // nested marker's own meet on one key, a state only a human can have written
32
+ // (a root default is never written beside one), the nested marker's own answer
33
+ // wins: an answer a person wrote is not overridden by a default nobody wrote.
34
+ //
35
+ // A default is written to a site's marker when the question is applicable on
36
+ // the new side and was not on the old one (a template added, a `when` that
37
+ // became true) and the marker's answers, the root's included, do not give it.
38
+ // The write splices the marker's text (`setMarkerKeys`), so everything a human
39
+ // wrote stays as it was. The root marker's `version` is written only when the
40
+ // caller gives one (`update`, never `apply`), and then in the root marker's
41
+ // one splice with its defaults, read when the plan is made: a write of its own
42
+ // before or after would be lost to the other. It is written whether or not the
43
+ // root renders anything or is merged, since every site of the repo moves to it.
44
+ //
45
+ // Performing a plan writes the merges, each site's in turn, then the markers.
46
+ // A conflicted path is left in the file between the engine's markers, or kept
47
+ // as it is where the template removed a file the user edited; either way the
48
+ // report says `conflicted` and the caller makes the verb fail on it. The plan
49
+ // names the second kind apart (`dropped`), since no marker in the file shows
50
+ // it.
51
+ //
52
+ // A key that the root's marker would receive as a default and that the template
53
+ // of any nested site of the repo declares, planned or not, or that a nested
54
+ // marker already answers, is refused before anything is written: it would
55
+ // stand in two markers, which no marker may do. The manifests are read from the
56
+ // new side's root; a nested site's template that cannot be read there is
57
+ // refused as well, since the check cannot be made without it. A render error is
58
+ // listed once, with the sides it came from.
59
+ import { join } from 'node:path';
60
+ import { loadTemplate, readTemplate } from "./bundled.js";
61
+ import { write } from "./effects.js";
62
+ import { engine } from "./engine.js";
63
+ import { MARKER_FILE, setMarkerKeys } from "./marker.js";
64
+ const isRendered = (side) => 'tree' in side;
65
+ /** An error as a line naming the site and what it concerns. */
66
+ export const describeError = (dir, e) => {
67
+ const about = [e.template && `template ${e.template}`, e.path, e.question && `question ${e.question}`].filter(Boolean);
68
+ return `${dir}: ${e.message}${about.length > 0 ? ` (${about.join(', ')})` : ''}`;
69
+ };
70
+ /** Errors by line, each with the sides it came from, so that one found on both is listed once. */
71
+ class Errors {
72
+ lines = new Map();
73
+ add(line, label) {
74
+ this.lines.set(line, (this.lines.get(line) ?? new Set()).add(label));
75
+ }
76
+ get any() {
77
+ return this.lines.size > 0;
78
+ }
79
+ toString() {
80
+ return [...this.lines].map(([line, labels]) => `${line} [${[...labels].join(' and ')}]`).join('\n');
81
+ }
82
+ }
83
+ /** The render of a source with `templates`; its problems go to `errors`. */
84
+ async function renderSource(templates, dir, source, label, errors) {
85
+ if (templates.render) {
86
+ const { rendered, errors: found } = await templates.render(source.templates, source.answers);
87
+ for (const e of found)
88
+ errors.add(`${dir}: ${e}`, label);
89
+ return found.length > 0 ? undefined : rendered;
90
+ }
91
+ const { render } = await engine();
92
+ const trees = [];
93
+ for (const name of source.templates) {
94
+ try {
95
+ trees.push((await readTemplate(templates.root, name)).tree);
96
+ }
97
+ catch (error) {
98
+ errors.add(`${dir}: ${error.message}`, label);
99
+ }
100
+ }
101
+ if (trees.length < source.templates.length)
102
+ return undefined;
103
+ const result = render(trees, source.answers);
104
+ for (const e of result.errors)
105
+ errors.add(describeError(dir, e), label);
106
+ if (result.errors.length > 0)
107
+ return undefined;
108
+ return { tree: result.tree, policies: result.files, answers: result.answers };
109
+ }
110
+ /**
111
+ * The merge of each of `sites` into the repo at `repo`, as the header says;
112
+ * `templates` is the root of templates both sides are rendered from, or each
113
+ * side's own.
114
+ */
115
+ export async function planSync(ctx, repo, templates, sites, options = {}) {
116
+ const { planMerge } = await engine();
117
+ const sides = typeof templates === 'string' ? { old: { root: templates }, new: { root: templates } } : templates;
118
+ const labels = options.labels ?? { old: 'old side', new: 'new side' };
119
+ const errors = new Errors();
120
+ const rendered = [];
121
+ let rootSides;
122
+ for (const site of [...sites].sort((a, b) => Number(b.dir === '.') - Number(a.dir === '.'))) {
123
+ const nested = site.dir !== '.';
124
+ // A nested site's answers are the root's, resolved defaults included, plus its own.
125
+ const old = isRendered(site.old)
126
+ ? site.old
127
+ : await renderSource(sides.old, site.dir, { ...site.old, answers: { ...(nested ? rootSides?.old.answers : {}), ...site.old.answers } }, labels.old, errors);
128
+ const given = { ...(nested ? rootSides?.new.answers : {}), ...site.new.answers };
129
+ const next = await renderSource(sides.new, site.dir, { ...site.new, answers: given }, labels.new, errors);
130
+ if (!old || !next)
131
+ continue;
132
+ if (!nested)
133
+ rootSides = { old, new: next };
134
+ rendered.push({ site, old, new: next, given });
135
+ }
136
+ if (errors.any)
137
+ throw new Error(errors.toString());
138
+ const defaultsOf = ({ old, new: next, given }) => Object.fromEntries(Object.entries(next.answers).filter(([key]) => !(key in given) && !(key in old.answers)));
139
+ const rootEntry = rendered.find((r) => r.site.dir === '.');
140
+ const doubled = await doubledKeys(sides.new.root, rootEntry && { templates: rootEntry.site.new.templates, defaults: defaultsOf(rootEntry) }, options.siblings ?? []);
141
+ if (doubled.length > 0)
142
+ throw new Error(doubled.join('\n'));
143
+ const merges = [];
144
+ const markers = [];
145
+ const planned = [];
146
+ const dropped = {};
147
+ if (options.version !== undefined && !rootEntry)
148
+ throw new Error('the version goes into the root marker, and the root is not among the sites');
149
+ for (const entry of rendered) {
150
+ const { dir, contextOnly } = entry.site;
151
+ const defaults = contextOnly ? {} : defaultsOf(entry);
152
+ const keys = { ...defaults, ...(dir === '.' && options.version !== undefined ? { version: options.version } : {}) };
153
+ if (Object.keys(keys).length > 0) {
154
+ const path = join(repo, dir, MARKER_FILE);
155
+ markers.push(write(path, setMarkerKeys(await ctx.readFile(path), keys)));
156
+ }
157
+ if (contextOnly)
158
+ continue;
159
+ const plan = await planMerge(join(repo, dir), entry.old, entry.new);
160
+ merges.push({ dir, plan });
161
+ planned.push({ dir, report: plan.report, defaults });
162
+ dropped[dir] = plan.report
163
+ .filter((e) => e.outcome === 'conflicted' && !entry.new.tree.has(e.path))
164
+ .map((e) => e.path);
165
+ }
166
+ return {
167
+ sites: planned,
168
+ conflicted: planned.flatMap((s) => s.report).filter((e) => e.outcome === 'conflicted').length,
169
+ dropped,
170
+ async perform() {
171
+ for (const { dir, plan } of merges) {
172
+ for (const { path, outcome } of plan.report)
173
+ ctx.say(`${ctx.dryRun ? '[dry-run] ' : ''}${outcome} ${join(dir, path)}`);
174
+ if (!ctx.dryRun)
175
+ await plan.apply();
176
+ }
177
+ await ctx.apply(markers);
178
+ },
179
+ };
180
+ }
181
+ /**
182
+ * The refusals for a root default that would stand in two markers: a nested
183
+ * site declares it, or answers it. A nested site's template that cannot be
184
+ * read is refused too, since whether it declares the key cannot be told: a
185
+ * check that cannot be made is not passed. Where the nested site is rendered
186
+ * as well, its render reports the template first; one that is not rendered, or
187
+ * whose manifest only this plx cannot read (another version's), meets it here.
188
+ */
189
+ async function doubledKeys(root, rootSide, siblings) {
190
+ if (!rootSide)
191
+ return [];
192
+ const lines = [];
193
+ const fix = 'a key is answered in one marker only: answer it in the root marker and remove it from the nested one';
194
+ const questionsOf = async (name) => loadTemplate(root, name).then((manifest) => manifest.questions.map((q) => q.name), (error) => error);
195
+ for (const key of Object.keys(rootSide.defaults)) {
196
+ let rootTemplate;
197
+ for (const name of rootSide.templates) {
198
+ const questions = await questionsOf(name);
199
+ if (!rootTemplate && Array.isArray(questions) && questions.includes(key))
200
+ rootTemplate = name;
201
+ }
202
+ const where = `${MARKER_FILE} would get \`${key}\` as the default of ${rootTemplate ? `template ${rootTemplate}` : 'a template of its own'}`;
203
+ for (const { dir, templates, answers } of siblings) {
204
+ const marker = join(dir, MARKER_FILE);
205
+ for (const name of templates) {
206
+ const questions = await questionsOf(name);
207
+ if (questions instanceof Error)
208
+ lines.push(`${where}, and template ${name} of ${marker} cannot be read, so whether it declares it too cannot be told: ${questions.message}`);
209
+ else if (questions.includes(key))
210
+ lines.push(`${where}, and template ${name} of ${marker} declares it too: ${fix}`);
211
+ }
212
+ if (key in answers)
213
+ lines.push(`${where}, and ${marker} answers it already: ${fix}`);
214
+ }
215
+ }
216
+ return lines;
217
+ }
218
+ /**
219
+ * The answers a site's templates resolve to, with the given answers under
220
+ * them: what a nested site reads of the root. A render that fails gives the
221
+ * given answers alone; the error is the plan's to report.
222
+ */
223
+ export async function resolvedAnswers(root, source) {
224
+ const side = await renderSource({ root }, '.', source, '', new Errors());
225
+ return { ...source.answers, ...side?.answers };
226
+ }
227
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,6CAA6C;AAC7C,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,yEAAyE;AACzE,sEAAsE;AACtE,wEAAwE;AACxE,0EA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,CAAC,CAAC;IACzE,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;AACjD,CAAC"}
package/dist/take.d.ts CHANGED
@@ -1,16 +1,23 @@
1
- import type { Consumer, Site } from './consumers.ts';
1
+ import type { Consumer } from './consumers.ts';
2
2
  import type { Context } from './context.ts';
3
- import { type Review, type Reviewers } from './pull.ts';
4
- /** What became of one site: merged clean, left with conflicts, or its copier run failed (`detail` says why). */
3
+ import { type PinGap, type Review, type Reviewers } from './pull.ts';
4
+ /** What became of one site: merged clean, left with conflicts, or its step failed (`detail` says why). */
5
5
  export interface SiteResult {
6
+ /** The site as the run names it. */
6
7
  rel: string;
8
+ /** Its directory relative to the repo, `.` for the root. */
9
+ dir: string;
7
10
  outcome: 'clean' | 'conflicted' | 'failed';
8
11
  detail?: string;
12
+ /** Paths relative to the repo that the merge left with markers in them, where the step knows them. */
13
+ conflicts?: string[];
14
+ /** Paths relative to the repo of edited files the version drops, kept without markers. */
15
+ kept?: string[];
9
16
  }
10
17
  /** What one consumer's taking of the version came to, as data: the caller folds it into a summary. */
11
18
  export interface Taken {
12
19
  rel: string;
13
- /** Every site, in the order they were updated. */
20
+ /** Every site, in the order they were brought to the version. */
14
21
  sites: SiteResult[];
15
22
  /** The lockfile refresh, where manifests moved; undefined when nothing needed one. */
16
23
  lockfile?: 'refreshed' | 'failed';
@@ -24,47 +31,35 @@ export interface Taken {
24
31
  };
25
32
  /** Why the commit, the push or the pull request failed, when one did. */
26
33
  failed?: string;
34
+ /** The root marker names the version, and the `plx` pin does not, once the sites are brought to it. */
35
+ pin?: PinGap;
27
36
  /** The users asked to review the pull request, or why asking them failed. */
28
37
  review?: Review;
29
38
  }
30
39
  /** Whether the consumer needs a hand beyond reviewing its pull request. */
31
40
  export declare const needsHand: (t: Taken) => boolean;
32
41
  /**
33
- * How a site is brought to the version in the scratch checkout: `target` is
34
- * the site's directory there, `dir` the checkout's root. The default runs
35
- * copier against the published template; the maintainers' preview of an
36
- * unreleased version (preview.ts of @plexus-ms/dev) brings its own, against
37
- * the local template checkouts. Whatever it leaves is then judged and
38
- * staged the same way.
42
+ * How the sites are brought to the version in the scratch checkout `dir`, its
43
+ * files and markers changed in place, and what became of each. A step that
44
+ * throws stops the taking before anything is committed.
39
45
  */
40
- export type SiteUpdate = (ctx: Context, site: Site, target: string, dir: string) => Promise<void>;
46
+ export type SitesStep = (ctx: Context, consumer: Consumer, dir: string) => Promise<SiteResult[]>;
41
47
  /** How a consumer takes the version. */
42
48
  export interface Take {
43
49
  version: string;
44
- /** The template ref copier updates to; unset, copier takes the newest tag. */
45
- ref?: string;
46
50
  /** Who opened the pull request, named in its body. */
47
51
  opener: string;
48
52
  /** Why the repo takes the version now (need.ts), named in the body beside the opener. */
49
53
  why?: string;
50
- /** How each site is updated; default: copier against the published template, at `ref`. */
51
- update?: SiteUpdate;
52
- /** Who is asked to review the pull request when it is opened; default: the root answers' `pr_reviewers` after copier ran. */
54
+ /** How the sites are brought to the version. */
55
+ sites: SitesStep;
56
+ /** Who is asked to review the pull request when it is opened; default: the root marker's `pr_reviewers` once the sites are brought to it. */
53
57
  reviewers?: Reviewers;
54
58
  }
55
- /**
56
- * copier at the version plx pins, through mise, with the consumer's own mise
57
- * config ignored: copier needs no project tool, and a root `mise.toml` left
58
- * with conflict markers by the root site's update would otherwise fail every
59
- * later mise call in the directory, the apps' updates first of all.
60
- */
61
- export declare const copierIn: (dir: string, args: string[]) => [string, string[]];
62
59
  /**
63
60
  * One consumer takes the version in `dir`, a scratch checkout of its branch:
64
61
  * every site updated, the lockfile refreshed, the workflow refs bumped, then
65
62
  * the commit, the branch and the pull request.
66
63
  */
67
64
  export declare function takeVersion(ctx: Context, consumer: Consumer, dir: string, take: Take): Promise<Taken>;
68
- /** A commit of plain plumbing on a scratch checkout: unsigned, no hooks, a stand-in identity. */
69
- export declare const scratchCommit: (ctx: Context, dir: string, message: string) => Promise<string | undefined>;
70
65
  //# sourceMapp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GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAO3G"}
package/dist/take.js CHANGED
@@ -1,44 +1,38 @@
1
1
  // take: one repo takes a version (§ 3 PLX-Updates), in a scratch checkout of the
2
- // branch the version lands on (consumers.ts). `copier update` runs at the
3
- // version plx pins (copier.ts) at every site (the repo root, then its apps/*),
4
- // the lockfile refreshed where manifests moved, the hand-owned workflows pinned to the version; then one
5
- // commit, pushed as `plexus/<version>`, and a pull request against the branch.
6
- // A conflict is committed with its markers and reported, and the pull request
7
- // is opened all the same, as a draft where the forge offers one, whose body
8
- // opens with what needs a hand (pull.ts): that is where it gets resolved. Nothing here aborts
9
- // a run: what became of each site, the lockfile and the pull request is
10
- // returned as data (`Taken`), which the caller folds into the summary that
11
- // says what needs a human (summary.ts). Reviewing and merging the pull
12
- // request stays human.
2
+ // branch the version lands on (consumers.ts): its sites brought to the
3
+ // version by the caller's step, the lockfile refreshed where manifests moved,
4
+ // the hand-owned workflows pinned to the version; then one commit, pushed as
5
+ // `plexus/<version>`, whose message names each site's conflicted paths and
6
+ // the edited files the version drops, and a pull request against the branch. A conflict is
7
+ // committed with its markers and reported, and the pull request is opened all
8
+ // the same, as a draft where the forge offers one, whose body opens with what
9
+ // needs a hand (pull.ts): that is where it gets resolved. Nothing here aborts
10
+ // a run but the sites' step itself: what became of each site, the lockfile and
11
+ // the pull request is returned as data (`Taken`), which the caller folds into
12
+ // the summary that says what needs a human (summary.ts). Reviewing and merging
13
+ // the pull request stays human.
13
14
  //
14
15
  // `update` (update.ts) is the verb on top of it, and the only thing that
15
- // opens a version's pull request; `update --recursive` (recursive.ts) runs
16
- // that verb over many repos. The maintainers' preview of an unreleased
17
- // version (preview.ts of @plexus-ms/dev) uses the same steps with its own
18
- // `SiteUpdate`, against the local template checkouts, and opens nothing.
19
- import { join, relative } from 'node:path';
16
+ // opens a version's pull request, with the engine's step: both sides rendered
17
+ // and merged at every site, the version written into the root marker.
18
+ // `update --recursive` (recursive.ts) runs that verb over many repos. The
19
+ // maintainers' preview of an unreleased version (preview.ts of @plexus-ms/dev)
20
+ // uses the same steps with a step of its own, copier against the local
21
+ // template checkouts, under a dry run, and opens nothing.
22
+ import { join } from 'node:path';
20
23
  import { bumpWorkflowRefs, WORKFLOW_REF } from "./bookkeeping.js";
21
- import { filesWithConflictMarkers, hasConflictMarkers, hasUnmergedEntries } from "./conflicts.js";
22
- import { ANSWERS_FILE, copierVia, parseAnswers, setAnswer } from "./copier.js";
24
+ import { filesWithConflictMarkers } from "./conflicts.js";
23
25
  import { run, write } from "./effects.js";
24
26
  import { detailOf } from "./io.js";
25
- import { askForReviews, createPull, needsAHand, pullBody, pullOf, versionBranch, } from "./pull.js";
26
- import { namesOldTemplate, templateSource } from "./templates.js";
27
+ import { MARKER_FILE } from "./marker.js";
28
+ import { MISE_FILE } from "./overview.js";
29
+ import { askForReviews, commitMessage, createPull, needsAHand, pinGap, pinSaid, pullBody, pullOf, versionBranch, } from "./pull.js";
27
30
  /** Whether the consumer needs a hand beyond reviewing its pull request. */
28
31
  export const needsHand = (t) => t.sites.some((s) => s.outcome !== 'clean') ||
29
32
  (t.marked?.length ?? 0) > 0 ||
30
33
  t.lockfile === 'failed' ||
31
- t.failed !== undefined;
32
- /**
33
- * copier at the version plx pins, through mise, with the consumer's own mise
34
- * config ignored: copier needs no project tool, and a root `mise.toml` left
35
- * with conflict markers by the root site's update would otherwise fail every
36
- * later mise call in the directory, the apps' updates first of all.
37
- */
38
- export const copierIn = (dir, args) => [
39
- 'env',
40
- [`MISE_IGNORED_CONFIG_PATHS=${dir}`, 'mise', ...copierVia(args)],
41
- ];
34
+ t.failed !== undefined ||
35
+ t.pin !== undefined;
42
36
  /**
43
37
  * One consumer takes the version in `dir`, a scratch checkout of its branch:
44
38
  * every site updated, the lockfile refreshed, the workflow refs bumped, then
@@ -46,102 +40,12 @@ export const copierIn = (dir, args) => [
46
40
  */
47
41
  export async function takeVersion(ctx, consumer, dir, take) {
48
42
  const base = (await ctx.read('git', ['rev-parse', 'HEAD'], { cwd: dir })).trim();
49
- const update = take.update ?? fromTemplate(take.ref);
50
- const sites = [];
51
- for (const site of consumer.sites)
52
- sites.push(await updateSite(ctx, consumer, site, dir, update));
43
+ const sites = await take.sites(ctx, consumer, dir);
53
44
  const lockfile = await refreshLockfile(ctx, consumer, dir, base);
54
45
  await bumpConsumerRefs(ctx, consumer, dir, take.version);
55
46
  const taken = { rel: consumer.rel, sites, ...(lockfile ? { lockfile } : {}) };
56
47
  return { ...taken, ...(await openPull(ctx, consumer, dir, base, take, taken)) };
57
48
  }
58
- /** A commit of plain plumbing on a scratch checkout: unsigned, no hooks, a stand-in identity. */
59
- export const scratchCommit = (ctx, dir, message) => ctx
60
- .stage(run('git', ['add', '-A'], { cwd: dir }))
61
- .then(() => ctx.stage(run('git', [
62
- '-c',
63
- 'commit.gpgsign=false',
64
- '-c',
65
- 'user.name=plx',
66
- '-c',
67
- 'user.email=plx@localhost',
68
- 'commit',
69
- '--quiet',
70
- '--no-verify',
71
- '--allow-empty',
72
- '-m',
73
- message,
74
- ], { cwd: dir })));
75
- /** copier against the published template, at `ref`. */
76
- const fromTemplate = (ref) => async (ctx, site, target, dir) => {
77
- ctx.say(`→ ${site.rel}: copier update${ref ? ` to ${ref}` : ''}`);
78
- // A template renamed on a version: the answers still name the old source,
79
- // which copier would clone through the forge's redirect; point them at
80
- // the current name first, committed because copier refuses a dirty
81
- // subproject.
82
- const answers = await ctx.readFile(join(target, ANSWERS_FILE));
83
- const current = templateSource(site.template);
84
- const recorded = parseAnswers(answers).src;
85
- if (recorded && namesOldTemplate(recorded)) {
86
- ctx.say(` ${site.rel}: the template is ${current} now; the answers follow`);
87
- await ctx.stage(write(join(target, ANSWERS_FILE), setAnswer(answers, '_src_path', current)));
88
- await scratchCommit(ctx, dir, `plx: ${site.rel} reads ${current}, the template's name since its rename`);
89
- }
90
- // Template tasks (mise install, hook setup) serve a developer's checkout,
91
- // not a pull request. Unattended, a new question takes its default; on a
92
- // terminal copier asks. A dry run previews on the scratch checkout, so
93
- // the step is staged there rather than only announced.
94
- const args = [
95
- 'update',
96
- '--skip-answered',
97
- '--trust',
98
- '--skip-tasks',
99
- ...(ref ? ['--vcs-ref', ref] : []),
100
- ...(ctx.yes || ctx.dryRun ? ['--defaults'] : []),
101
- ];
102
- const step = run(...copierIn(dir, args), { cwd: target, interactive: !ctx.dryRun });
103
- if (ctx.dryRun)
104
- await ctx.stage(step);
105
- else
106
- await ctx.apply([step]);
107
- };
108
- async function updateSite(ctx, consumer, site, dir, update) {
109
- const target = join(dir, relative(consumer.path, site.path));
110
- try {
111
- await update(ctx, site, target, dir);
112
- }
113
- catch (error) {
114
- const why = detailOf(error);
115
- ctx.say(` ✗ FAILED — copier update exited nonzero${why ? `: ${why}` : ''}`);
116
- return { rel: site.rel, outcome: 'failed', ...(why ? { detail: why } : {}) };
117
- }
118
- // copier applies the template diff with `git apply --3way`, which leaves
119
- // unmerged index entries and inline markers when a hunk does not apply.
120
- // Scoped to the site: the root site's changes are still in the tree when
121
- // its apps are updated.
122
- const status = await ctx.read('git', ['status', '--porcelain', '--', '.'], { cwd: target });
123
- let conflict = hasUnmergedEntries(status);
124
- const changed = (await ctx.read('git', ['diff', '--name-only', '--relative', '--', '.'], { cwd: target }))
125
- .split('\n')
126
- .filter(Boolean);
127
- for (const f of changed) {
128
- const text = await ctx.readFile(join(target, f)).catch(() => '');
129
- if (hasConflictMarkers(text))
130
- conflict = true;
131
- }
132
- if (conflict)
133
- ctx.say(' ✗ CONFLICTS — committed with their <<<<<<< markers, to resolve in the pull request:');
134
- else
135
- ctx.say(' ✓ merged clean:');
136
- for (const line of status.split('\n').filter(Boolean))
137
- ctx.say(` ${line}`);
138
- // Staged, so that the next site starts from a whole index: a conflict
139
- // leaves unmerged entries, and copier's own git plumbing (`git
140
- // write-tree`) refuses an index with those, so the next site's update
141
- // would fail; staged, the markers are in the tree and the index is whole.
142
- await ctx.stage(run('git', ['add', '-A'], { cwd: dir }));
143
- return { rel: site.rel, outcome: conflict ? 'conflicted' : 'clean' };
144
- }
145
49
  /**
146
50
  * Refresh the lockfile when the updates touched a manifest (`mise exec` trusts the directory's own config).
147
51
  * The lockfile is what this step writes, so the install is never frozen: pnpm freezes it by default under CI,
@@ -195,8 +99,9 @@ async function bumpConsumerRefs(ctx, consumer, dir, version) {
195
99
  * already on origin is never moved (pull.ts). Hooks are skipped: the checks
196
100
  * are the pull request's job, and the mount's own checkout may carry the
197
101
  * repo's hooks. The pull request is a draft when anything needs a hand, and
198
- * its body says what, from what the sites and the lockfile came to and the
199
- * detector over the committed tree.
102
+ * its body says what, from what the sites and the lockfile came to, the
103
+ * detector over the committed tree, and the `plx` pin of the root `mise.toml`
104
+ * where the root marker names the version and the pin does not.
200
105
  */
201
106
  async function openPull(ctx, consumer, dir, base, take, taken) {
202
107
  const { version } = take;
@@ -213,11 +118,11 @@ async function openPull(ctx, consumer, dir, base, take, taken) {
213
118
  const head = `${consumer.origin ?? 'origin'} ${branch}`;
214
119
  try {
215
120
  await ctx.apply([
216
- // Staged first: a site whose copier run failed mid-merge can leave unmerged entries, which a reset refuses.
121
+ // Staged first: a site's step can leave unmerged entries, which a reset refuses.
217
122
  run('git', ['add', '-A'], { cwd: dir }),
218
- // One commit on the branch, the scratch ones folded in: a later run tells it from a human's by the count.
123
+ // One commit on the branch, any scratch ones folded in: a later run tells it from a human's by the count.
219
124
  run('git', ['reset', '--quiet', '--soft', base], { cwd: dir }),
220
- run('git', ['commit', '--quiet', '--no-verify', '-m', `chore: Plexus ${version}`], { cwd: dir }),
125
+ run('git', ['commit', '--quiet', '--no-verify', '-m', commitMessage(version, taken.sites)], { cwd: dir }),
221
126
  // An empty expected value: the branch must not exist on origin yet.
222
127
  run('git', [
223
128
  'push',
@@ -235,18 +140,26 @@ async function openPull(ctx, consumer, dir, base, take, taken) {
235
140
  return { failed: `push to ${head}${why ? `: ${why}` : ''}` };
236
141
  }
237
142
  const marked = await filesWithConflictMarkers(ctx, dir);
238
- const of = (outcome) => taken.sites.filter((s) => s.outcome === outcome).map((s) => siteOf(consumer, s.rel));
143
+ const read = (file) => ctx.readFile(join(dir, file)).catch(() => undefined);
144
+ const pin = pinGap(version, await read(MARKER_FILE), await read(MISE_FILE));
145
+ const gap = pin ? { pin } : {};
146
+ const of = (outcome) => taken.sites.filter((s) => s.outcome === outcome).map((s) => s.dir);
239
147
  const state = {
240
148
  version,
241
- sites: consumer.sites.map((s) => relative(consumer.path, s.path) || '.'),
149
+ sites: taken.sites.map((s) => s.dir),
242
150
  conflicted: of('conflicted'),
243
151
  marked,
244
152
  failed: of('failed'),
245
153
  lockfile: taken.lockfile === 'failed',
154
+ ...gap,
155
+ conflicts: Object.fromEntries(taken.sites.map((s) => [s.dir, s.conflicts ?? []])),
156
+ kept: Object.fromEntries(taken.sites.map((s) => [s.dir, s.kept ?? []])),
246
157
  note: `Opened by ${take.opener}${take.why ? `: ${take.why}` : ''}.`,
247
158
  };
248
159
  if (marked.length > 0)
249
160
  ctx.say(` ${consumer.rel}: conflict markers in ${marked.join(', ')}`);
161
+ if (pin)
162
+ ctx.say(` ${consumer.rel}: ${pinSaid(pin, version)}`);
250
163
  let draft;
251
164
  try {
252
165
  draft = await createPull(ctx, consumer.rel, { base: consumer.branch, version, body: pullBody(state), draft: needsAHand(state) }, dir);
@@ -254,7 +167,7 @@ async function openPull(ctx, consumer, dir, base, take, taken) {
254
167
  catch (error) {
255
168
  const why = detailOf(error);
256
169
  ctx.say(` ✗ FAILED — pull request${why ? `: ${why}` : ''}`);
257
- return { marked, failed: `pull request${why ? `: ${why}` : ''}` };
170
+ return { marked, ...gap, failed: `pull request${why ? `: ${why}` : ''}` };
258
171
  }
259
172
  // Asking the forge for what it opened is a read like any other: a failure is reported, never "none".
260
173
  let opened;
@@ -264,23 +177,16 @@ async function openPull(ctx, consumer, dir, base, take, taken) {
264
177
  catch (error) {
265
178
  const why = detailOf(error);
266
179
  ctx.say(` ✗ FAILED — ${consumer.rel}: the pull request opened, but listing it failed${why ? `: ${why}` : ''}`);
267
- return { marked, pull: { branch, draft }, failed: `listing the pull request: ${why}` };
180
+ return { marked, ...gap, pull: { branch, draft }, failed: `listing the pull request: ${why}` };
268
181
  }
269
182
  const url = opened?.url;
270
183
  ctx.say(`• ${consumer.rel}: ${draft ? 'draft ' : ''}pull request opened${url ? `: ${url}` : ''}`);
271
184
  const pull = { branch, draft, ...(url ? { url } : {}) };
272
185
  if (!opened)
273
- return { marked, pull, failed: 'the forge did not list the pull request it opened' };
274
- // Unless named, from the root answers as copier left them at every site: a renamed or changed answer counts.
275
- const from = take.reviewers ?? {
276
- answersFile: await ctx.readFile(join(dir, ANSWERS_FILE)).catch(() => ''),
277
- };
186
+ return { marked, ...gap, pull, failed: 'the forge did not list the pull request it opened' };
187
+ // Unless named, from the root marker as the sites' step left it: a default it wrote counts.
188
+ const from = take.reviewers ?? { marker: await ctx.readFile(join(dir, MARKER_FILE)).catch(() => '') };
278
189
  const review = await askForReviews(ctx, consumer.rel, opened, from, dir);
279
- return { marked, pull, ...(review ? { review } : {}) };
280
- }
281
- /** A site's name in the run, as the repo names it: `.` for its root. */
282
- function siteOf(consumer, rel) {
283
- const s = consumer.sites.find((x) => x.rel === rel);
284
- return s ? relative(consumer.path, s.path) || '.' : rel;
190
+ return { marked, ...gap, pull, ...(review ? { review } : {}) };
285
191
  }
286
192
  //# sourceMappingURL=take.js.map