@plexus-ms/lib 0.115.0 → 0.116.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.
- package/dist/consumers.d.ts +2 -0
- package/dist/consumers.d.ts.map +1 -1
- package/dist/consumers.js +6 -3
- package/dist/consumers.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/need.d.ts +39 -0
- package/dist/need.d.ts.map +1 -0
- package/dist/need.js +69 -0
- package/dist/need.js.map +1 -0
- package/dist/preview.d.ts +4 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +60 -0
- package/dist/preview.js.map +1 -0
- package/dist/propagate.d.ts +13 -44
- package/dist/propagate.d.ts.map +1 -1
- package/dist/propagate.js +39 -351
- package/dist/propagate.js.map +1 -1
- package/dist/self.d.ts.map +1 -1
- package/dist/self.js.map +1 -1
- package/dist/ship.d.ts +4 -6
- package/dist/ship.d.ts.map +1 -1
- package/dist/ship.js +19 -15
- package/dist/ship.js.map +1 -1
- package/dist/take.d.ts +55 -0
- package/dist/take.d.ts.map +1 -0
- package/dist/take.js +316 -0
- package/dist/take.js.map +1 -0
- package/dist/update.d.ts +10 -4
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +66 -27
- package/dist/update.js.map +1 -1
- package/package.json +1 -1
package/dist/take.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Consumer } from './consumers.ts';
|
|
2
|
+
import type { Context } from './context.ts';
|
|
3
|
+
export interface Summary {
|
|
4
|
+
train: string;
|
|
5
|
+
/** True for a dry run: nothing in the workspace changed. */
|
|
6
|
+
preview: boolean;
|
|
7
|
+
/** Sites, relative to the workspace. */
|
|
8
|
+
clean: string[];
|
|
9
|
+
conflicted: string[];
|
|
10
|
+
/** Sites whose update exited nonzero, consumers that could not be cloned or pushed, and lockfiles that failed to refresh. */
|
|
11
|
+
failed: string[];
|
|
12
|
+
/** Consumers left untouched, with the reason. */
|
|
13
|
+
skipped: {
|
|
14
|
+
path: string;
|
|
15
|
+
reason: string;
|
|
16
|
+
}[];
|
|
17
|
+
/** Repos that need no train yet and rest on the one they have (need.ts), with what would end the rest. */
|
|
18
|
+
resting: {
|
|
19
|
+
path: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
}[];
|
|
22
|
+
/** The pull requests opened or updated, one per consumer that changed. */
|
|
23
|
+
pulls: string[];
|
|
24
|
+
}
|
|
25
|
+
/** True when nothing in the summary needs a human but the pull requests. */
|
|
26
|
+
export declare const isClean: (s: Summary) => boolean;
|
|
27
|
+
/** Add what one repo's run found to the summary of a run over many. */
|
|
28
|
+
export declare function mergeSummary(into: Summary, from: Summary): void;
|
|
29
|
+
export declare const emptySummary: (train: string, preview: boolean) => Summary;
|
|
30
|
+
export declare const trainBranch: (train: string) => string;
|
|
31
|
+
/** How a consumer takes the train: the knobs the preview and update set differently. */
|
|
32
|
+
export interface Take {
|
|
33
|
+
train: string;
|
|
34
|
+
/**
|
|
35
|
+
* Preview from the local preset checkouts under this upstream directory at
|
|
36
|
+
* main (preview.ts), instead of the published template.
|
|
37
|
+
*/
|
|
38
|
+
previewFrom?: string;
|
|
39
|
+
/** The template ref copier updates to; unset, copier takes the newest tag, which the train just cut. */
|
|
40
|
+
ref?: string;
|
|
41
|
+
/** Who opened the pull request, named in its body. */
|
|
42
|
+
opener: string;
|
|
43
|
+
/** Why the repo takes the train now (need.ts), named in the body beside the opener. */
|
|
44
|
+
why?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One consumer takes the train in `dir`, a scratch checkout of its branch:
|
|
48
|
+
* every site updated, the lockfile refreshed, the workflow refs bumped, then
|
|
49
|
+
* the commit, the branch and the pull request.
|
|
50
|
+
*/
|
|
51
|
+
export declare function takeTrain(ctx: Context, consumer: Consumer, dir: string, take: Take, summary: Summary): Promise<void>;
|
|
52
|
+
/** The URL of the open pull request from the train branch against the consumer's branch, if any. */
|
|
53
|
+
export declare function openPullUrl(ctx: Context, consumer: Consumer, dir: string, train: string): Promise<string>;
|
|
54
|
+
export declare const detail: (error: unknown) => string;
|
|
55
|
+
//# sourceMappingURL=take.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"take.d.ts","sourceRoot":"","sources":["../src/take.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,QAAQ,EAA4C,MAAM,gBAAgB,CAAC;AACzF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,6HAA6H;IAC7H,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,iDAAiD;IACjD,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,0GAA0G;IAC1G,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,0EAA0E;IAC1E,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,4EAA4E;AAC5E,eAAO,MAAM,OAAO,GAAI,GAAG,OAAO,KAAG,OACyC,CAAC;AAE/E,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAO/D;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,SAAS,OAAO,KAAG,OAS7D,CAAC;AAEH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,MAA2B,CAAC;AAExE,wFAAwF;AACxF,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wGAAwG;IACxG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,uFAAuF;IACvF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAaD;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,iBAM1G;AAkLD,oGAAoG;AACpG,wBAAsB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG/G;AAwFD,eAAO,MAAM,MAAM,GAAI,OAAO,OAAO,KAAG,MAIvC,CAAC"}
|
package/dist/take.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// take: one repo takes a train (§ 3 PLX-Updates), in a scratch checkout of the
|
|
2
|
+
// branch the train 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 marker is synced to the answers file, the lockfile refreshed where
|
|
5
|
+
// manifests moved, the hand-owned workflows pinned to the train; then one
|
|
6
|
+
// commit, pushed as `plexus/<version>`, and a pull request against the branch.
|
|
7
|
+
// A conflict is committed with its markers and reported, and the pull request
|
|
8
|
+
// is opened all the same: that is where it gets resolved. Nothing here aborts
|
|
9
|
+
// a run: a failing or conflicting site is recorded in the summary, which says
|
|
10
|
+
// what needs a human. Reviewing and merging the pull request stays human.
|
|
11
|
+
//
|
|
12
|
+
// `update` (update.ts) is the verb on top of it, and the only thing that
|
|
13
|
+
// opens a train's pull request; `propagate` (propagate.ts) runs that verb over
|
|
14
|
+
// many repos. The maintainers' preview of an unreleased train (preview.ts)
|
|
15
|
+
// uses the same steps against the local preset checkouts, and opens nothing.
|
|
16
|
+
import { join, relative } from 'node:path';
|
|
17
|
+
import { bumpWorkflowRefs, hasConflictMarkers, hasUnmergedEntries, syncMarker, WORKFLOW_REF } from "./bookkeeping.js";
|
|
18
|
+
import { presetSource, RENAMED_PRESETS } from "./consumers.js";
|
|
19
|
+
import { ANSWERS_FILE, copierVia, parseAnswers } from "./copier.js";
|
|
20
|
+
import { run, write } from "./effects.js";
|
|
21
|
+
import { MARKER_FILE } from "./marker.js";
|
|
22
|
+
/** True when nothing in the summary needs a human but the pull requests. */
|
|
23
|
+
export const isClean = (s) => s.conflicted.length === 0 && s.failed.length === 0 && s.skipped.length === 0;
|
|
24
|
+
/** Add what one repo's run found to the summary of a run over many. */
|
|
25
|
+
export function mergeSummary(into, from) {
|
|
26
|
+
into.clean.push(...from.clean);
|
|
27
|
+
into.conflicted.push(...from.conflicted);
|
|
28
|
+
into.failed.push(...from.failed);
|
|
29
|
+
into.skipped.push(...from.skipped);
|
|
30
|
+
into.resting.push(...from.resting);
|
|
31
|
+
into.pulls.push(...from.pulls);
|
|
32
|
+
}
|
|
33
|
+
export const emptySummary = (train, preview) => ({
|
|
34
|
+
train,
|
|
35
|
+
preview,
|
|
36
|
+
clean: [],
|
|
37
|
+
conflicted: [],
|
|
38
|
+
failed: [],
|
|
39
|
+
skipped: [],
|
|
40
|
+
resting: [],
|
|
41
|
+
pulls: [],
|
|
42
|
+
});
|
|
43
|
+
export const trainBranch = (train) => `plexus/${train}`;
|
|
44
|
+
/**
|
|
45
|
+
* copier at the version plx pins, through mise, with the consumer's own mise
|
|
46
|
+
* config ignored: copier needs no project tool, and a root `mise.toml` left
|
|
47
|
+
* with conflict markers by the root site's update would otherwise fail every
|
|
48
|
+
* later mise call in the directory, the apps' updates first of all.
|
|
49
|
+
*/
|
|
50
|
+
const copierIn = (dir, args) => [
|
|
51
|
+
'env',
|
|
52
|
+
[`MISE_IGNORED_CONFIG_PATHS=${dir}`, 'mise', ...copierVia(args)],
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* One consumer takes the train in `dir`, a scratch checkout of its branch:
|
|
56
|
+
* every site updated, the lockfile refreshed, the workflow refs bumped, then
|
|
57
|
+
* the commit, the branch and the pull request.
|
|
58
|
+
*/
|
|
59
|
+
export async function takeTrain(ctx, consumer, dir, take, summary) {
|
|
60
|
+
const base = (await ctx.read('git', ['rev-parse', 'HEAD'], { cwd: dir })).trim();
|
|
61
|
+
for (const site of consumer.sites)
|
|
62
|
+
await updateSite(ctx, consumer, site, dir, take, summary);
|
|
63
|
+
await refreshLockfile(ctx, consumer, dir, base, summary);
|
|
64
|
+
await bumpConsumerRefs(ctx, consumer, dir, take.train);
|
|
65
|
+
await openPull(ctx, consumer, dir, take, summary);
|
|
66
|
+
}
|
|
67
|
+
// Preview commits are plain plumbing on a throwaway clone: unsigned, no hooks, a stand-in identity.
|
|
68
|
+
const previewCommit = (ctx, dir, message) => ctx
|
|
69
|
+
.stage(run('git', ['add', '-A'], { cwd: dir }))
|
|
70
|
+
.then(() => ctx.stage(run('git', [
|
|
71
|
+
'-c',
|
|
72
|
+
'commit.gpgsign=false',
|
|
73
|
+
'-c',
|
|
74
|
+
'user.name=plx',
|
|
75
|
+
'-c',
|
|
76
|
+
'user.email=plx@localhost',
|
|
77
|
+
'commit',
|
|
78
|
+
'--quiet',
|
|
79
|
+
'--no-verify',
|
|
80
|
+
'--allow-empty',
|
|
81
|
+
'-m',
|
|
82
|
+
message,
|
|
83
|
+
], { cwd: dir })));
|
|
84
|
+
async function updateSite(ctx, consumer, site, dir, take, summary) {
|
|
85
|
+
const target = join(dir, relative(consumer.path, site.path));
|
|
86
|
+
try {
|
|
87
|
+
if (take.previewFrom) {
|
|
88
|
+
const localPreset = join(take.previewFrom, site.preset);
|
|
89
|
+
ctx.say(`→ ${site.rel}: copier update (preview from ${localPreset}@main)`);
|
|
90
|
+
// Point the answers at the local preset so the preview reads it; copier
|
|
91
|
+
// refuses a dirty subproject, hence the commit.
|
|
92
|
+
const answers = await ctx.readFile(join(target, ANSWERS_FILE));
|
|
93
|
+
await ctx.stage(write(join(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${localPreset}`)));
|
|
94
|
+
await previewCommit(ctx, dir, `plx preview: ${site.rel} reads ${localPreset} from the local checkout`);
|
|
95
|
+
await ctx.stage(run(...copierIn(dir, ['update', '--skip-answered', '--trust', '--defaults', '--skip-tasks', '--vcs-ref', 'main']), { cwd: target }));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
ctx.say(`→ ${site.rel}: copier update${take.ref ? ` to ${take.ref}` : ''}`);
|
|
99
|
+
// A preset renamed on a train: the answers still name the old source,
|
|
100
|
+
// which copier would clone through the forge's redirect; point them at
|
|
101
|
+
// the current name first, committed because copier refuses a dirty
|
|
102
|
+
// subproject.
|
|
103
|
+
const answers = await ctx.readFile(join(target, ANSWERS_FILE));
|
|
104
|
+
const current = presetSource(site.preset);
|
|
105
|
+
const recorded = /^_src_path: (.*)$/m.exec(answers)?.[1];
|
|
106
|
+
if (recorded &&
|
|
107
|
+
recorded !== current &&
|
|
108
|
+
Object.keys(RENAMED_PRESETS).some((old) => presetSource(old) === recorded)) {
|
|
109
|
+
ctx.say(` ${site.rel}: the preset is ${current} now; the answers follow`);
|
|
110
|
+
await ctx.stage(write(join(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${current}`)));
|
|
111
|
+
await previewCommit(ctx, dir, `plx: ${site.rel} reads ${current}, the preset's name since its rename`);
|
|
112
|
+
}
|
|
113
|
+
// Template tasks (mise install, hook setup) serve a developer's checkout,
|
|
114
|
+
// not a pull request. Unattended, a new question takes its default; on a
|
|
115
|
+
// terminal copier asks. A dry run previews on the scratch checkout, so
|
|
116
|
+
// the step is staged there rather than only announced.
|
|
117
|
+
const args = [
|
|
118
|
+
'update',
|
|
119
|
+
'--skip-answered',
|
|
120
|
+
'--trust',
|
|
121
|
+
'--skip-tasks',
|
|
122
|
+
...(take.ref ? ['--vcs-ref', take.ref] : []),
|
|
123
|
+
...(ctx.yes || ctx.dryRun ? ['--defaults'] : []),
|
|
124
|
+
];
|
|
125
|
+
const step = run(...copierIn(dir, args), { cwd: target, interactive: !ctx.dryRun });
|
|
126
|
+
if (ctx.dryRun)
|
|
127
|
+
await ctx.stage(step);
|
|
128
|
+
else
|
|
129
|
+
await ctx.apply([step]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
ctx.say(` ✗ FAILED — copier update exited nonzero${detail(error)}`);
|
|
134
|
+
summary.failed.push(site.rel);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// copier applies the template diff with `git apply --3way`, which leaves
|
|
138
|
+
// unmerged index entries and inline markers when a hunk does not apply.
|
|
139
|
+
// Scoped to the site: the root site's changes are still in the tree when
|
|
140
|
+
// its apps are updated.
|
|
141
|
+
const status = await ctx.read('git', ['status', '--porcelain', '--', '.'], { cwd: target });
|
|
142
|
+
let conflict = hasUnmergedEntries(status);
|
|
143
|
+
const changed = (await ctx.read('git', ['diff', '--name-only', '--relative', '--', '.'], { cwd: target }))
|
|
144
|
+
.split('\n')
|
|
145
|
+
.filter(Boolean);
|
|
146
|
+
for (const f of changed) {
|
|
147
|
+
const text = await ctx.readFile(join(target, f)).catch(() => '');
|
|
148
|
+
if (hasConflictMarkers(text))
|
|
149
|
+
conflict = true;
|
|
150
|
+
}
|
|
151
|
+
await syncSiteMarker(ctx, site, target);
|
|
152
|
+
if (conflict) {
|
|
153
|
+
ctx.say(' ✗ CONFLICTS — committed with their <<<<<<< markers, to resolve in the pull request:');
|
|
154
|
+
summary.conflicted.push(site.rel);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
ctx.say(' ✓ merged clean:');
|
|
158
|
+
summary.clean.push(site.rel);
|
|
159
|
+
}
|
|
160
|
+
for (const line of status.split('\n').filter(Boolean))
|
|
161
|
+
ctx.say(` ${line}`);
|
|
162
|
+
// Each preview-from-local site is committed so the next site's answers
|
|
163
|
+
// rewrite starts from a clean tree. Otherwise the site is staged: a conflict
|
|
164
|
+
// leaves unmerged index entries, and copier's own git plumbing (`git
|
|
165
|
+
// write-tree`) refuses an index with those, so the next site's update would
|
|
166
|
+
// fail; staged, the markers are in the tree and the index is whole.
|
|
167
|
+
if (take.previewFrom)
|
|
168
|
+
await previewCommit(ctx, dir, `plx preview: ${site.rel} updated`);
|
|
169
|
+
else
|
|
170
|
+
await ctx.stage(run('git', ['add', '-A'], { cwd: dir }));
|
|
171
|
+
}
|
|
172
|
+
/** The marker's `plexus` follows the answers file's `_commit` after an update (bookkeeping.ts). */
|
|
173
|
+
async function syncSiteMarker(ctx, site, target) {
|
|
174
|
+
const marker = await ctx.readFile(join(target, MARKER_FILE)).catch(() => undefined);
|
|
175
|
+
if (marker === undefined)
|
|
176
|
+
return;
|
|
177
|
+
const { commit } = parseAnswers(await ctx.readFile(join(target, ANSWERS_FILE)));
|
|
178
|
+
if (!commit)
|
|
179
|
+
return;
|
|
180
|
+
const synced = syncMarker(marker, commit);
|
|
181
|
+
if (synced === marker)
|
|
182
|
+
return;
|
|
183
|
+
ctx.say(` marker: plexus → ${commit} in ${site.rel}/${MARKER_FILE}`);
|
|
184
|
+
await ctx.stage(write(join(target, MARKER_FILE), synced));
|
|
185
|
+
}
|
|
186
|
+
/** Refresh the lockfile when the updates touched a manifest (`mise exec` trusts the directory's own config). */
|
|
187
|
+
async function refreshLockfile(ctx, consumer, dir, base, summary) {
|
|
188
|
+
if ((await ctx.readFile(join(dir, 'pnpm-workspace.yaml')).catch(() => undefined)) === undefined)
|
|
189
|
+
return;
|
|
190
|
+
const manifests = ['*package.json', 'pnpm-workspace.yaml'];
|
|
191
|
+
const unchanged = await ctx
|
|
192
|
+
.read('git', ['diff', '--quiet', base, '--', ...manifests], { cwd: dir })
|
|
193
|
+
.then(() => true)
|
|
194
|
+
.catch(() => false);
|
|
195
|
+
if (unchanged)
|
|
196
|
+
return;
|
|
197
|
+
ctx.say(`→ ${consumer.rel}: pnpm install (manifests changed)`);
|
|
198
|
+
try {
|
|
199
|
+
await ctx.apply([run('mise', ['exec', '--', 'pnpm', 'install', '--reporter=silent'], { cwd: dir })]);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
ctx.say(` ✗ pnpm install failed${detail(error)}`);
|
|
203
|
+
summary.failed.push(`${consumer.rel}/pnpm-lock.yaml`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** Consumers' hand-owned workflows pin the reusable workflows by tag; lockstep them to the train. */
|
|
207
|
+
async function bumpConsumerRefs(ctx, consumer, dir, train) {
|
|
208
|
+
const workflows = join(dir, '.github', 'workflows');
|
|
209
|
+
const entries = await ctx.readDir(workflows).catch(() => []);
|
|
210
|
+
const files = entries
|
|
211
|
+
.filter((e) => !e.directory && /\.ya?ml$/.test(e.name))
|
|
212
|
+
.map((e) => e.name)
|
|
213
|
+
.sort();
|
|
214
|
+
for (const f of files) {
|
|
215
|
+
const text = await ctx.readFile(join(workflows, f));
|
|
216
|
+
if (!text.includes(WORKFLOW_REF))
|
|
217
|
+
continue;
|
|
218
|
+
const bumped = bumpWorkflowRefs(text, train);
|
|
219
|
+
if (bumped === text)
|
|
220
|
+
continue;
|
|
221
|
+
ctx.say(`→ ${consumer.rel}: ${f} workflow refs → @${train}`);
|
|
222
|
+
await ctx.stage(write(join(workflows, f), bumped));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** The URL of the open pull request from the train branch against the consumer's branch, if any. */
|
|
226
|
+
export async function openPullUrl(ctx, consumer, dir, train) {
|
|
227
|
+
const args = ['pr', 'list', '--head', trainBranch(train), '--base', consumer.branch, '--state', 'open'];
|
|
228
|
+
return (await ctx.read('gh', [...args, '--json', 'url', '--jq', '.[0].url'], { cwd: dir }).catch(() => '')).trim();
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* One commit, the train branch pushed, and a pull request against the
|
|
232
|
+
* consumer's branch: opened once, found again on a re-run. The branch is plx's
|
|
233
|
+
* own, so a re-run may move it, with a lease on what it fetched. Hooks are
|
|
234
|
+
* skipped: the checks are the pull request's job, and the mount's own
|
|
235
|
+
* checkout may carry the repo's hooks.
|
|
236
|
+
*/
|
|
237
|
+
async function openPull(ctx, consumer, dir, take, summary) {
|
|
238
|
+
const { train } = take;
|
|
239
|
+
const branch = trainBranch(train);
|
|
240
|
+
if (ctx.dryRun) {
|
|
241
|
+
ctx.say(` (preview) ${consumer.rel}: would commit, push ${branch} and open a pull request against ${consumer.branch}`);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if ((await ctx.read('git', ['status', '--porcelain'], { cwd: dir })).trim() === '') {
|
|
245
|
+
ctx.say(`• ${consumer.rel}: nothing changed — no pull request`);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const head = `${consumer.origin ?? 'origin'} ${branch}`;
|
|
249
|
+
try {
|
|
250
|
+
await ctx.apply([
|
|
251
|
+
run('git', ['add', '-A'], { cwd: dir }),
|
|
252
|
+
run('git', ['commit', '--quiet', '--no-verify', '-m', `chore: train ${train}`], { cwd: dir }),
|
|
253
|
+
]);
|
|
254
|
+
// The lease needs the remote-tracking ref; a fresh clone has none for a branch it did not check out.
|
|
255
|
+
await ctx
|
|
256
|
+
.read('git', ['fetch', '--quiet', 'origin', `+refs/heads/${branch}:refs/remotes/origin/${branch}`], {
|
|
257
|
+
cwd: dir,
|
|
258
|
+
})
|
|
259
|
+
.catch(() => '');
|
|
260
|
+
await ctx.apply([
|
|
261
|
+
run('git', ['push', '--quiet', '--no-verify', '--force-with-lease', 'origin', `HEAD:refs/heads/${branch}`], {
|
|
262
|
+
cwd: dir,
|
|
263
|
+
}),
|
|
264
|
+
]);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
ctx.say(` ✗ FAILED — push to ${head}${detail(error)}`);
|
|
268
|
+
summary.failed.push(consumer.rel);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const existing = await openPullUrl(ctx, consumer, dir, train);
|
|
272
|
+
if (existing) {
|
|
273
|
+
ctx.say(`• ${consumer.rel}: pull request updated: ${existing}`);
|
|
274
|
+
summary.pulls.push(existing);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const sites = consumer.sites.map((s) => s.rel);
|
|
278
|
+
const conflicted = sites.filter((s) => summary.conflicted.includes(s));
|
|
279
|
+
const body = [
|
|
280
|
+
`Train ${train} (§ 1.5 PLX): \`copier update\` at ${sites.join(', ')}, the marker, the lockfile where manifests moved, and the workflow refs.`,
|
|
281
|
+
conflicted.length > 0
|
|
282
|
+
? `Conflicts to resolve, committed with their markers: ${conflicted.join(', ')}.`
|
|
283
|
+
: 'Merged clean at every site.',
|
|
284
|
+
`Opened by ${take.opener}${take.why ? `: ${take.why}` : ''}.`,
|
|
285
|
+
].join('\n\n');
|
|
286
|
+
try {
|
|
287
|
+
await ctx.apply([
|
|
288
|
+
run('gh', [
|
|
289
|
+
'pr',
|
|
290
|
+
'create',
|
|
291
|
+
'--base',
|
|
292
|
+
consumer.branch,
|
|
293
|
+
'--head',
|
|
294
|
+
branch,
|
|
295
|
+
'--title',
|
|
296
|
+
`chore: train ${train}`,
|
|
297
|
+
'--body',
|
|
298
|
+
body,
|
|
299
|
+
], { cwd: dir }),
|
|
300
|
+
]);
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
ctx.say(` ✗ FAILED — pull request${detail(error)}`);
|
|
304
|
+
summary.failed.push(consumer.rel);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const url = await openPullUrl(ctx, consumer, dir, train);
|
|
308
|
+
ctx.say(`• ${consumer.rel}: pull request opened${url ? `: ${url}` : ''}`);
|
|
309
|
+
summary.pulls.push(url || `${consumer.rel} ${branch}`);
|
|
310
|
+
}
|
|
311
|
+
export const detail = (error) => {
|
|
312
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
313
|
+
const last = message.trim().split('\n').at(-1) ?? '';
|
|
314
|
+
return last && !/exited with/.test(last) ? `: ${last}` : '';
|
|
315
|
+
};
|
|
316
|
+
//# sourceMappingURL=take.js.map
|
package/dist/take.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"take.js","sourceRoot":"","sources":["../src/take.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E,yEAAyE;AACzE,0EAA0E;AAC1E,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,0EAA0E;AAC1E,EAAE;AACF,yEAAyE;AACzE,+EAA+E;AAC/E,2EAA2E;AAC3E,6EAA6E;AAC7E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtH,OAAO,EAAiB,YAAY,EAAE,eAAe,EAAa,MAAM,gBAAgB,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAmB1C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAU,EAAW,EAAE,CAC7C,CAAC,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC;AAE/E,uEAAuE;AACvE,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,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AC"}
|
package/dist/update.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { Context } from './context.ts';
|
|
2
|
-
import { type Summary } from './
|
|
3
|
-
/** The train repos that are templates: what a repo can be generated from. */
|
|
4
|
-
export declare const PRESETS: readonly string[];
|
|
2
|
+
import { type Summary } from './take.ts';
|
|
5
3
|
export interface UpdateOptions {
|
|
6
4
|
/** The repo to update: a checkout whose root is a site of a repo preset. */
|
|
7
5
|
repo: string;
|
|
8
|
-
/**
|
|
6
|
+
/** What the repo is called in the narration and the summary; default: its directory's name. */
|
|
7
|
+
name?: string;
|
|
8
|
+
/** The train to take, which is asking for it; default: the preset's newest release. */
|
|
9
9
|
train?: string;
|
|
10
|
+
/** Take the newest train whatever the triggers say: somebody asks. */
|
|
11
|
+
now?: boolean;
|
|
12
|
+
/** The backstop age in days; default: the repo's answer `update_max_age`, else 30. */
|
|
13
|
+
maxAge?: number;
|
|
14
|
+
/** The clock the backstop is measured against, as a date; default: now. */
|
|
15
|
+
today?: string;
|
|
10
16
|
}
|
|
11
17
|
export declare function update(ctx: Context, options: UpdateOptions): Promise<Summary>;
|
|
12
18
|
//# sourceMappingURL=update.d.ts.map
|
package/dist/update.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,OAAO,EAAqC,KAAK,OAAO,EAA0B,MAAM,WAAW,CAAC;AAGpG,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CA6FnF"}
|
package/dist/update.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// update: a repo generated from the presets takes the train itself (§ 3
|
|
2
|
-
// PLX-Updates), from inside the repo
|
|
3
|
-
//
|
|
2
|
+
// PLX-Updates), from inside the repo, in the tenant's own CI or by hand; it is
|
|
3
|
+
// the only thing that opens a train's pull request.
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// It takes a train when the repo needs one, not whenever one was cut
|
|
6
|
+
// (need.ts): when it is asked (`--now`, or a train named), or when the oldest
|
|
7
|
+
// train the repo has not taken is older than the backstop age, which the
|
|
8
|
+
// repo's answers set (`update_max_age`, in days; 30 when they do not say, zero
|
|
9
|
+
// for every train). Otherwise the repo rests: one line saying why, exit 0.
|
|
10
|
+
//
|
|
11
|
+
// The trains are the preset's GitHub releases (every train tag is locked by
|
|
12
|
+
// one, § 1.6 PLX), asked of the forge as an operator would
|
|
13
|
+
// (`gh api repos/plexus-ms/<preset>/releases`): the newest is the train to
|
|
14
|
+
// take, and their dates are what the backstop is measured against. The work happens in a
|
|
8
15
|
// worktree of origin's branch, never in the checkout: a developer's branch and
|
|
9
16
|
// edits stay as they are, and in CI the worktree shares the checkout's
|
|
10
17
|
// credentials, so the push and the pull request need no second token. Then
|
|
@@ -12,27 +19,27 @@
|
|
|
12
19
|
// workflow refs, one commit on `plexus/<version>`, one pull request.
|
|
13
20
|
//
|
|
14
21
|
// The train is pulled once per repo: a `plexus/<version>` branch already on
|
|
15
|
-
// origin, from an earlier run
|
|
16
|
-
//
|
|
22
|
+
// origin, from an earlier run or from a human resolving its conflicts, is
|
|
23
|
+
// left alone, so a daily run never moves a branch somebody is
|
|
17
24
|
// working on; deleting the branch is how a pull is redone. A repo whose every
|
|
18
25
|
// site already records the train does nothing at all.
|
|
19
26
|
//
|
|
20
|
-
// plx update #
|
|
21
|
-
// plx
|
|
27
|
+
// plx update # the newest train, if the repo needs it
|
|
28
|
+
// plx update --now # the newest train, whatever its triggers say
|
|
29
|
+
// plx -n update --now # preview in a worktree, push nothing
|
|
22
30
|
// plx -y update --train 0.102.0 # unattended, an explicit train
|
|
23
|
-
import { basename, join } from 'node:path';
|
|
24
|
-
import { findConsumers, presetSource } from "./consumers.js";
|
|
31
|
+
import { basename, join, relative } from 'node:path';
|
|
32
|
+
import { findConsumers, PRESETS, presetSource } from "./consumers.js";
|
|
25
33
|
import { ANSWERS_FILE, parseAnswers } from "./copier.js";
|
|
26
34
|
import { compareTrains } from "./doctor.js";
|
|
27
35
|
import { run } from "./effects.js";
|
|
36
|
+
import { maxAgeOf, needOf } from "./need.js";
|
|
28
37
|
import { overview } from "./overview.js";
|
|
29
|
-
import { detail, emptySummary, openPullUrl, takeTrain, trainBranch } from "./
|
|
30
|
-
import { isTrainVersion, preflightForge,
|
|
31
|
-
/** The train repos that are templates: what a repo can be generated from. */
|
|
32
|
-
export const PRESETS = TRAIN_REPOS.filter((r) => r.startsWith('preset-'));
|
|
38
|
+
import { detail, emptySummary, openPullUrl, takeTrain, trainBranch } from "./take.js";
|
|
39
|
+
import { isTrainVersion, preflightForge, UsageError } from "./train.js";
|
|
33
40
|
export async function update(ctx, options) {
|
|
34
41
|
const { repo } = options;
|
|
35
|
-
const name = basename(repo);
|
|
42
|
+
const name = options.name ?? basename(repo);
|
|
36
43
|
if (options.train !== undefined && !isTrainVersion(options.train))
|
|
37
44
|
throw new UsageError(`'${options.train}' is not plain semver (X.Y.Z, no v)`);
|
|
38
45
|
const tree = await overview(ctx, repo);
|
|
@@ -49,9 +56,20 @@ export async function update(ctx, options) {
|
|
|
49
56
|
if (!root)
|
|
50
57
|
throw new Error(`${name}: its root is not a site of a repo preset`);
|
|
51
58
|
await preflightForge(ctx);
|
|
52
|
-
const
|
|
59
|
+
const releases = options.train === undefined ? await releasesOf(ctx, root.preset) : [];
|
|
60
|
+
const train = options.train ?? newestOf(releases, root.preset);
|
|
53
61
|
const summary = emptySummary(train, ctx.dryRun);
|
|
54
|
-
|
|
62
|
+
// The repo is judged by what its origin has on the branch the train lands
|
|
63
|
+
// on, not by the checkout, which may be behind it or on a branch of its own.
|
|
64
|
+
await ctx.read('git', ['fetch', '--quiet', 'origin', consumer.branch], { cwd: repo }).catch(() => '');
|
|
65
|
+
const answers = await Promise.all(consumer.sites.map(async (s) => {
|
|
66
|
+
const file = join(relative(consumer.path, s.path), ANSWERS_FILE);
|
|
67
|
+
const onOrigin = await ctx
|
|
68
|
+
.read('git', ['show', `origin/${consumer.branch}:${file}`], { cwd: repo })
|
|
69
|
+
.catch(() => undefined);
|
|
70
|
+
return parseAnswers(onOrigin ?? (await ctx.readFile(join(s.path, ANSWERS_FILE))));
|
|
71
|
+
}));
|
|
72
|
+
const recorded = answers.map((a) => a.commit);
|
|
55
73
|
if (recorded.every((c) => c === train)) {
|
|
56
74
|
ctx.say(`• ${name}: already at ${train}`);
|
|
57
75
|
return summary;
|
|
@@ -72,6 +90,19 @@ export async function update(ctx, options) {
|
|
|
72
90
|
summary.pulls.push(url);
|
|
73
91
|
return summary;
|
|
74
92
|
}
|
|
93
|
+
const need = needOf({
|
|
94
|
+
recorded,
|
|
95
|
+
releases,
|
|
96
|
+
asked: options.train !== undefined ? `--train ${train}` : options.now ? '--now' : undefined,
|
|
97
|
+
maxAge: options.maxAge ?? maxAgeOf(answers[consumer.sites.indexOf(root)]?.answers ?? {}),
|
|
98
|
+
now: options.today === undefined ? new Date() : new Date(options.today),
|
|
99
|
+
});
|
|
100
|
+
if (!need.take) {
|
|
101
|
+
ctx.say(`• ${name}: rests — ${need.why} (plx update --now takes ${train})`);
|
|
102
|
+
summary.resting.push({ path: name, reason: need.why });
|
|
103
|
+
return summary;
|
|
104
|
+
}
|
|
105
|
+
ctx.say(`• ${name}: takes ${train} — ${need.why}`);
|
|
75
106
|
const scratch = (await ctx.stage(run('mktemp', ['-d'])))?.trim() ?? '';
|
|
76
107
|
const dir = join(scratch, name);
|
|
77
108
|
try {
|
|
@@ -85,7 +116,7 @@ export async function update(ctx, options) {
|
|
|
85
116
|
summary.failed.push(name);
|
|
86
117
|
return summary;
|
|
87
118
|
}
|
|
88
|
-
await takeTrain(ctx, consumer, dir, { train, ref: train, opener: '`plx update`' }, summary);
|
|
119
|
+
await takeTrain(ctx, consumer, dir, { train, ref: train, opener: '`plx update`', why: need.why }, summary);
|
|
89
120
|
}
|
|
90
121
|
finally {
|
|
91
122
|
await ctx.stage(run('git', ['worktree', 'remove', '--force', dir], { cwd: repo })).catch(() => undefined);
|
|
@@ -94,14 +125,22 @@ export async function update(ctx, options) {
|
|
|
94
125
|
}
|
|
95
126
|
return summary;
|
|
96
127
|
}
|
|
97
|
-
/** The preset's
|
|
98
|
-
async function
|
|
128
|
+
/** The preset's releases are the trains (§ 1.6 PLX: every train tag has one), with the dates they were cut. */
|
|
129
|
+
async function releasesOf(ctx, preset) {
|
|
99
130
|
const source = presetSource(preset).replace(/^gh:/, '');
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
131
|
+
const jq = '.[] | select(.draft | not) | "\\(.tag_name) \\(.published_at)"';
|
|
132
|
+
const lines = await ctx.read('gh', ['api', `repos/${source}/releases`, '--paginate', '--jq', jq]).catch(() => '');
|
|
133
|
+
return lines
|
|
134
|
+
.split('\n')
|
|
135
|
+
.map((l) => l.trim().split(/\s+/))
|
|
136
|
+
.filter((p) => p.length === 2 && isTrainVersion(p[0] ?? ''))
|
|
137
|
+
.map(([train, published]) => ({ train, published }));
|
|
138
|
+
}
|
|
139
|
+
/** The newest train among a preset's releases. */
|
|
140
|
+
function newestOf(releases, preset) {
|
|
141
|
+
const newest = releases.map((r) => r.train).reduce((a, b) => (a && compareTrains(a, b) >= 0 ? a : b), '');
|
|
142
|
+
if (!newest)
|
|
143
|
+
throw new Error(`no release of ${presetSource(preset).replace(/^gh:/, '')} found — pass the train explicitly (--train <version>)`);
|
|
144
|
+
return newest;
|
|
106
145
|
}
|
|
107
146
|
//# sourceMappingURL=update.js.map
|
package/dist/update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,8EAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,+EAA+E;AAC/E,oDAAoD;AACpD,EAAE;AACF,qEAAqE;AACrE,8EAA8E;AAC9E,yEAAyE;AACzE,+EAA+E;AAC/E,2EAA2E;AAC3E,EAAE;AACF,4EAA4E;AAC5E,2DAA2D;AAC3D,2EAA2E;AAC3E,yFAAyF;AACzF,+EAA+E;AAC/E,uEAAuE;AACvE,2EAA2E;AAC3E,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAC1E,8DAA8D;AAC9D,8EAA8E;AAC9E,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,kFAAkF;AAClF,0EAA0E;AAC1E,oEAAoE;AACpE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;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