@osdlc/repo-cleaner 0.17.2 → 0.19.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 (54) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +691 -305
  3. package/dist/branches.d.ts +37 -36
  4. package/dist/branches.js +199 -196
  5. package/dist/clean.d.ts +179 -0
  6. package/dist/clean.js +824 -0
  7. package/dist/cli.d.ts +12 -16
  8. package/dist/cli.js +367 -478
  9. package/dist/hooks.d.ts +8 -12
  10. package/dist/hooks.js +2 -2
  11. package/dist/index.d.ts +18 -25
  12. package/dist/index.js +16 -23
  13. package/dist/landing.d.ts +3 -3
  14. package/dist/landing.js +7 -7
  15. package/dist/plan.d.ts +76 -70
  16. package/dist/plan.js +82 -77
  17. package/dist/providers/github.d.ts +2 -1
  18. package/dist/providers/github.js +2 -1
  19. package/dist/providers/gitlab.d.ts +3 -2
  20. package/dist/providers/gitlab.js +14 -8
  21. package/dist/providers/index.d.ts +5 -4
  22. package/dist/providers/index.js +8 -5
  23. package/dist/providers/types.d.ts +8 -2
  24. package/dist/prs.d.ts +35 -7
  25. package/dist/prs.js +45 -12
  26. package/dist/receipt.d.ts +46 -57
  27. package/dist/receipt.js +52 -28
  28. package/dist/reference.d.ts +12 -0
  29. package/dist/reference.js +152 -0
  30. package/dist/remote-mirror.d.ts +9 -1
  31. package/dist/remote-mirror.js +19 -1
  32. package/dist/render.d.ts +66 -61
  33. package/dist/render.js +206 -255
  34. package/dist/resolve.d.ts +3 -3
  35. package/dist/resolve.js +4 -12
  36. package/dist/status-line.d.ts +1 -1
  37. package/dist/status-line.js +5 -5
  38. package/dist/step-board.d.ts +1 -1
  39. package/dist/step-board.js +2 -5
  40. package/dist/submodules.d.ts +120 -0
  41. package/dist/submodules.js +292 -0
  42. package/dist/sweep.d.ts +107 -64
  43. package/dist/sweep.js +333 -119
  44. package/dist/types.d.ts +294 -105
  45. package/dist/types.js +106 -54
  46. package/dist/util.d.ts +13 -0
  47. package/dist/util.js +36 -0
  48. package/dist/version.generated.d.ts +1 -1
  49. package/dist/version.generated.js +1 -1
  50. package/dist/worktrees.d.ts +21 -37
  51. package/dist/worktrees.js +198 -165
  52. package/package.json +5 -5
  53. package/dist/apply.d.ts +0 -131
  54. package/dist/apply.js +0 -541
package/dist/sweep.d.ts CHANGED
@@ -1,93 +1,136 @@
1
1
  /**
2
- * The sweep itself: one repository, or many.
2
+ * The sweep: resolve the targets, then inventory every repository they name.
3
3
  *
4
- * Every item carries the command that would act on it, and running that
5
- * command is the caller's decision. The only write is the optional fetch,
6
- * which updates remote-tracking refs and nothing else.
4
+ * Every row carries the commands that would act on it, and running them is
5
+ * the caller's decision. The only write is the fetch a sweep of remote
6
+ * branches makes, which updates remote-tracking refs and nothing else, and the
7
+ * clone a remote URL target is swept through.
7
8
  */
8
9
  import type { CommandRunner } from '@osdlc/command-seam';
10
+ import type { Annotate } from './hooks.ts';
9
11
  import { type ProcessProbe } from './processes.ts';
10
12
  import { type ProviderChoice } from './providers/index.ts';
