@osdlc/repo-cleaner 0.17.2 → 0.18.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/CHANGELOG.md +18 -0
- package/README.md +497 -329
- package/dist/branches.d.ts +9 -36
- package/dist/branches.js +92 -172
- package/dist/clean.d.ts +162 -0
- package/dist/clean.js +755 -0
- package/dist/cli.d.ts +12 -16
- package/dist/cli.js +340 -479
- package/dist/hooks.d.ts +8 -12
- package/dist/hooks.js +2 -2
- package/dist/index.d.ts +18 -25
- package/dist/index.js +16 -23
- package/dist/landing.d.ts +3 -3
- package/dist/landing.js +7 -7
- package/dist/plan.d.ts +76 -70
- package/dist/plan.js +82 -77
- package/dist/receipt.d.ts +44 -57
- package/dist/receipt.js +46 -28
- package/dist/reference.d.ts +12 -0
- package/dist/reference.js +148 -0
- package/dist/remote-mirror.d.ts +8 -0
- package/dist/remote-mirror.js +18 -0
- package/dist/render.d.ts +61 -61
- package/dist/render.js +195 -254
- package/dist/resolve.js +1 -9
- package/dist/status-line.d.ts +1 -1
- package/dist/status-line.js +5 -5
- package/dist/step-board.d.ts +1 -1
- package/dist/step-board.js +2 -5
- package/dist/submodules.d.ts +120 -0
- package/dist/submodules.js +292 -0
- package/dist/sweep.d.ts +97 -67
- package/dist/sweep.js +272 -118
- package/dist/types.d.ts +276 -105
- package/dist/types.js +100 -54
- package/dist/util.d.ts +7 -0
- package/dist/util.js +20 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/worktrees.d.ts +21 -37
- package/dist/worktrees.js +198 -165
- package/package.json +4 -4
- package/dist/apply.d.ts +0 -131
- package/dist/apply.js +0 -541
package/dist/sweep.d.ts
CHANGED
|
@@ -1,93 +1,123 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The sweep
|
|
2
|
+
* The sweep: resolve the targets, then inventory every repository they name.
|
|
3
3
|
*
|
|
4
|
-
* Every
|
|
5
|
-
*
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
*
|
|
21
|
-
*
|
|
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
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
fetch?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Where the caller is standing. A worktree containing it is never proposed
|
|
32
|
-
* for removal. Defaults to the process's cwd.
|
|
33
|
-
*/
|
|
34
|
-
cwd?: string;
|
|
35
|
-
/**
|
|
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.
|
|
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.
|
|
42
42
|
*/
|
|
43
43
|
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
44
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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.
|
|
52
48
|
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
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
|
+
* target sweeps the checkout at `cwd`.
|
|
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;
|
|
84
|
+
branch?: string | undefined;
|
|
85
|
+
/** Only the worktree at this path; for {@link inspectWorktree}. */
|
|
86
|
+
worktree?: string | undefined;
|
|
87
|
+
cwd: string;
|
|
88
|
+
annotate?: Annotate | undefined;
|
|
55
89
|
onProgress?: ((progress: SweepProgress) => void) | undefined;
|
|
56
|
-
/** Where this repository sits in a run of several, for {@link onProgress}. Defaults to 1 of 1. */
|
|
57
90
|
position?: {
|
|
58
91
|
index: number;
|
|
59
92
|
of: number;
|
|
60
93
|
} | undefined;
|
|
61
94
|
}
|
|
62
95
|
/**
|
|
63
|
-
* Inventory one repository
|
|
64
|
-
*
|
|
65
|
-
* Never throws for a repository
|
|
66
|
-
*
|
|
67
|
-
* single-repository caller checks that field.
|
|
96
|
+
* Inventory one repository, annotated and with freed branches held, as
|
|
97
|
+
* {@link sweep} does for each. The engine `check` and `run` re-sweep with.
|
|
98
|
+
* Never throws for a repository it cannot read; throws a `conflict` for a
|
|
99
|
+
* `branch` that is the default branch.
|
|
68
100
|
*/
|
|
69
|
-
export declare function sweepRepo(path: string, opts
|
|
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
|
-
}
|
|
101
|
+
export declare function sweepRepo(path: string, opts: RepoSweepOptions): RepoSweep;
|
|
76
102
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* {@link resolveEntries}. A repository that fails discovery becomes an error
|
|
81
|
-
* row and the sweep continues.
|
|
103
|
+
* Keep again each branch the sweep freed for its worktree's removal when that
|
|
104
|
+
* worktree no longer frees it: a host's `annotate` held it back, demoted it,
|
|
105
|
+
* or dropped its row. Running it twice changes nothing.
|
|
82
106
|
*/
|
|
83
|
-
export declare function
|
|
107
|
+
export declare function holdFreedBranches(rows: Row[], branchScoped: boolean): Row[];
|
|
84
108
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
109
|
+
* The worktree at `path`, judged as a sweep judges it: its verdict, risks,
|
|
110
|
+
* blockers and evidence, submodules included. Reads git and the process
|
|
111
|
+
* table; asks no provider.
|
|
112
|
+
*
|
|
113
|
+
* The main checkout is a worktree too: it comes back as its `keep` row
|
|
114
|
+
* ("primary worktree").
|
|
115
|
+
*
|
|
116
|
+
* @throws RepoCleanerError (`not-found`) when `path` is not a worktree of a
|
|
117
|
+
* repository git can read.
|
|
90
118
|
*/
|
|
91
|
-
export declare function
|
|
92
|
-
|
|
93
|
-
|
|
119
|
+
export declare function inspectWorktree(path: string, opts?: Runners & {
|
|
120
|
+
cwd?: string | undefined;
|
|
121
|
+
annotate?: Annotate | undefined;
|
|
122
|
+
}): WorktreeRow;
|
|
123
|
+
export {};
|