@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.
- package/CHANGELOG.md +31 -0
- package/README.md +691 -305
- package/dist/branches.d.ts +37 -36
- package/dist/branches.js +199 -196
- package/dist/clean.d.ts +179 -0
- package/dist/clean.js +824 -0
- package/dist/cli.d.ts +12 -16
- package/dist/cli.js +367 -478
- 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/providers/github.d.ts +2 -1
- package/dist/providers/github.js +2 -1
- package/dist/providers/gitlab.d.ts +3 -2
- package/dist/providers/gitlab.js +14 -8
- package/dist/providers/index.d.ts +5 -4
- package/dist/providers/index.js +8 -5
- package/dist/providers/types.d.ts +8 -2
- package/dist/prs.d.ts +35 -7
- package/dist/prs.js +45 -12
- package/dist/receipt.d.ts +46 -57
- package/dist/receipt.js +52 -28
- package/dist/reference.d.ts +12 -0
- package/dist/reference.js +152 -0
- package/dist/remote-mirror.d.ts +9 -1
- package/dist/remote-mirror.js +19 -1
- package/dist/render.d.ts +66 -61
- package/dist/render.js +206 -255
- package/dist/resolve.d.ts +3 -3
- package/dist/resolve.js +4 -12
- 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 +107 -64
- package/dist/sweep.js +333 -119
- package/dist/types.d.ts +294 -105
- package/dist/types.js +106 -54
- package/dist/util.d.ts +13 -0
- package/dist/util.js +36 -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 +5 -5
- package/dist/apply.d.ts +0 -131
- package/dist/apply.js +0 -541
package/dist/sweep.d.ts
CHANGED
|
@@ -1,93 +1,136 @@
|
|
|
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
|
-
*
|
|
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
|
-
|
|
43
|
+
branch?: string | undefined;
|
|
30
44
|
/**
|
|
31
|
-
* Where the caller is standing
|
|
32
|
-
*
|
|
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
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
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
|
|
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
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
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
|
|
120
|
+
export declare function holdFreedBranches(rows: Row[], branchScoped: boolean): Row[];
|
|
84
121
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
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
|
|
92
|
-
|
|
93
|
-
|
|
132
|
+
export declare function inspectWorktree(path: string, opts?: Runners & {
|
|
133
|
+
cwd?: string | undefined;
|
|
134
|
+
annotate?: Annotate | undefined;
|
|
135
|
+
}): WorktreeRow;
|
|
136
|
+
export {};
|