11
- import { type RepoSweep, type Scope, type SweepItem, type SweepProgress, type SweepResult } from './types.ts';
12
- export interface SweepOptions {
13
- /** Which categories to gather. Defaults to all of them. */
14
- scope?: Iterable<Scope | string>;
15
- /** Remote to measure against. Defaults to `origin`, then the first one. */
16
- remote?: string | null;
17
- /** Ask no provider and classify on git evidence alone. Same as `provider: 'none'`, and wins over it. */
18
- noProvider?: boolean;
13
+ import { type Kind, type RepoSweep, type Row, type Sweep, type SweepProgress, type SweptWith, type WorktreeRow } from './types.ts';
14
+ /** Runners and the process probe: what a test or a host injects. */
15
+ export interface Runners {
16
+ /** Defaults spawn the real `git`, `gh` and `glab`. */
17
+ git?: CommandRunner | undefined;
18
+ gh?: CommandRunner | undefined;
19
+ glab?: CommandRunner | undefined;
19
20
  /**
20
- * Which provider to ask for pull requests: `github` (`gh`), `gitlab`
21
- * (`glab`), `none`, or `auto`, which reads the remote's host. Defaults to `auto`.
21
+ * Answers whether a worktree lock's owner is alive and which processes work
22
+ * inside a worktree. Defaults to {@link defaultProcessProbe}, over `ps` and
23
+ * `lsof`.
22
24
  */
25
+ probe?: ProcessProbe | undefined;
26
+ }
27
+ export interface SweepOptions extends Runners {
28
+ /** Only these kinds of row. Default: `worktree` and `branch`, and `remote` with `remote`. Naming `remote` implies `remote`. */
29
+ only?: readonly Kind[] | undefined;
30
+ /** Also judge remote branches: fetches each remote first and looks up pull requests. */
31
+ remote?: boolean | undefined;
32
+ /** With `remote`: do not fetch; judge against the remote-tracking refs on disk. */
33
+ offline?: boolean | undefined;
34
+ /** The remote whose default branch counts as "merged into". Default `origin`, then the first remote. */
35
+ against?: string | undefined;
36
+ /** With `remote`: where pull requests come from. Default `auto`, by the remote's host. */
23
37
  provider?: ProviderChoice | undefined;
24
38
  /**
25
- * Run `git fetch --prune <remote>` before classifying, so ancestry is read
26
- * against fresh remote-tracking refs. A failed fetch makes the repository
27
- * an error row. Off by default.
39
+ * One branch only: its worktree, its local branch, and its remote branch
40
+ * with `remote`. `HEAD` is the branch checked out at the target. Takes at
41
+ * most one target, no remote URL, and never the default branch.
28
42
  */
29
- fetch?: boolean;
43
+ branch?: string | undefined;
30
44
  /**
31
- * Where the caller is standing. A worktree containing it is never proposed
32
- * for removal. Defaults to the process's cwd.
45
+ * Where the caller is standing: the base for relative targets, the target
46
+ * when none is given, and a worktree that is never offered for removal.
47
+ * Defaults to the process's cwd.
33
48
  */
34
- cwd?: string;
49
+ cwd?: string | undefined;
50
+ /** Where remote URL targets' clones are kept. Defaults to {@link defaultCacheDir}. */
51
+ cacheDir?: string | undefined;
52
+ /** A host's re-ranking of each repository's rows. */
53
+ annotate?: Annotate | undefined;
54
+ /** Told before each step, and before each row of a step that walks many. For a status line. */
55
+ onProgress?: ((progress: SweepProgress) => void) | undefined;
56
+ /** Told, mid-walk, that a target directory is enormous. Defaults to stderr. */
57
+ onWarn?: ((message: string) => void) | undefined;
58
+ }
59
+ /**
60
+ * The sweep `targets` and `opts` ask for, as a plan records it. Throws a
61
+ * {@link RepoCleanerError} for options that contradict each other or would
62
+ * have no effect, before anything is read.
63
+ */
64
+ export declare function sweptWith(targets: readonly string[], opts: Omit<SweepOptions, Exclude<keyof Runners, 'git'> | 'annotate' | 'onProgress' | 'onWarn' | 'cacheDir'>): SweptWith & {
65
+ urls: boolean;
66
+ };
67
+ /**
68
+ * Sweep `targets`: checkouts, directories to search for checkouts, or remote
69
+ * URLs (swept through a clone kept in `cacheDir`, remote branches only). No
70
+ * targets means `[cwd]`, resolved the same way.
71
+ *
72
+ * Never throws for a repository it cannot read: that one comes back with
73
+ * `error` set, because a fan-out must not end on its first bad entry. Throws a
74
+ * {@link RepoCleanerError} for options that contradict each other, before
75
+ * reading anything.
76
+ */
77
+ export declare function sweep(targets: readonly string[], opts?: SweepOptions): Sweep;
78
+ /** What {@link sweepRepo} takes: a sweep's options, already resolved. */
79
+ interface RepoSweepOptions extends Runners {
80
+ only: readonly Kind[];
81
+ against?: string | undefined;
82
+ provider: ProviderChoice;
83
+ fetch: boolean;
35
84
  /**
36
- * Inventory one branch only: the worktree holding it, its local branch and
37
- * its remote branch. The default branch is refused. `cwd` is ignored, so the
38
- * worktree is judged on its facts, and the local branch is not pinned for
39
- * being checked out there: apply removes the worktree first. It stays pinned
40
- * when that worktree is blocked or cannot be removed, or when `scope` leaves
41
- * worktrees out.
85
+ * Read remote tips with `ls-remote` even without a fetch: `clean`'s
86
+ * re-check, which must not delete on the strength of a stale tracking ref.
87
+ * Without a fetch, a failed `ls-remote` then fails the repository rather
88
+ * than fall back to those refs.
42
89
  */
90
+ liveRemoteTips?: boolean | undefined;
43
91
  branch?: string | undefined;
44
- /** Injected runners. Defaults spawn the real `git`, `gh` and `glab`. */
45
- git?: CommandRunner | undefined;
46
- gh?: CommandRunner | undefined;
47
- glab?: CommandRunner | undefined;
48
- /**
49
- * Answers whether a worktree lock's owner is alive and which processes work
50
- * inside a worktree. Defaults to {@link defaultProcessProbe}, one per
51
- * repository, over `ps` and `lsof`.
52
- */
53
- probe?: ProcessProbe | undefined;
54
- /** Told before each step, and before each item of a step that walks many. For a status line. */
92
+ /** Only the worktree at this path; for {@link inspectWorktree}. */
93
+ worktree?: string | undefined;
94
+ cwd: string;
95
+ annotate?: Annotate | undefined;
55
96
  onProgress?: ((progress: SweepProgress) => void) | undefined;
56
- /** Where this repository sits in a run of several, for {@link onProgress}. Defaults to 1 of 1. */
57
97
  position?: {
58
98
  index: number;
59
99
  of: number;
60
100
  } | undefined;
61
101
  }
62
102
  /**
63
- * Inventory one repository.
103
+ * Inventory one repository, annotated and with freed branches held, as
104
+ * {@link sweep} does for each. The engine `check` and `run` re-sweep with.
105
+ * Never throws for a repository it cannot read; throws a `conflict` for a
106
+ * `branch` that is the default branch.
64
107
  *
65
- * Never throws for a repository that cannot be read: the failure is returned
66
- * as `error`, because a fan-out must not end on its first bad entry. A
67
- * single-repository caller checks that field.
108
+ * A failed fetch fails the repository. A lookup that only adds evidence does
109
+ * not: a remote whose branches `ls-remote` cannot list is read from the
110
+ * remote-tracking refs the fetch just wrote, and a provider whose listing
111
+ * fails leaves no pull request evidence. Each is a sentence in `notes`, and
112
+ * every row is judged on the evidence that is left.
68
113
  */
69
- export declare function sweepRepo(path: string, opts?: SweepOptions): RepoSweep;
70
- export interface SweepReposOptions extends SweepOptions {
71
- /** Base for a relative entry. Defaults to the process's cwd. */
72
- baseDir?: string;
73
- /** Told, mid-walk, that a container entry is enormous. Defaults to stderr. */
74
- onWarn?: ((message: string) => void) | undefined;
75
- }
114
+ export declare function sweepRepo(path: string, opts: RepoSweepOptions): RepoSweep;
76
115
  /**
77
- * Resolve `entries` and inventory every repository they name.
78
- *
79
- * Entries may be checkouts or directories containing checkouts; see
80
- * {@link resolveEntries}. A repository that fails discovery becomes an error
81
- * row and the sweep continues.
116
+ * Keep again each branch the sweep freed for its worktree's removal when that
117
+ * worktree no longer frees it: a host's `annotate` held it back, demoted it,
118
+ * or dropped its row. Running it twice changes nothing.
82
119
  */
83
- export declare function sweepRepos(entries: readonly string[], opts?: SweepReposOptions): SweepResult;
120
+ export declare function holdFreedBranches(rows: Row[], branchScoped: boolean): Row[];
84
121
  /**
85
- * Keep again each branch a sweep freed for its worktree's removal when that
86
- * worktree no longer frees it by the sweep's own rule: a host's `annotate`
87
- * held it back or demoted it, or dropped its row. Run it on annotated rows,
88
- * with `branchScoped` set for a `branch` sweep, so the counts and the plan
89
- * match what `applyPlan` will do. Running it twice changes nothing.
122
+ * The worktree at `path`, judged as a sweep judges it: its verdict, risks,
123
+ * blockers and evidence, submodules included. Reads git and the process
124
+ * table; asks no provider.
125
+ *
126
+ * The main checkout is a worktree too: it comes back as its `keep` row
127
+ * ("primary worktree").
128
+ *
129
+ * @throws RepoCleanerError (`not-found`) when `path` is not a worktree of a
130
+ * repository git can read.
90
131
  */
91
- export declare function holdFreedBranches(items: SweepItem[], opts?: {
92
- branchScoped?: boolean;
93
- }): SweepItem[];
132
+ export declare function inspectWorktree(path: string, opts?: Runners & {
133
+ cwd?: string | undefined;
134
+ annotate?: Annotate | undefined;
135
+ }): WorktreeRow;
136
+ export {};