@tallyrelease/core 0.5.0-beta.56 → 0.5.0-beta.64

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/facts.js CHANGED
@@ -212,7 +212,12 @@ export const rangeFacts = (workspace, git, opts) => {
212
212
  const changes = [];
213
213
  for (const { plugin, source, ctx: sourceCtx } of intents) {
214
214
  // eslint-disable-next-line no-await-in-loop -- hooks run sequentially in config order
215
- const collected = await runHook(plugin, "intent", () => source.collect(sourceCtx, { from, to: head, commits }));
215
+ const collected = await runHook(plugin, "intent", () => source.collect(sourceCtx, {
216
+ from,
217
+ to: head,
218
+ commits,
219
+ units: workspace.units,
220
+ }));
216
221
  warnUnknown(plugin, collected);
217
222
  changes.push(...collected);
218
223
  }
@@ -16,6 +16,10 @@ export interface PlanChange {
16
16
  via?: string;
17
17
  /** Release-As value of this commit for the unit. */
18
18
  releaseAs?: string;
19
+ /** Units the change names; set with `files`. */
20
+ units?: string[];
21
+ /** Files consumed once every unit named by the changes with them releases. */
22
+ files?: string[];
19
23
  }
20
24
  export interface UnitPlan {
21
25
  id: string;
package/dist/plan.js CHANGED
@@ -36,6 +36,9 @@ const planChanges = (intent) => (intent?.changes ?? []).map(({ change, via }) =>
36
36
  ...(change.pr === undefined ? {} : { pr: change.pr }),
37
37
  ...(via === undefined ? {} : { via }),
38
38
  ...(releaseAs === undefined ? {} : { releaseAs }),
39
+ ...(change.files === undefined
40
+ ? {}
41
+ : { units: [...(change.units ?? [])], files: [...change.files] }),
39
42
  };
40
43
  });
41
44
  /**
package/dist/plugin.d.ts CHANGED
@@ -191,6 +191,8 @@ export interface IntentSource<O = unknown> {
191
191
  from: string | null;
192
192
  to: string;
193
193
  commits: readonly RawCommit[];
194
+ /** All units of the workspace. */
195
+ units: readonly Unit[];
194
196
  }) => MaybePromise<Change[]>;
195
197
  }
196
198
  /** A `Release-As` value; `unit` is set by the qualified form `<unit>@<version>`. */
@@ -213,6 +215,11 @@ export interface Change {
213
215
  releaseAs?: ReleaseAsValue[];
214
216
  pr?: number;
215
217
  date?: string;
218
+ /**
219
+ * Files consumed when the change is released: deleted in the release
220
+ * commit that releases every unit named by the changes with the file.
221
+ */
222
+ files?: string[];
216
223
  }
217
224
  /** Throws `E_PLUGIN_API` or `E_PLUGIN_NAME` for an unsupported plugin. */
218
225
  export declare const assertPlugin: (plugin: {
@@ -15,7 +15,8 @@ export declare const versionFileClaims: (workspace: Workspace) => Promise<Readon
15
15
  * Files of a release of `items` (stable `next`): plugin version files,
16
16
  * templates, markers and `<root>/CHANGELOG.md` per unit, read through `fs`; the
17
17
  * owning plugin's `changelog` hook may replace a unit's section. Returns
18
- * only files whose content changes, and each unit's changelog section;
18
+ * only files whose content changes, the consumed files of changes whose
19
+ * named units all release in `items`, and each unit's changelog section;
19
20
  * checks claims first. Templates skip first releases and warn
20
21
  * `W_VERSION_FILE_NO_MATCH` without any match, markers warn
21
22
  * `W_MARKER_NO_MATCH`; a missing version file is
@@ -30,6 +31,8 @@ export declare const releaseFiles: (workspace: Workspace, plan: Plan, opts: {
30
31
  date: string;
31
32
  }) => Promise<{
32
33
  files: Map<string, string>;
34
+ /** Files consumed by released changes, deleted by the release. */
35
+ deletes: Set<string>;
33
36
  /** Changelog section of each unit, by unit id. */
34
37
  sections: Map<string, string>;
35
38
  warnings: Warning[];
@@ -259,6 +259,24 @@ const changelogStep = async (staged, step) => {
259
259
  }
260
260
  return section;
261
261
  };
262
+ /**
263
+ * Readable files of the plan's changes where every unit named by a change
264
+ * with the file is in `released`; `written` files are kept.
265
+ */
266
+ const consumedFiles = (plan, released, { fs, written }) => {
267
+ const named = new Map();
268
+ for (const { files = [], units = [] } of plan.units.flatMap((u) => u.changes)) {
269
+ for (const path of files) {
270
+ named.set(path, [...(named.get(path) ?? []), ...units]);
271
+ }
272
+ }
273
+ return new Set([...named]
274
+ .filter(([path, units]) => units.length > 0 &&
275
+ units.every((id) => released.has(id)) &&
276
+ !written.has(path) &&
277
+ fs.read(path) !== undefined)
278
+ .map(([path]) => path));
279
+ };
262
280
  /** Checks template files and patterns (`E_CONFIG`); runs no plugin hook. */
263
281
  export const validateTemplates = (workspace) => {
264
282
  for (const [id, templates] of workspace.release.templates) {
@@ -310,7 +328,8 @@ export const versionFileClaims = async (workspace) => {
310
328
  * Files of a release of `items` (stable `next`): plugin version files,
311
329
  * templates, markers and `<root>/CHANGELOG.md` per unit, read through `fs`; the
312
330
  * owning plugin's `changelog` hook may replace a unit's section. Returns
313
- * only files whose content changes, and each unit's changelog section;
331
+ * only files whose content changes, the consumed files of changes whose
332
+ * named units all release in `items`, and each unit's changelog section;
314
333
  * checks claims first. Templates skip first releases and warn
315
334
  * `W_VERSION_FILE_NO_MATCH` without any match, markers warn
316
335
  * `W_MARKER_NO_MATCH`; a missing version file is
@@ -371,6 +390,10 @@ export const releaseFiles = async (workspace, plan, opts) => {
371
390
  }
372
391
  return {
373
392
  files: new Map([...files].filter(([path, c]) => fs.read(path) !== c)),
393
+ deletes: consumedFiles(plan, new Set(versions.keys()), {
394
+ fs,
395
+ written: files,
396
+ }),
374
397
  sections,
375
398
  warnings,
376
399
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallyrelease/core",
3
- "version": "0.5.0-beta.56",
3
+ "version": "0.5.0-beta.64",
4
4
  "description": "Pure planning core of tallyrelease",
5
5
  "repository": {
6
6
  "type": "git",