@plexus-ms/lib 0.130.0 → 0.132.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 (109) hide show
  1. package/dist/apply.d.ts +25 -0
  2. package/dist/apply.d.ts.map +1 -0
  3. package/dist/apply.js +204 -0
  4. package/dist/apply.js.map +1 -0
  5. package/dist/bookkeeping.js +3 -3
  6. package/dist/bookkeeping.js.map +1 -1
  7. package/dist/bundled.d.ts +15 -0
  8. package/dist/bundled.d.ts.map +1 -0
  9. package/dist/bundled.js +42 -0
  10. package/dist/bundled.js.map +1 -0
  11. package/dist/changeset.js +3 -3
  12. package/dist/changeset.js.map +1 -1
  13. package/dist/consumers.d.ts +6 -35
  14. package/dist/consumers.d.ts.map +1 -1
  15. package/dist/consumers.js +45 -83
  16. package/dist/consumers.js.map +1 -1
  17. package/dist/doctor.d.ts +17 -1
  18. package/dist/doctor.d.ts.map +1 -1
  19. package/dist/doctor.js +167 -11
  20. package/dist/doctor.js.map +1 -1
  21. package/dist/engine.d.ts +2 -0
  22. package/dist/engine.d.ts.map +1 -0
  23. package/dist/engine.js +9 -0
  24. package/dist/engine.js.map +1 -0
  25. package/dist/frontmatter.d.ts.map +1 -1
  26. package/dist/frontmatter.js +6 -5
  27. package/dist/frontmatter.js.map +1 -1
  28. package/dist/index.d.ts +13 -8
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +14 -9
  31. package/dist/index.js.map +1 -1
  32. package/dist/io.d.ts +1 -1
  33. package/dist/marker.d.ts +38 -0
  34. package/dist/marker.d.ts.map +1 -1
  35. package/dist/marker.js +269 -16
  36. package/dist/marker.js.map +1 -1
  37. package/dist/model.d.ts +15 -17
  38. package/dist/model.d.ts.map +1 -1
  39. package/dist/model.js +19 -21
  40. package/dist/model.js.map +1 -1
  41. package/dist/need.d.ts +1 -1
  42. package/dist/need.d.ts.map +1 -1
  43. package/dist/need.js +2 -2
  44. package/dist/need.js.map +1 -1
  45. package/dist/newSite.d.ts +31 -0
  46. package/dist/newSite.d.ts.map +1 -0
  47. package/dist/newSite.js +184 -0
  48. package/dist/newSite.js.map +1 -0
  49. package/dist/overview.d.ts +5 -9
  50. package/dist/overview.d.ts.map +1 -1
  51. package/dist/overview.js +26 -51
  52. package/dist/overview.js.map +1 -1
  53. package/dist/pull.d.ts +48 -21
  54. package/dist/pull.d.ts.map +1 -1
  55. package/dist/pull.js +183 -67
  56. package/dist/pull.js.map +1 -1
  57. package/dist/recursive.d.ts.map +1 -1
  58. package/dist/recursive.js +7 -5
  59. package/dist/recursive.js.map +1 -1
  60. package/dist/requirements.d.ts +1 -1
  61. package/dist/requirements.d.ts.map +1 -1
  62. package/dist/requirements.js +11 -13
  63. package/dist/requirements.js.map +1 -1
  64. package/dist/siteTemplates.d.ts +14 -0
  65. package/dist/siteTemplates.d.ts.map +1 -0
  66. package/dist/siteTemplates.js +107 -0
  67. package/dist/siteTemplates.js.map +1 -0
  68. package/dist/sites.d.ts +24 -0
  69. package/dist/sites.d.ts.map +1 -0
  70. package/dist/sites.js +89 -0
  71. package/dist/sites.js.map +1 -0
  72. package/dist/standard-index.json +1 -1
  73. package/dist/summary.d.ts +1 -1
  74. package/dist/summary.d.ts.map +1 -1
  75. package/dist/summary.js +6 -1
  76. package/dist/summary.js.map +1 -1
  77. package/dist/sync.d.ts +86 -0
  78. package/dist/sync.d.ts.map +1 -0
  79. package/dist/sync.js +227 -0
  80. package/dist/sync.js.map +1 -0
  81. package/dist/take.d.ts +20 -25
  82. package/dist/take.d.ts.map +1 -1
  83. package/dist/take.js +48 -142
  84. package/dist/take.js.map +1 -1
  85. package/dist/templatesRoot.d.ts +5 -0
  86. package/dist/templatesRoot.d.ts.map +1 -0
  87. package/dist/templatesRoot.js +37 -0
  88. package/dist/templatesRoot.js.map +1 -0
  89. package/dist/update.d.ts +48 -10
  90. package/dist/update.d.ts.map +1 -1
  91. package/dist/update.js +173 -78
  92. package/dist/update.js.map +1 -1
  93. package/dist/version.d.ts +2 -2
  94. package/dist/version.d.ts.map +1 -1
  95. package/dist/version.js +2 -8
  96. package/dist/version.js.map +1 -1
  97. package/dist/versionTemplates.d.ts +24 -0
  98. package/dist/versionTemplates.d.ts.map +1 -0
  99. package/dist/versionTemplates.js +168 -0
  100. package/dist/versionTemplates.js.map +1 -0
  101. package/package.json +2 -1
  102. package/dist/copier.d.ts +0 -17
  103. package/dist/copier.d.ts.map +0 -1
  104. package/dist/copier.js +0 -35
  105. package/dist/copier.js.map +0 -1
  106. package/dist/templates.d.ts +0 -21
  107. package/dist/templates.d.ts.map +0 -1
  108. package/dist/templates.js +0 -55
  109. package/dist/templates.js.map +0 -1
