@theholocron/astromech 5.0.0-alpha.56 → 5.0.0-alpha.560
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 +220 -81
- package/dist/config/index.d.mts +55 -12
- package/dist/config/index.mjs +15 -23
- package/dist/editorconfig-checker-BKNGE7U2.mjs +27 -0
- package/dist/index.d.mts +1414 -512
- package/dist/index.mjs +4242 -1429
- package/dist/lint/index.d.mts +97 -0
- package/dist/lint/index.mjs +160 -0
- package/dist/load-WHAqMxwx.mjs +549 -0
- package/dist/repo-validation/index.d.mts +300 -0
- package/dist/repo-validation/index.mjs +577 -0
- package/dist/schema.type-MUEwDLrg.d.mts +132 -0
- package/dist/upgrade/index.d.mts +126 -0
- package/dist/upgrade/index.mjs +283 -0
- package/package.json +48 -22
- package/dist/schema-Cf5dfaDO.mjs +0 -11
- package/dist/schema-D01VYg43.d.mts +0 -77
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { QualifiedConfig } from "@commitlint/types";
|
|
2
|
+
/**
|
|
3
|
+
* The org's canonical `alex` (inclusive-language) config, as raw parsed
|
|
4
|
+
* data. The one canonical copy is `alexrc.json` beside this file. A central
|
|
5
|
+
* Sentinel check (holocron#769/#793) reads it directly rather than fetching
|
|
6
|
+
* each repo's own copy via the Contents API — the same "one config, not N
|
|
7
|
+
* copies" reasoning `@theholocron/commitlint-config` already established for
|
|
8
|
+
* commit-message linting. `holocron setup` no longer writes a per-repo
|
|
9
|
+
* `.alexrc.json` or `.alexignore` (#831).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The org's canonical `alex` (inclusive-language) config as data: the words it allows, from the one JSON file
|
|
13
|
+
* `alexrc.json` beside this module.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ALEX_CONFIG: {
|
|
16
|
+
/** The words `alex` accepts despite its default rules. */
|
|
17
|
+
allow: string[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Glob-ish path patterns `alex` skips: the one copy of the list. It used to be mirrored by hand in an extensionless
|
|
21
|
+
* `alexignore` template that `holocron setup` wrote into each repo as `.alexignore`; setup no longer writes it (#831), so
|
|
22
|
+
* Sentinel's check and the Prettier ignore list read this.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ALEX_IGNORE_PATTERNS: string[];
|
|
25
|
+
/**
|
|
26
|
+
* The paths editorconfig-checker skips, read from the same
|
|
27
|
+
* `editorconfig-checker.json` template `holocron setup` writes as a repo's
|
|
28
|
+
* `.editorconfig-checker.json` — so Sentinel's central editorconfig check
|
|
29
|
+
* (holocron#927) excludes exactly what CI's editorconfig-checker does, from
|
|
30
|
+
* one source.
|
|
31
|
+
*
|
|
32
|
+
* The exclusion that matters most is `\.md$` / `\.mdx$`: the generated
|
|
33
|
+
* `.editorconfig` gives every file tab indentation, but
|
|
34
|
+
* `@theholocron/prettier-config` formats markdown with spaces, so a README's
|
|
35
|
+
* indented code example would fail one tool or the other. Markdown is left
|
|
36
|
+
* to prettier and markdownlint.
|
|
37
|
+
*
|
|
38
|
+
* Each entry is a regular-expression source, matched against a
|
|
39
|
+
* repo-relative path, as editorconfig-checker itself treats them.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* The paths editorconfig-checker skips, as regular-expression sources matched against a repo-relative path; the
|
|
43
|
+
* list `holocron setup` writes into `.editorconfig-checker.json`.
|
|
44
|
+
*/
|
|
45
|
+
export declare const EDITORCONFIG_CHECKER_EXCLUDE: readonly string[];
|
|
46
|
+
/** `true` when `path` matches any {@link EDITORCONFIG_CHECKER_EXCLUDE} pattern. */
|
|
47
|
+
export declare function isEditorConfigExcluded(path: string): boolean;
|
|
48
|
+
/** One commitlint rule a commit message broke. */
|
|
49
|
+
interface CommitMessageViolation {
|
|
50
|
+
/** Rule name, e.g. `"subject-empty"`. */
|
|
51
|
+
rule: string;
|
|
52
|
+
/** commitlint's own message for the failure, e.g. `"subject may not be empty"`. */
|
|
53
|
+
message: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Lints one commit message against an already-loaded commitlint config and returns each rule it breaks; an empty
|
|
57
|
+
* list means it is valid.
|
|
58
|
+
*/
|
|
59
|
+
export declare function lintCommitMessage(message: string, loaded: QualifiedConfig): Promise<CommitMessageViolation[]>;
|
|
60
|
+
/** What linting a commit message file found. */
|
|
61
|
+
interface LintCommitMsgFileResult {
|
|
62
|
+
/** Whether the message broke no rule. */
|
|
63
|
+
valid: boolean;
|
|
64
|
+
/** Each rule the message broke; empty when it is valid. */
|
|
65
|
+
violations: CommitMessageViolation[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Lints the commit message in `filePath` (what git's `commit-msg` hook passes as `$1`) against the commitlint
|
|
69
|
+
* config found by searching up from `cwd`.
|
|
70
|
+
*/
|
|
71
|
+
export declare function lintCommitMsgFile(filePath: string, cwd?: string): Promise<LintCommitMsgFileResult>;
|
|
72
|
+
/**
|
|
73
|
+
* The org's canonical prettier ignore-pattern list for a central Sentinel
|
|
74
|
+
* check (holocron#769/#819) — the `PRETTIER_CONFIG` object itself doesn't
|
|
75
|
+
* need a home here, since `@theholocron/prettier-config`'s default export
|
|
76
|
+
* already *is* one canonical, importable config (the same "one config,
|
|
77
|
+
* not N copies" reasoning `@theholocron/commitlint-config` established for
|
|
78
|
+
* commit-message linting, and `ALEX_CONFIG` established for inclusive
|
|
79
|
+
* language) — only the ignore list is a Sentinel-specific decision that
|
|
80
|
+
* belongs alongside `ALEX_IGNORE_PATTERNS`, not inside the config package.
|
|
81
|
+
*
|
|
82
|
+
* Reuses `ALEX_IGNORE_PATTERNS`' own entries (`.github/*`, `CHANGELOG.md`,
|
|
83
|
+
* `LICENSE` all independently confirmed to fail a real `prettier.check()`
|
|
84
|
+
* today — machine-generated or unparseable content, same reasoning that
|
|
85
|
+
* excluded them from alex), plus `pnpm-lock.yaml` — prettier-specific
|
|
86
|
+
* (alex never reads a lockfile, but prettier would try to reformat it):
|
|
87
|
+
* machine-written by pnpm's own writer, and not gitignored (lockfiles are
|
|
88
|
+
* tracked), so prettier picks it up by default. Reformatting it
|
|
89
|
+
* fights every subsequent `pnpm install` (this repo's own `.prettierignore`
|
|
90
|
+
* already excludes it for that exact reason).
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* The paths Prettier skips in every repo: the ones inclusive-language checking skips, plus the pnpm lockfile, which
|
|
94
|
+
* pnpm writes itself.
|
|
95
|
+
*/
|
|
96
|
+
export declare const PRETTIER_IGNORE_PATTERNS: string[];
|
|
97
|
+
export type { CommitMessageViolation, LintCommitMsgFileResult };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { t as editorconfig_checker_default } from "../editorconfig-checker-BKNGE7U2.mjs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import load from "@commitlint/load";
|
|
4
|
+
import lint from "@commitlint/lint";
|
|
5
|
+
// src/lint/alex-config/alex-config.ts
|
|
6
|
+
/**
|
|
7
|
+
* The org's canonical `alex` (inclusive-language) config, as raw parsed
|
|
8
|
+
* data. The one canonical copy is `alexrc.json` beside this file. A central
|
|
9
|
+
* Sentinel check (holocron#769/#793) reads it directly rather than fetching
|
|
10
|
+
* each repo's own copy via the Contents API — the same "one config, not N
|
|
11
|
+
* copies" reasoning `@theholocron/commitlint-config` already established for
|
|
12
|
+
* commit-message linting. `holocron setup` no longer writes a per-repo
|
|
13
|
+
* `.alexrc.json` or `.alexignore` (#831).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The org's canonical `alex` (inclusive-language) config as data: the words it allows, from the one JSON file
|
|
17
|
+
* `alexrc.json` beside this module.
|
|
18
|
+
*/
|
|
19
|
+
const ALEX_CONFIG = { allow: [
|
|
20
|
+
"dead",
|
|
21
|
+
"execute",
|
|
22
|
+
"execution",
|
|
23
|
+
"executes",
|
|
24
|
+
"failure",
|
|
25
|
+
"failures",
|
|
26
|
+
"hook",
|
|
27
|
+
"hooks",
|
|
28
|
+
"host-hostess",
|
|
29
|
+
"husky",
|
|
30
|
+
"period",
|
|
31
|
+
"postman-postwoman"
|
|
32
|
+
] };
|
|
33
|
+
// src/lint/alex-ignore-patterns/alex-ignore-patterns.ts
|
|
34
|
+
/**
|
|
35
|
+
* Glob-ish path patterns `alex` skips: the one copy of the list. It used to be mirrored by hand in an extensionless
|
|
36
|
+
* `alexignore` template that `holocron setup` wrote into each repo as `.alexignore`; setup no longer writes it (#831), so
|
|
37
|
+
* Sentinel's check and the Prettier ignore list read this.
|
|
38
|
+
*/
|
|
39
|
+
const ALEX_IGNORE_PATTERNS = [
|
|
40
|
+
".github/*",
|
|
41
|
+
"CHANGELOG.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
];
|
|
44
|
+
// src/lint/editorconfig-checker-exclude/editorconfig-checker-exclude.ts
|
|
45
|
+
/**
|
|
46
|
+
* The paths editorconfig-checker skips, read from the same
|
|
47
|
+
* `editorconfig-checker.json` template `holocron setup` writes as a repo's
|
|
48
|
+
* `.editorconfig-checker.json` — so Sentinel's central editorconfig check
|
|
49
|
+
* (holocron#927) excludes exactly what CI's editorconfig-checker does, from
|
|
50
|
+
* one source.
|
|
51
|
+
*
|
|
52
|
+
* The exclusion that matters most is `\.md$` / `\.mdx$`: the generated
|
|
53
|
+
* `.editorconfig` gives every file tab indentation, but
|
|
54
|
+
* `@theholocron/prettier-config` formats markdown with spaces, so a README's
|
|
55
|
+
* indented code example would fail one tool or the other. Markdown is left
|
|
56
|
+
* to prettier and markdownlint.
|
|
57
|
+
*
|
|
58
|
+
* Each entry is a regular-expression source, matched against a
|
|
59
|
+
* repo-relative path, as editorconfig-checker itself treats them.
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* The paths editorconfig-checker skips, as regular-expression sources matched against a repo-relative path; the
|
|
63
|
+
* list `holocron setup` writes into `.editorconfig-checker.json`.
|
|
64
|
+
*/
|
|
65
|
+
const EDITORCONFIG_CHECKER_EXCLUDE = editorconfig_checker_default.Exclude;
|
|
66
|
+
// src/lint/is-editorconfig-excluded/is-editorconfig-excluded.ts
|
|
67
|
+
/** `true` when `path` matches any {@link EDITORCONFIG_CHECKER_EXCLUDE} pattern. */
|
|
68
|
+
function isEditorConfigExcluded(path) {
|
|
69
|
+
return EDITORCONFIG_CHECKER_EXCLUDE.some((pattern) => new RegExp(pattern).test(path));
|
|
70
|
+
}
|
|
71
|
+
// src/lint/lint-message/lint-message.ts
|
|
72
|
+
/**
|
|
73
|
+
* Lints one commit message string against an already-loaded commitlint
|
|
74
|
+
* config. The genuinely environment-independent half of commit-message
|
|
75
|
+
* linting (holocron#789) — *obtaining* a `QualifiedConfig` differs by
|
|
76
|
+
* caller (Sentinel isolates itself from any ambient config since it runs
|
|
77
|
+
* standalone, away from a real repo checkout; `lintCommitMsgFile` below
|
|
78
|
+
* lets cosmiconfig discover the invoking repo's own
|
|
79
|
+
* `commitlint.config.*`, matching `commitlint --edit`'s own contract) —
|
|
80
|
+
* but linting one message against a loaded config is identical either way.
|
|
81
|
+
*
|
|
82
|
+
* Real `@commitlint/lint` — the same programmatic API `@commitlint/cli`
|
|
83
|
+
* itself uses internally — never a reimplementation of commitlint's rules.
|
|
84
|
+
*/
|
|
85
|
+
/** `parserPreset.parserOpts`, if the loaded config sets one — same lookup `@commitlint/cli`'s own `selectParserOpts()` does. */
|
|
86
|
+
function selectParserOpts(parserPreset) {
|
|
87
|
+
return parserPreset?.parserOpts;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Lints one commit message against an already-loaded commitlint config and returns each rule it breaks; an empty
|
|
91
|
+
* list means it is valid.
|
|
92
|
+
*/
|
|
93
|
+
async function lintCommitMessage(message, loaded) {
|
|
94
|
+
const opts = {
|
|
95
|
+
/* istanbul ignore next -- see comment above */
|
|
96
|
+
parserOpts: selectParserOpts(loaded.parserPreset) ?? {},
|
|
97
|
+
plugins: loaded.plugins,
|
|
98
|
+
/* istanbul ignore next -- see comment above */
|
|
99
|
+
ignores: loaded.ignores ?? [],
|
|
100
|
+
defaultIgnores: loaded.defaultIgnores !== false
|
|
101
|
+
};
|
|
102
|
+
const outcome = await lint(message, loaded.rules, opts);
|
|
103
|
+
if (outcome.valid) return [];
|
|
104
|
+
return outcome.errors.map((error) => ({
|
|
105
|
+
rule: error.name,
|
|
106
|
+
message: error.message
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
// src/lint/lint-commit-msg-file/lint-commit-msg-file.ts
|
|
110
|
+
/**
|
|
111
|
+
* `holocron run lint commit-msg <file>` — a real programmatic replacement for
|
|
112
|
+
* shelling out to `commitlint --edit "$1"` from `.husky/commit-msg`
|
|
113
|
+
* (holocron#789). Matches that CLI's own contract exactly: `file` is a
|
|
114
|
+
* path to the commit message being written (the arg git's `commit-msg`
|
|
115
|
+
* hook passes as `$1`), no `--config` override needed — `@commitlint/load`
|
|
116
|
+
* runs from `cwd` with no seed, so cosmiconfig's own normal upward search
|
|
117
|
+
* discovers the invoking repo's real `commitlint.config.*` file, exactly
|
|
118
|
+
* as `commitlint --edit` (no `--config` flag) already does today. Unlike
|
|
119
|
+
* Sentinel's `loadIsolatedConfig()`, no isolation is needed here — this
|
|
120
|
+
* runs inside a real repo checkout with a real `node_modules`, not
|
|
121
|
+
* standalone on a server.
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* Lints the commit message in `filePath` (what git's `commit-msg` hook passes as `$1`) against the commitlint
|
|
125
|
+
* config found by searching up from `cwd`.
|
|
126
|
+
*/
|
|
127
|
+
async function lintCommitMsgFile(filePath, cwd = process.cwd()) {
|
|
128
|
+
const violations = await lintCommitMessage(await readFile(filePath, "utf8"), await load({}, { cwd }));
|
|
129
|
+
return {
|
|
130
|
+
valid: violations.length === 0,
|
|
131
|
+
violations
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// src/lint/prettier-ignore-patterns/prettier-ignore-patterns.ts
|
|
135
|
+
/**
|
|
136
|
+
* The org's canonical prettier ignore-pattern list for a central Sentinel
|
|
137
|
+
* check (holocron#769/#819) — the `PRETTIER_CONFIG` object itself doesn't
|
|
138
|
+
* need a home here, since `@theholocron/prettier-config`'s default export
|
|
139
|
+
* already *is* one canonical, importable config (the same "one config,
|
|
140
|
+
* not N copies" reasoning `@theholocron/commitlint-config` established for
|
|
141
|
+
* commit-message linting, and `ALEX_CONFIG` established for inclusive
|
|
142
|
+
* language) — only the ignore list is a Sentinel-specific decision that
|
|
143
|
+
* belongs alongside `ALEX_IGNORE_PATTERNS`, not inside the config package.
|
|
144
|
+
*
|
|
145
|
+
* Reuses `ALEX_IGNORE_PATTERNS`' own entries (`.github/*`, `CHANGELOG.md`,
|
|
146
|
+
* `LICENSE` all independently confirmed to fail a real `prettier.check()`
|
|
147
|
+
* today — machine-generated or unparseable content, same reasoning that
|
|
148
|
+
* excluded them from alex), plus `pnpm-lock.yaml` — prettier-specific
|
|
149
|
+
* (alex never reads a lockfile, but prettier would try to reformat it):
|
|
150
|
+
* machine-written by pnpm's own writer, and not gitignored (lockfiles are
|
|
151
|
+
* tracked), so prettier picks it up by default. Reformatting it
|
|
152
|
+
* fights every subsequent `pnpm install` (this repo's own `.prettierignore`
|
|
153
|
+
* already excludes it for that exact reason).
|
|
154
|
+
*/
|
|
155
|
+
/**
|
|
156
|
+
* The paths Prettier skips in every repo: the ones inclusive-language checking skips, plus the pnpm lockfile, which
|
|
157
|
+
* pnpm writes itself.
|
|
158
|
+
*/
|
|
159
|
+
const PRETTIER_IGNORE_PATTERNS = [...ALEX_IGNORE_PATTERNS, "pnpm-lock.yaml"];
|
|
160
|
+
export { ALEX_CONFIG, ALEX_IGNORE_PATTERNS, EDITORCONFIG_CHECKER_EXCLUDE, PRETTIER_IGNORE_PATTERNS, isEditorConfigExcluded, lintCommitMessage, lintCommitMsgFile };
|