@theholocron/astromech 5.0.0-alpha.33 → 5.0.0-alpha.331
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/README.md +171 -70
- package/dist/config/index.d.mts +52 -8
- package/dist/config/index.mjs +26 -23
- package/dist/editorconfig-checker-HPpphHhI.mjs +39 -0
- package/dist/index.d.mts +1043 -525
- package/dist/index.mjs +3654 -1407
- package/dist/lint/index.d.mts +106 -0
- package/dist/lint/index.mjs +156 -0
- package/dist/load-BMdyQzoc.mjs +472 -0
- package/dist/repo-validation/index.d.mts +300 -0
- package/dist/repo-validation/index.mjs +541 -0
- package/dist/{schema-D01VYg43.d.mts → schema.type-BfeI4AnM.d.mts} +27 -17
- package/package.json +37 -17
- package/dist/schema-Cf5dfaDO.mjs +0 -11
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/** A `[skip docs]` marker found in a PR description or commit message. */
|
|
2
|
+
interface SkipDocs {
|
|
3
|
+
/** The packages it names (`[skip docs: array-utils]`), or `null` for every package. */
|
|
4
|
+
scope: string[] | null;
|
|
5
|
+
/** What follows the marker on its line; empty when the marker gives no reason, which does not count. */
|
|
6
|
+
reason: string;
|
|
7
|
+
}
|
|
8
|
+
/** What the docs-presence check found for the packages a feature changed. */
|
|
9
|
+
interface DocsPresenceResult {
|
|
10
|
+
/** Packages with no docs signal and no `[skip docs]` reason. */
|
|
11
|
+
warn: string[];
|
|
12
|
+
/** Packages a `[skip docs]` marker with a reason covered. */
|
|
13
|
+
skipped: Array<{
|
|
14
|
+
dir: string;
|
|
15
|
+
reason: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** A marker covered a package but gave no reason, so the package is in `warn`. */
|
|
18
|
+
missingReason: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sorts the packages a feature changed into those that need a warning (no docs signal, and no `[skip docs]` marker
|
|
22
|
+
* with a reason that covers them) and those a marker excused. A marker with no reason excuses nothing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function evaluateDocsPresence(input: {
|
|
25
|
+
packages: readonly string[];
|
|
26
|
+
changedFiles: readonly string[];
|
|
27
|
+
addedCommentLines: (dir: string) => readonly string[];
|
|
28
|
+
skip: SkipDocs | null;
|
|
29
|
+
}): DocsPresenceResult;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the PR touches a package's documentation: a doc comment added in its source, its `README.md`, or a docs
|
|
32
|
+
* page named after it (see `pageNames`).
|
|
33
|
+
*/
|
|
34
|
+
export declare function hasDocsSignal(dir: string, changedFiles: readonly string[], addedCommentLines: readonly string[]): boolean;
|
|
35
|
+
/** Whether a line of a unified diff adds part of a doc comment: its `/**` opener, a ` * text` line or the closer. */
|
|
36
|
+
export declare function isAddedDocComment(line: string): boolean;
|
|
37
|
+
/** Whether any subject is a Conventional Commit `feat`: `feat:`, `feat(scope):` or `feat!:`, in any case. */
|
|
38
|
+
export declare function isFeat(subjects: readonly string[]): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The public package a changed file is source of: the nearest folder above it with a `package.json`, when the file is
|
|
41
|
+
* under that package's `src/` or is its root `index`, and the package is not private. Tests, other package files and
|
|
42
|
+
* files in no package give `undefined`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function packageOf(file: string, readPackage: (dir: string) => {
|
|
45
|
+
private?: boolean;
|
|
46
|
+
} | undefined): string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* The names a package's docs page can have: its folder name, and that name without the `-client` or
|
|
49
|
+
* `holocron-plugin-` part its page drops (`clients/axiom-client` is the page `clients/axiom.mdx`).
|
|
50
|
+
*/
|
|
51
|
+
export declare function pageNames(dir: string): string[];
|
|
52
|
+
/**
|
|
53
|
+
* Finds `[skip docs] reason`, or `[skip docs: pkg-a, pkg-b] reason`, on one line of a PR description or commit
|
|
54
|
+
* body. Like semantic-release's `[skip ci]`, except that the reason after it is what makes it count. `null` when the
|
|
55
|
+
* text has no marker.
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseSkipDocs(text: string): SkipDocs | null;
|
|
58
|
+
/** One frontmatter field: its trimmed value and the 1-indexed line it sits on in the file. */
|
|
59
|
+
interface SpecField {
|
|
60
|
+
/** The text after the colon, trimmed; empty for a key that only opens a nested block (`discussion:`). */
|
|
61
|
+
value: string;
|
|
62
|
+
/** 1-indexed, counting the opening `---` as line 1. */
|
|
63
|
+
line: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A file's frontmatter by key. One level of nesting is keyed `parent.child` (`discussion.url`), and the parent
|
|
67
|
+
* key is there too.
|
|
68
|
+
*/
|
|
69
|
+
type SpecFrontmatter = Map<string, SpecField>;
|
|
70
|
+
/** The kind of file the ADR and spec check reads: an architecture decision record or a design spec. */
|
|
71
|
+
type SpecKind = "adr" | "spec";
|
|
72
|
+
/** One problem the ADR and spec check found in a file. */
|
|
73
|
+
interface SpecFinding {
|
|
74
|
+
/** The file's repo-relative path, as it was given to the check. */
|
|
75
|
+
file: string;
|
|
76
|
+
/** 1-indexed: the offending field's own line, or the first line when the field (or the whole frontmatter) is missing. */
|
|
77
|
+
line: number;
|
|
78
|
+
/** The frontmatter field at fault (`id`, `status`, ...), or `frontmatter` when there is none at all. */
|
|
79
|
+
rule: string;
|
|
80
|
+
/** What is wrong, as a sentence. */
|
|
81
|
+
reason: string;
|
|
82
|
+
/** An `error` fails the check; a `warning` is reported and never fails it. */
|
|
83
|
+
severity: "error" | "warning";
|
|
84
|
+
}
|
|
85
|
+
/** A file to check: its repo-relative path and its text. */
|
|
86
|
+
interface SpecFile {
|
|
87
|
+
/** Repo-relative, with `/` separators. */
|
|
88
|
+
path: string;
|
|
89
|
+
/** The file's whole text. */
|
|
90
|
+
text: string;
|
|
91
|
+
}
|
|
92
|
+
/** What the ADR and spec check found across the files it was given. */
|
|
93
|
+
interface SpecsResult {
|
|
94
|
+
/** How many of the files were an ADR or a spec (the rest were not the check's business and were skipped). */
|
|
95
|
+
fileCount: number;
|
|
96
|
+
/** Every problem found, in file order. */
|
|
97
|
+
findings: SpecFinding[];
|
|
98
|
+
}
|
|
99
|
+
/** The three statuses of a spec that its discussion post is reconciled by. */
|
|
100
|
+
interface StatusTriple {
|
|
101
|
+
/** The `status` in the file; `undefined` when it has none. */
|
|
102
|
+
file: string | undefined;
|
|
103
|
+
/** The status the post's tag shows; `undefined` when it has no status tag, or more than one. */
|
|
104
|
+
tag: string | undefined;
|
|
105
|
+
/** The status the file and the tag last agreed on, as written on the post; `undefined` when it carries none yet. */
|
|
106
|
+
synced: string | undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* What to do about a spec's status: `none` (in step), `record` (in step, but the post's last-synced line is stale: just
|
|
110
|
+
* rewrite it), `set-tag` (the file is right: put its status on the tag), `request` (the tag was changed on purpose: ask
|
|
111
|
+
* for the file to change) or `conflict` (both moved, or there is no way to tell: change nothing and say why).
|
|
112
|
+
*/
|
|
113
|
+
type StatusReconciliation = {
|
|
114
|
+
action: "none";
|
|
115
|
+
} | {
|
|
116
|
+
action: "record";
|
|
117
|
+
status: string;
|
|
118
|
+
} | {
|
|
119
|
+
action: "set-tag";
|
|
120
|
+
status: string;
|
|
121
|
+
} | {
|
|
122
|
+
action: "request";
|
|
123
|
+
status: string;
|
|
124
|
+
} | {
|
|
125
|
+
action: "conflict";
|
|
126
|
+
reason: string;
|
|
127
|
+
};
|
|
128
|
+
/** The front matter fields `updateFrontmatter` can set. A field left out is left alone. */
|
|
129
|
+
interface FrontmatterChanges {
|
|
130
|
+
/** The new `id`, such as `SPEC-0007`. Added as the first field when the document has none. */
|
|
131
|
+
id?: string;
|
|
132
|
+
/** The new `status`. */
|
|
133
|
+
status?: string;
|
|
134
|
+
/** The address of the document's discussion post, written as `discussion.url`. */
|
|
135
|
+
discussionUrl?: string;
|
|
136
|
+
}
|
|
137
|
+
/** A spec, as `assignSpecIds` numbers it. */
|
|
138
|
+
interface SpecToNumber {
|
|
139
|
+
/** The spec's repo-relative path. */
|
|
140
|
+
path: string;
|
|
141
|
+
/** The `id` it has, or `undefined` when it has none yet. */
|
|
142
|
+
id: string | undefined;
|
|
143
|
+
/** When its file was first committed, in seconds since the epoch; `undefined` when that is not known. */
|
|
144
|
+
time: number | undefined;
|
|
145
|
+
}
|
|
146
|
+
/** What goes in the first message of a document's discussion post. */
|
|
147
|
+
interface DiscussionBodyInput {
|
|
148
|
+
/** The document's id, such as `SPEC-0007` or `ADR-0009`. */
|
|
149
|
+
id: string;
|
|
150
|
+
/** A short description of the document; empty when it has none. */
|
|
151
|
+
summary: string;
|
|
152
|
+
/** The pull request that added the document, when it is known. */
|
|
153
|
+
pr?: {
|
|
154
|
+
/** The pull request's number. */
|
|
155
|
+
number: number;
|
|
156
|
+
/** The pull request's address. */
|
|
157
|
+
url: string;
|
|
158
|
+
};
|
|
159
|
+
/** Where the document is on the default branch, when it is there: the id then links to it. Left out, the id is plain text. */
|
|
160
|
+
file?: {
|
|
161
|
+
/** The repository, `owner/name`. */
|
|
162
|
+
repo: string;
|
|
163
|
+
/** The default branch. */
|
|
164
|
+
branch: string;
|
|
165
|
+
/** The document's repo-relative path. */
|
|
166
|
+
path: string;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The ids the specs without one should take. They are numbered after the highest id any spec has, one after another,
|
|
171
|
+
* oldest first (by when the file was first committed, then by path), so numbering a whole tree gives the same result
|
|
172
|
+
* every time and a new spec always takes the next number. A spec that already has an id keeps it and is not in the
|
|
173
|
+
* result. Ids are `SPEC-` and at least four digits.
|
|
174
|
+
*/
|
|
175
|
+
export declare function assignSpecIds(specs: readonly SpecToNumber[]): Map<string, string>;
|
|
176
|
+
/**
|
|
177
|
+
* The ADR and spec check over the files it is given: each one that is an ADR or a spec (see `classifySpecPath`) goes to
|
|
178
|
+
* its rules, and every other file is skipped. Whoever calls it decides which files to read (the whole tree, a PR's
|
|
179
|
+
* changed files) and supplies their text; nothing here touches the filesystem or the network.
|
|
180
|
+
*
|
|
181
|
+
* Beyond each file's own rules, two specs may not share an `id`: the later one, in the order given, is an error.
|
|
182
|
+
*/
|
|
183
|
+
export declare function checkSpecs(files: readonly SpecFile[]): SpecsResult;
|
|
184
|
+
/**
|
|
185
|
+
* What a repo-relative path is to the ADR and spec check: an `adr` (a `.md` file directly in the ADR folder, other
|
|
186
|
+
* than the template and the README), a `spec` (a `*.spec.md` file directly in `.notes` or the wiki's specifications
|
|
187
|
+
* folder), or `undefined` for anything else, which the check leaves alone. Subfolders are not searched.
|
|
188
|
+
*/
|
|
189
|
+
export declare function classifySpecPath(path: string): SpecKind | undefined;
|
|
190
|
+
/**
|
|
191
|
+
* The first message of a document's discussion post: its id (a link to the file once it is on the default branch, see
|
|
192
|
+
* {@link discussionIdLine}), a short description, and the pull request that added it,
|
|
193
|
+
* each in a paragraph of its own. The pull request's address is kept in angle brackets so the chat service does not
|
|
194
|
+
* expand it into a preview card. A part that is not known (a document with no summary, one whose pull request cannot
|
|
195
|
+
* be found) is left out, with its blank line.
|
|
196
|
+
*/
|
|
197
|
+
export declare function discussionBody({ id, summary, pr, file }: DiscussionBodyInput): string;
|
|
198
|
+
/**
|
|
199
|
+
* The line of a discussion post's first message that names the document: its id (`SPEC-0007`), and, once the file is on
|
|
200
|
+
* the default branch, the id as a link to the file at its path there: `[SPEC-0007](<address>)`. The address is
|
|
201
|
+
* `https://github.com/<repo>/blob/<branch>/<path>`, kept in angle brackets so the chat service does not expand it into a
|
|
202
|
+
* preview card. Plain text when `file` is not given: while a pull request is open its `PR:` line is the link, and a blob
|
|
203
|
+
* address on a branch where the file does not yet exist leads nowhere. {@link discussionBody} writes it, a file that moved
|
|
204
|
+
* is given its new address with it, and a repair of existing posts compares against it.
|
|
205
|
+
*/
|
|
206
|
+
export declare function discussionIdLine(id: string, file: DiscussionBodyInput["file"]): string;
|
|
207
|
+
/**
|
|
208
|
+
* The line of a discussion post's first message that names the pull request that added the document:
|
|
209
|
+
* `PR: [#1538](<address>)`. The address is kept in angle brackets so the chat service does not expand it into a preview
|
|
210
|
+
* card. Empty when the pull request is not known, so a post names none. {@link discussionBody} writes it, and a repair of
|
|
211
|
+
* existing posts compares against it.
|
|
212
|
+
*/
|
|
213
|
+
export declare function discussionPrLine(pr: DiscussionBodyInput["pr"]): string;
|
|
214
|
+
/**
|
|
215
|
+
* The title of a spec's or ADR's discussion post: the document's own title, in plain text (a title cannot be formatted),
|
|
216
|
+
* cut with an ellipsis so it is at most 100 characters. The title is the document's own (see `specTitle`), already free
|
|
217
|
+
* of markup. Nothing is put in front of it: the status tag says where the document stands and the id is in the first message.
|
|
218
|
+
*/
|
|
219
|
+
export declare function discussionTitle(title: string): string;
|
|
220
|
+
/** Whether `value` is a `YYYY-MM-DD` date that exists as far as `Date.parse` can tell. */
|
|
221
|
+
export declare function isValidIsoDate(value: string): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Reads a leading `---` block of `key: value` lines, with the line each one is on, plus one level of nesting keyed
|
|
224
|
+
* `parent.child` (the ADR template's `discussion:` / ` url:`). Any other line is skipped. Returns `null` when the
|
|
225
|
+
* text does not open with such a block.
|
|
226
|
+
*/
|
|
227
|
+
export declare function parseFrontmatter(content: string): SpecFrontmatter | null;
|
|
228
|
+
/**
|
|
229
|
+
* What to do about a spec's status when the file, the tag on its discussion post and the status last synced may all
|
|
230
|
+
* differ. Two values cannot tell "someone retagged" from "the file changed and the tag has not caught up"; the third,
|
|
231
|
+
* the status the post was last in step with, can.
|
|
232
|
+
*
|
|
233
|
+
* - in step (tag is the file's status): nothing, or just record it when the post's last-synced line is stale
|
|
234
|
+
* - the tag is missing (none, or more than one status tag): put the file's status on it
|
|
235
|
+
* - only the file moved since the last sync (a merged edit): set the tag to the file's status
|
|
236
|
+
* - only the tag moved (a gatekeeper retagged): ask for the file to change, through a pull request
|
|
237
|
+
* - both moved, or there is no last-synced status to tell by: report a conflict and change nothing
|
|
238
|
+
*
|
|
239
|
+
* - the tag is `withdrawn` (the post's pull request closed unmerged, #1653): never a retag, since no file has that status.
|
|
240
|
+
* The file's status goes back on the tag, which is what reopening the pull request, or the same file coming back in a
|
|
241
|
+
* new one, needs.
|
|
242
|
+
*
|
|
243
|
+
* A file with no `status` cannot be synced, so that is a conflict too.
|
|
244
|
+
*/
|
|
245
|
+
export declare function reconcileSpecStatus({ file, tag, synced }: StatusTriple): StatusReconciliation;
|
|
246
|
+
/** Where ADRs live, relative to the repo root. */
|
|
247
|
+
export declare const ADR_DIR = "docs/wiki/decisions";
|
|
248
|
+
/** Where specs live, relative to the repo root: in-progress ones in `.notes`, settled ones under the wiki. */
|
|
249
|
+
export declare const SPEC_DIRS: readonly string[];
|
|
250
|
+
/** The statuses an ADR may have. */
|
|
251
|
+
export declare const ADR_STATUSES: readonly string[];
|
|
252
|
+
/** The statuses a spec may have. */
|
|
253
|
+
export declare const SPEC_STATUSES: readonly string[];
|
|
254
|
+
/**
|
|
255
|
+
* The statuses that mean a document is finished with: a spec that shipped or was dropped, one that was replaced, an ADR
|
|
256
|
+
* that was turned down or is no longer followed. Its discussion is closed and locked, so it does not start up again;
|
|
257
|
+
* the others (`draft`, `proposed`, `accepted`) stay open, since an accepted document is still asked about.
|
|
258
|
+
*/
|
|
259
|
+
export declare const CLOSED_STATUSES: readonly string[];
|
|
260
|
+
/**
|
|
261
|
+
* The tag a discussion post carries while its pull request is closed unmerged. It is a state of the post only: no file
|
|
262
|
+
* may have it as its `status` (`ADR_STATUSES` and `SPEC_STATUSES` leave it out), and `reconcileSpecStatus` never reads it
|
|
263
|
+
* as a gatekeeper's retag. A post with it is closed, like one with a finished status.
|
|
264
|
+
*/
|
|
265
|
+
export declare const WITHDRAWN_STATE = "withdrawn";
|
|
266
|
+
/** The files in the ADR folder that are not ADRs. */
|
|
267
|
+
export declare const ADR_EXEMPT: readonly string[];
|
|
268
|
+
/**
|
|
269
|
+
* A short summary of a spec or ADR for a discussion post: the first paragraph under a `Problem`, `Why`, `Context`,
|
|
270
|
+
* `Summary` or `Overview` heading, else the first paragraph after the title, cut with an ellipsis at 1000 characters.
|
|
271
|
+
* Empty when the document has no paragraph at all. The post links to the file for the rest; the text is not mirrored.
|
|
272
|
+
*/
|
|
273
|
+
export declare function specSummary(text: string): string;
|
|
274
|
+
/**
|
|
275
|
+
* A spec's title for a chat post: its first `# ` heading after the frontmatter, else its file name without `.spec.md`.
|
|
276
|
+
* What the file says is written by whoever opened the pull request, so the result carries no markdown, brackets or
|
|
277
|
+
* line breaks that could turn it into a link or a layout of its own.
|
|
278
|
+
*/
|
|
279
|
+
export declare function specTitle(path: string, text: string): string;
|
|
280
|
+
/**
|
|
281
|
+
* A document's text with its front matter changed: `id` and `status` set, and `discussion.url` set to the address of its discussion
|
|
282
|
+
* post. Nothing else in the file moves: the other fields, their order and the body are left as they were. A document
|
|
283
|
+
* with no front matter is returned unchanged.
|
|
284
|
+
*/
|
|
285
|
+
export declare function updateFrontmatter(text: string, changes: FrontmatterChanges): string;
|
|
286
|
+
/**
|
|
287
|
+
* The findings for one ADR's text. Errors: no frontmatter; a missing `id`, or one that is not `ADR-<the filename's
|
|
288
|
+
* four-digit prefix>`; a missing or empty `title`; a missing or unknown `status`; a missing or malformed `date`. A
|
|
289
|
+
* warning: an `accepted` ADR with no `discussion.url`, the address of its discussion post, which `holocron specs sync`
|
|
290
|
+
* writes. A GitHub Discussion link does not count.
|
|
291
|
+
*/
|
|
292
|
+
export declare function validateAdr(file: string, content: string): SpecFinding[];
|
|
293
|
+
/**
|
|
294
|
+
* The findings for one spec's text. Errors: no frontmatter; a missing or unknown `status`; an `id` that is not
|
|
295
|
+
* `SPEC-` and four digits. Warnings: a missing `id` (`holocron specs sync` numbers it, so a new spec needs none); a missing
|
|
296
|
+
* `issue` (every spec has a companion GitHub issue), except on an `archived` or `superseded` spec, many of which
|
|
297
|
+
* predate the issue-first process.
|
|
298
|
+
*/
|
|
299
|
+
export declare function validateSpec(file: string, content: string): SpecFinding[];
|
|
300
|
+
export type { DiscussionBodyInput, DocsPresenceResult, FrontmatterChanges, SkipDocs, SpecField, SpecFile, SpecFinding, SpecFrontmatter, SpecKind, SpecToNumber, SpecsResult, StatusReconciliation, StatusTriple };
|