package/dist/summary.js CHANGED
@@ -45,9 +45,12 @@ export function summarize(outcomes, preview, version = outcomes.find((o) => o.ve
45
45
  // Files that still hold markers need a human, like a conflicted site.
46
46
  for (const file of o.marked)
47
47
  s.conflicted.push(inRun(o.repo, file));
48
- // A site copier did not run at needs a human to run it.
48
+ // A branch not at the version needs a human to bring it there.
49
49
  for (const site of o.behind)
50
50
  s.failed.push(`${site === '.' ? o.repo : inRun(o.repo, site)} (not at ${o.version})`);
51
+ // A pin the version did not move needs a human to move it.
52
+ if (o.pin)
53
+ s.failed.push(`${o.repo} (plx pin not at ${o.version})`);
51
54
  if (o.failed !== undefined)
52
55
  s.failed.push(o.repo);
53
56
  if (o.pull)
@@ -73,6 +76,8 @@ export function summarize(outcomes, preview, version = outcomes.find((o) => o.ve
73
76
  }
74
77
  if (t.lockfile === 'failed')
75
78
  s.failed.push(`${t.rel}/pnpm-lock.yaml`);
79
+ if (t.pin)
80
+ s.failed.push(`${t.rel} (plx pin not at ${o.version})`);
76
81
  if (t.failed !== undefined)
77
82
  s.failed.push(t.rel);
78
83
  if (t.pull)
@@ -1 +1 @@
1
- {"version":3,"file":"summary.js","sourceRoot":"","sources":["../src/summary.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,uEAAuE;AACvE,yEAAyE;AACzE,w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,KAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACrD,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,sCAAsC,WAAW,EAAE,CAAC,CAAC;IAC7E,CAAC;SAAM,IAAI,KAAK,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,6CAA6C,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC;IAC9G,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,4DAA4D,IAAI,EAAE,CAAC,CAAC;IAC3F,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
package/dist/sync.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ import type { Answers, MergeEntry, RenderError, RenderedSide } from '@plexus-ms/cli-template';
2
+ import type { Context } from './context.ts';
3
+ /** Templates, by name below a root, and the answers to render them with. */
4
+ export interface Source {
5
+ readonly templates: readonly string[];
6
+ readonly answers: Answers;
7
+ }
8
+ /** A render that arrived as a tree: its policies, and the answers it resolved. */
9
+ export interface Rendered extends RenderedSide {
10
+ readonly answers: Answers;
11
+ }
12
+ /** A render of templates by name with answers, by another engine than this plx's: the render, or why there is none. */
13
+ export type RenderTemplates = (names: readonly string[], answers: Answers) => Promise<{
14
+ rendered?: Rendered;
15
+ errors: readonly string[];
16
+ }>;
17
+ /** Where one side's sources are rendered from: a root of templates, and the render of another engine where it is not this plx's. */
18
+ export interface Templates {
19
+ /** The directory that holds one directory per template. */
20
+ readonly root: string;
21
+ /** Renders the templates below the root; default: this plx's engine. */
22
+ readonly render?: RenderTemplates;
23
+ }
24
+ /** The templates of each side. */
25
+ export interface TemplateSides {
26
+ readonly old: Templates;
27
+ readonly new: Templates;
28
+ }
29
+ export interface SiteSides {
30
+ /** The site's directory relative to the repo, `.` for the root. */
31
+ readonly dir: string;
32
+ readonly old: Source | Rendered;
33
+ readonly new: Source;
34
+ /** Render the site for what it gives the nested sites, and merge nothing into it. */
35
+ readonly contextOnly?: boolean;
36
+ }
37
+ export interface SyncOptions {
38
+ /** What the old and the new side are called in an error. */
39
+ labels?: {
40
+ old: string;
41
+ new: string;
42
+ };
43
+ /** Every nested site of the repo, the ones not planned included: its templates and its marker's own answers. */
44
+ siblings?: readonly {
45
+ dir: string;
46
+ templates: readonly string[];
47
+ answers: Answers;
48
+ }[];
49
+ /** The version to write into the root marker, which must be among the sites; none: the version is left as it is. */
50
+ version?: string;
51
+ }
52
+ /** What planning decided for one site. */
53
+ export interface SiteMerge {
54
+ dir: string;
55
+ report: readonly MergeEntry[];
56
+ /** The answers to write into the site's marker. */
57
+ defaults: Record<string, unknown>;
58
+ }
59
+ export interface SyncPlan {
60
+ sites: SiteMerge[];
61
+ /** The paths reported `conflicted`, over all sites. */
62
+ conflicted: number;
63
+ /**
64
+ * By site, the paths reported `conflicted` that the new render does not
65
+ * hold: files the version drops that the user edited, kept as they are, with
66
+ * no marker in them.
67
+ */
68
+ dropped: Readonly<Record<string, readonly string[]>>;
69
+ /** Writes the merges and the markers; narrated, and skipped under --dry-run. */
70
+ perform(): Promise<void>;
71
+ }
72
+ /** An error as a line naming the site and what it concerns. */
73
+ export declare const describeError: (dir: string, e: RenderError) => string;
74
+ /**
75
+ * The merge of each of `sites` into the repo at `repo`, as the header says;
76
+ * `templates` is the root of templates both sides are rendered from, or each
77
+ * side's own.
78
+ */
79
+ export declare function planSync(ctx: Context, repo: string, templates: string | TemplateSides, sites: readonly SiteSides[], options?: SyncOptions): Promise<SyncPlan>;
80
+ /**
81
+ * The answers a site's templates resolve to, with the given answers under
82
+ * them: what a nested site reads of the root. A render that fails gives the
83
+ * given answers alone; the error is the plan's to report.
84
+ */
85
+ export declare function resolvedAnswers(root: string, source: Source): Promise<Answers>;
86
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRo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AAC,CAGpF"}
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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E,EAAE,IAAI,MAAM,EAAE,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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