@boringparts/verule 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/dist/additional-inputs.d.ts +13 -0
- package/dist/additional-inputs.js +68 -0
- package/dist/cli-command-identity.d.ts +13 -0
- package/dist/cli-command-identity.js +15 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +42 -0
- package/dist/config-loader.d.ts +14 -0
- package/dist/config-loader.js +203 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/inline-ignore.d.ts +44 -0
- package/dist/inline-ignore.js +297 -0
- package/dist/main.d.ts +12381 -0
- package/dist/main.js +531 -0
- package/dist/observation.d.ts +93 -0
- package/dist/observation.js +703 -0
- package/dist/projects.d.ts +21 -0
- package/dist/projects.js +171 -0
- package/dist/report-wire.d.ts +1260 -0
- package/dist/report-wire.js +629 -0
- package/dist/session-command.d.ts +48 -0
- package/dist/session-command.js +71 -0
- package/dist/session.d.ts +15 -0
- package/dist/session.js +677 -0
- package/dist/shared-session.d.ts +13 -0
- package/dist/shared-session.js +333 -0
- package/dist/types.d.ts +307 -0
- package/dist/types.js +43 -0
- package/dist/watch-command.d.ts +664 -0
- package/dist/watch-command.js +99 -0
- package/dist/watch.d.ts +57 -0
- package/dist/watch.js +792 -0
- package/package.json +57 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 tssae
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type AdditionalInputEntry, type AdditionalInputRegistrar, type AdditionalInputRegistry, type AdditionalInputSource, type ScopedAdditionalInputRegistrar } from "tssae";
|
|
2
|
+
export type { AdditionalInputEntry, AdditionalInputRegistrar, AdditionalInputRegistry, AdditionalInputSource, ScopedAdditionalInputRegistrar, };
|
|
3
|
+
/** Validates config-level `additionalInputs` paths without performing filesystem I/O. */
|
|
4
|
+
export declare function validateAdditionalInputPaths(paths: readonly string[] | undefined): readonly string[];
|
|
5
|
+
/**
|
|
6
|
+
* Wraps `tssae`'s `createAdditionalInputRegistry` so registry validation and read
|
|
7
|
+
* errors surface as `VeruleExecutionError` matching Verule's error contract.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createAdditionalInputRegistry(options: {
|
|
10
|
+
readonly cwd: string;
|
|
11
|
+
}): AdditionalInputRegistry;
|
|
12
|
+
/** Binds an `AdditionalInputRegistrar` to a fixed rule or summary source tag. */
|
|
13
|
+
export declare function createScopedAdditionalInputRegistrar(registrar: AdditionalInputRegistrar, source: AdditionalInputSource): ScopedAdditionalInputRegistrar;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createAdditionalInputRegistry as createTssaeAdditionalInputRegistry, createScopedAdditionalInputRegistrar as createTssaeScopedAdditionalInputRegistrar, } from "tssae";
|
|
2
|
+
import { VeruleExecutionError, toVeruleError } from "./types.js";
|
|
3
|
+
/** Validates config-level `additionalInputs` paths without performing filesystem I/O. */
|
|
4
|
+
export function validateAdditionalInputPaths(paths) {
|
|
5
|
+
if (paths === undefined) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
const validated = [];
|
|
9
|
+
for (const rawPath of paths) {
|
|
10
|
+
if (typeof rawPath !== "string" || rawPath.trim() === "") {
|
|
11
|
+
throw new VeruleExecutionError("INVALID_CONFIG", "Additional input path must be a non-empty string.");
|
|
12
|
+
}
|
|
13
|
+
validated.push(rawPath);
|
|
14
|
+
}
|
|
15
|
+
return validated;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wraps `tssae`'s `createAdditionalInputRegistry` so registry validation and read
|
|
19
|
+
* errors surface as `VeruleExecutionError` matching Verule's error contract.
|
|
20
|
+
*/
|
|
21
|
+
export function createAdditionalInputRegistry(options) {
|
|
22
|
+
const inner = createTssaeAdditionalInputRegistry(options);
|
|
23
|
+
return {
|
|
24
|
+
cwd: inner.cwd,
|
|
25
|
+
registerAdditionalInput(filePath, source) {
|
|
26
|
+
try {
|
|
27
|
+
return inner.registerAdditionalInput(filePath, source);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
throw toVeruleError(err, "INVALID_CONFIG");
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
readAdditionalInput(filePath, source) {
|
|
34
|
+
try {
|
|
35
|
+
return inner.readAdditionalInput(filePath, source);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
const mapped = toVeruleError(err, "RULE_EXECUTION_ERROR");
|
|
39
|
+
if (mapped.message.startsWith("Failed to read additional input ")) {
|
|
40
|
+
throw new VeruleExecutionError("RULE_EXECUTION_ERROR", mapped.message, {
|
|
41
|
+
cause: err,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
throw mapped;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
listAdditionalInputs: () => inner.listAdditionalInputs(),
|
|
48
|
+
getTrackedAbsolutePaths: () => inner.getTrackedAbsolutePaths(),
|
|
49
|
+
refresh: () => inner.refresh(),
|
|
50
|
+
resolveAbsolutePath(filePath) {
|
|
51
|
+
try {
|
|
52
|
+
return inner.resolveAbsolutePath(filePath);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
throw toVeruleError(err, "INVALID_CONFIG");
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Binds an `AdditionalInputRegistrar` to a fixed rule or summary source tag. */
|
|
61
|
+
export function createScopedAdditionalInputRegistrar(registrar, source) {
|
|
62
|
+
try {
|
|
63
|
+
return createTssaeScopedAdditionalInputRegistrar(registrar, source);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
throw toVeruleError(err, "INVALID_CONFIG");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type CliCommandIdentity = {
|
|
2
|
+
readonly commandName: string;
|
|
3
|
+
readonly version: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the single executable command name and display version from a CLI package manifest.
|
|
7
|
+
*
|
|
8
|
+
* Throws if `bin` does not declare exactly one command; defaults missing `version` to `"unpublished"`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function cliCommandIdentity(manifest: {
|
|
11
|
+
readonly bin: Readonly<Record<string, string>>;
|
|
12
|
+
readonly version?: string;
|
|
13
|
+
}): CliCommandIdentity;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the single executable command name and display version from a CLI package manifest.
|
|
3
|
+
*
|
|
4
|
+
* Throws if `bin` does not declare exactly one command; defaults missing `version` to `"unpublished"`.
|
|
5
|
+
*/
|
|
6
|
+
export function cliCommandIdentity(manifest) {
|
|
7
|
+
const names = Object.keys(manifest.bin);
|
|
8
|
+
if (names.length !== 1) {
|
|
9
|
+
throw new Error("CLI package must declare exactly one command in bin.");
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
commandName: names[0],
|
|
13
|
+
version: manifest.version ?? "unpublished",
|
|
14
|
+
};
|
|
15
|
+
}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fstatSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { nodeCliOutput } from "@boringparts/cli-contract/node";
|
|
5
|
+
import { cliCommandIdentity } from "./cli-command-identity.js";
|
|
6
|
+
import { runCli } from "./main.js";
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const shutdownController = new AbortController();
|
|
9
|
+
const abortShutdown = () => shutdownController.abort();
|
|
10
|
+
process.on("SIGINT", abortShutdown);
|
|
11
|
+
process.on("SIGTERM", abortShutdown);
|
|
12
|
+
let watchStdin = false;
|
|
13
|
+
try {
|
|
14
|
+
const stdinStat = fstatSync(0);
|
|
15
|
+
watchStdin = stdinStat.isFIFO() || stdinStat.isSocket();
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
watchStdin = false;
|
|
19
|
+
}
|
|
20
|
+
if (watchStdin) {
|
|
21
|
+
process.stdin.once("end", abortShutdown);
|
|
22
|
+
process.stdin.resume();
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
process.exitCode = await runCli({
|
|
26
|
+
argv: process.argv,
|
|
27
|
+
signal: shutdownController.signal,
|
|
28
|
+
write: nodeCliOutput({ stdout: process.stdout, stderr: process.stderr }),
|
|
29
|
+
// Keep manifest reading and identity validation inside runCli's unexpected-failure boundary.
|
|
30
|
+
get identity() {
|
|
31
|
+
return cliCommandIdentity(require("../package.json"));
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
process.off("SIGINT", abortShutdown);
|
|
37
|
+
process.off("SIGTERM", abortShutdown);
|
|
38
|
+
if (watchStdin) {
|
|
39
|
+
process.stdin.off("end", abortShutdown);
|
|
40
|
+
process.stdin.pause();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type NormalizedVeruleConfig } from "./index.ts";
|
|
2
|
+
export type LoadedProjectConfig = {
|
|
3
|
+
readonly configPath: string;
|
|
4
|
+
readonly config: NormalizedVeruleConfig;
|
|
5
|
+
readonly watchFiles: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function resolveConfigPath(cwd: string, explicitConfig?: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Dynamically imports a Verule configuration file with ESM cache-busting for the config
|
|
10
|
+
* and its local relative module graph, returning the validated config and dependency paths.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadProjectConfigWithDependencies(cwd: string, explicitConfig?: string): Promise<LoadedProjectConfig>;
|
|
13
|
+
/** Dynamically imports and validates a project configuration file. */
|
|
14
|
+
export declare function loadProjectConfig(cwd: string, explicitConfig?: string): Promise<NormalizedVeruleConfig>;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
10
|
+
import { registerHooks } from "node:module";
|
|
11
|
+
import { resolve } from "node:path";
|
|
12
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
13
|
+
import { VeruleExecutionError, defineConfig, } from "./index.js";
|
|
14
|
+
const DEFAULT_CONFIG_CANDIDATES = [
|
|
15
|
+
"verule.config.ts",
|
|
16
|
+
"verule.config.mts",
|
|
17
|
+
"verule.config.mjs",
|
|
18
|
+
"verule.config.js",
|
|
19
|
+
];
|
|
20
|
+
// Property-typed view avoids `unbound-method` while preserving the exact function
|
|
21
|
+
// reference for restoration (whereas `.bind(process)` would allocate a wrapper).
|
|
22
|
+
const processEmitWarningHost = process;
|
|
23
|
+
let nextReloadGeneration = 1;
|
|
24
|
+
let activeConfigImports = 0;
|
|
25
|
+
let savedEmitWarning;
|
|
26
|
+
function isTypeStrippingWarning(warning, typeOrOptions) {
|
|
27
|
+
const warningName = typeof typeOrOptions === "string"
|
|
28
|
+
? typeOrOptions
|
|
29
|
+
: typeof typeOrOptions === "object" &&
|
|
30
|
+
typeOrOptions !== null &&
|
|
31
|
+
"type" in typeOrOptions
|
|
32
|
+
? typeOrOptions.type
|
|
33
|
+
: typeof warning === "object"
|
|
34
|
+
? warning.name
|
|
35
|
+
: undefined;
|
|
36
|
+
const warningMessage = typeof warning === "string" ? warning : warning.message;
|
|
37
|
+
return (warningName === "ExperimentalWarning" &&
|
|
38
|
+
warningMessage.includes("Type Stripping"));
|
|
39
|
+
}
|
|
40
|
+
// Node 24.0.0 emits `ExperimentalWarning: Type Stripping` to stderr on the first
|
|
41
|
+
// `.ts` import, which corrupts CLI JSON envelopes and NDJSON streams. We suppress
|
|
42
|
+
// only that warning across dynamic config imports using an active-import refcount
|
|
43
|
+
// so overlapping loads share one hook and restore the exact original handler on exit.
|
|
44
|
+
const suppressTypeStrippingWarning = function (warning, ...args) {
|
|
45
|
+
if (isTypeStrippingWarning(warning, args[0])) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (savedEmitWarning !== undefined) {
|
|
49
|
+
Reflect.apply(savedEmitWarning, process, [warning, ...args]);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export function resolveConfigPath(cwd, explicitConfig) {
|
|
53
|
+
if (explicitConfig !== undefined) {
|
|
54
|
+
const resolved = resolve(cwd, explicitConfig);
|
|
55
|
+
if (!existsSync(resolved)) {
|
|
56
|
+
throw new VeruleExecutionError("INVALID_CONFIG", `Configuration file not found: ${resolved}`);
|
|
57
|
+
}
|
|
58
|
+
return resolved;
|
|
59
|
+
}
|
|
60
|
+
for (const candidate of DEFAULT_CONFIG_CANDIDATES) {
|
|
61
|
+
const resolved = resolve(cwd, candidate);
|
|
62
|
+
if (existsSync(resolved)) {
|
|
63
|
+
return resolved;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
throw new VeruleExecutionError("INVALID_CONFIG", `No Verule configuration file found in ${cwd}.`);
|
|
67
|
+
}
|
|
68
|
+
function isLocalImportSpecifier(specifier) {
|
|
69
|
+
return (specifier.startsWith("./") ||
|
|
70
|
+
specifier.startsWith("../") ||
|
|
71
|
+
specifier.startsWith("/") ||
|
|
72
|
+
specifier.startsWith("file://"));
|
|
73
|
+
}
|
|
74
|
+
function hasPreserveSymlinksFlag() {
|
|
75
|
+
if (process.execArgv.includes("--preserve-symlinks")) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
const nodeOptions = process.env.NODE_OPTIONS?.trim();
|
|
79
|
+
if (!nodeOptions) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return nodeOptions.split(/\s+/u).includes("--preserve-symlinks");
|
|
83
|
+
}
|
|
84
|
+
function stripUrlQuery(url) {
|
|
85
|
+
const queryIndex = url.indexOf("?");
|
|
86
|
+
return queryIndex === -1
|
|
87
|
+
? { baseUrl: url, query: "" }
|
|
88
|
+
: { baseUrl: url.slice(0, queryIndex), query: url.slice(queryIndex) };
|
|
89
|
+
}
|
|
90
|
+
function trackNonNodeModulesFileUrl(trackedFiles, fileUrl, requireExisting = false) {
|
|
91
|
+
if (!fileUrl.startsWith("file://") || fileUrl.includes("/node_modules/")) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const filePath = fileURLToPath(fileUrl);
|
|
96
|
+
if (!requireExisting || existsSync(filePath)) {
|
|
97
|
+
trackedFiles.add(filePath);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Ignore non-file paths.
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Dynamically imports a Verule configuration file with ESM cache-busting for the config
|
|
106
|
+
* and its local relative module graph, returning the validated config and dependency paths.
|
|
107
|
+
*/
|
|
108
|
+
export async function loadProjectConfigWithDependencies(cwd, explicitConfig) {
|
|
109
|
+
const configPath = resolveConfigPath(cwd, explicitConfig);
|
|
110
|
+
const configUrl = pathToFileURL(configPath).href;
|
|
111
|
+
const reloadToken = String(nextReloadGeneration++);
|
|
112
|
+
const reloadMarker = `verule-reload=${reloadToken}`;
|
|
113
|
+
const trackedFiles = new Set([configPath]);
|
|
114
|
+
const preserveSymlinks = hasPreserveSymlinksFlag();
|
|
115
|
+
const hook = registerHooks({
|
|
116
|
+
resolve(specifier, context, nextResolve) {
|
|
117
|
+
const resolved = nextResolve(specifier, context);
|
|
118
|
+
if (!resolved.url.startsWith("file://")) {
|
|
119
|
+
return resolved;
|
|
120
|
+
}
|
|
121
|
+
const { baseUrl: rawUrl, query: existingQuery } = stripUrlQuery(resolved.url);
|
|
122
|
+
// In Node 24.0.0, `nextResolve` from a symlinked `cli.js` entry can return
|
|
123
|
+
// an unresolved symlink path, preventing pnpm's isolated `node_modules` from
|
|
124
|
+
// resolving transitive dependencies such as `tssae`. Canonicalize `file://`
|
|
125
|
+
// URLs via `realpathSync` unless `--preserve-symlinks` is explicitly active.
|
|
126
|
+
let canonicalUrl = rawUrl;
|
|
127
|
+
if (!preserveSymlinks) {
|
|
128
|
+
try {
|
|
129
|
+
canonicalUrl = pathToFileURL(realpathSync(fileURLToPath(rawUrl))).href;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// Keep original URL if the target cannot be realpathed.
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const fromReloadedGraph = typeof context.parentURL === "string" &&
|
|
136
|
+
context.parentURL.includes(reloadMarker);
|
|
137
|
+
if (fromReloadedGraph && isLocalImportSpecifier(specifier)) {
|
|
138
|
+
// Track both the unresolved local path (for symlink retargeting) and
|
|
139
|
+
// canonical realpath (for target edits) outside `node_modules` so
|
|
140
|
+
// `verule watch` reloads on either change.
|
|
141
|
+
try {
|
|
142
|
+
const { baseUrl: unresolvedUrl } = stripUrlQuery(new URL(specifier, context.parentURL).href);
|
|
143
|
+
trackNonNodeModulesFileUrl(trackedFiles, unresolvedUrl, true);
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// Ignore malformed specifiers.
|
|
147
|
+
}
|
|
148
|
+
trackNonNodeModulesFileUrl(trackedFiles, rawUrl);
|
|
149
|
+
if (!canonicalUrl.includes("/node_modules/")) {
|
|
150
|
+
trackNonNodeModulesFileUrl(trackedFiles, canonicalUrl);
|
|
151
|
+
return {
|
|
152
|
+
...resolved,
|
|
153
|
+
url: `${canonicalUrl}?${reloadMarker}`,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const restoredUrl = `${canonicalUrl}${existingQuery}`;
|
|
158
|
+
return restoredUrl === resolved.url
|
|
159
|
+
? resolved
|
|
160
|
+
: { ...resolved, url: restoredUrl };
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
let loaded;
|
|
164
|
+
if (activeConfigImports === 0) {
|
|
165
|
+
savedEmitWarning = processEmitWarningHost.emitWarning;
|
|
166
|
+
processEmitWarningHost.emitWarning = suppressTypeStrippingWarning;
|
|
167
|
+
}
|
|
168
|
+
activeConfigImports += 1;
|
|
169
|
+
try {
|
|
170
|
+
loaded = await import(__rewriteRelativeImportExtension(`${configUrl}?${reloadMarker}`));
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
174
|
+
throw new VeruleExecutionError("INVALID_CONFIG", `Failed to load Verule configuration "${configPath}": ${message}`, { cause: err });
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
activeConfigImports -= 1;
|
|
178
|
+
if (activeConfigImports === 0 &&
|
|
179
|
+
savedEmitWarning !== undefined &&
|
|
180
|
+
processEmitWarningHost.emitWarning === suppressTypeStrippingWarning) {
|
|
181
|
+
processEmitWarningHost.emitWarning = savedEmitWarning;
|
|
182
|
+
savedEmitWarning = undefined;
|
|
183
|
+
}
|
|
184
|
+
hook.deregister();
|
|
185
|
+
}
|
|
186
|
+
if (typeof loaded !== "object" || loaded === null || !("default" in loaded)) {
|
|
187
|
+
throw new VeruleExecutionError("INVALID_CONFIG", `Verule configuration "${configPath}" must export a default configuration object.`);
|
|
188
|
+
}
|
|
189
|
+
const rawDefault = loaded.default;
|
|
190
|
+
if (typeof rawDefault !== "object" || rawDefault === null) {
|
|
191
|
+
throw new VeruleExecutionError("INVALID_CONFIG", `Default export of "${configPath}" must be a configuration object.`);
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
configPath,
|
|
195
|
+
config: defineConfig(rawDefault),
|
|
196
|
+
watchFiles: [...trackedFiles],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** Dynamically imports and validates a project configuration file. */
|
|
200
|
+
export async function loadProjectConfig(cwd, explicitConfig) {
|
|
201
|
+
const loaded = await loadProjectConfigWithDependencies(cwd, explicitConfig);
|
|
202
|
+
return loaded.config;
|
|
203
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createAdditionalInputRegistry, createScopedAdditionalInputRegistrar, type AdditionalInputEntry, type AdditionalInputRegistrar, type AdditionalInputRegistry, type AdditionalInputSource, type ScopedAdditionalInputRegistrar, } from "./additional-inputs.ts";
|
|
2
|
+
export { INLINE_IGNORE_RULE_ID } from "./inline-ignore.ts";
|
|
3
|
+
export { parseObserveLimit, parseTargetSpec } from "./observation.ts";
|
|
4
|
+
export { defineConfig, defineRule, openSession, runCheck } from "./session.ts";
|
|
5
|
+
export { requestSharedReport, startSharedSession } from "./shared-session.ts";
|
|
6
|
+
export { watchProject } from "./watch.ts";
|
|
7
|
+
export { dedupeEvidence, evidenceOf, extractBasisEvidence, getEngineVersion, isSameInstance, normalizeEvidence, normalizeEvidenceItem, normalizeLocation, registerProvenance, resolveRetainedObjectFields, syntaxLocationOf, type AssignabilityPair, type AssignabilityResult, type BranchBypassPath, type BranchCoverageItem, type BranchCoverageOptions, type BranchCoverageStatus, type BranchDirection, type BranchEdgeInfo, type BranchKind, type BranchRef, type CallEffectsOptions, type CallEffectsResult, type CallEffectsTargetRef, type CallbackInvocationInfo, type CallProjectionSelection, type CallRef, type CallSiteParameterBinding, type CallTargetInfo, type CallTargetsResult, type CleanupCoverageStatus, type CleanupScopeRef, type CleanupSiteInfo, type CompilerOptionsSummary, type ControlFlowPathStep, type DeclarationCallersResult, type DeclarationProjectionSelection, type DeclarationRef, type DiagnosticBasis, type DiagnosticLocation, type DirectCallInfo, type EngineCallIoMetrics, type EngineIrCacheMetrics, type EngineLoweringMetrics, type EngineRpcMetrics, type EngineStepMetrics, type EngineSummaryLookupMetrics, type Evidence, type ExplainCleanupPath, type FieldEffect, type FieldEffectKind, type FieldWriteOperator, type FindSyntaxOptions, type FirstPartyResolutionSource, type FullCallProjectionFields, type FullDeclarationProjectionFields, type FullInstanceProjectionFields, type FullSignatureProjectionFields, type FullSyntaxLookupFields, type FullTypeProjectionFields, type FunctionBranchesResult, type Gap, type GuardConditionInfo, type ImplementationResolutionResult, type ImplementationTargetRef, type ImplicitExceptionCleanupOutcome, type ImplicitExceptionCoverageOutcome, type InstanceCleanupOptions, type InstanceCleanupScopeResult, type InstanceOriginKind, type InstanceProjectionSelection, type InstanceRef, type InstanceResolutionResult, type InstanceTargetRef, type InstantiatedParameterType, type LookupFilesOptions, type MemoryStats, type ObjectFieldShape, type ObserveLimit, type ObserveLimitInput, type ObserveMode, type ObserveOptions, type ProgramObjectKind, type ProgramRef, type ProjectedCallResolutionRow, type ProjectedCallRow, type ProjectedDeclarationRow, type ProjectedInstanceRow, type ProjectedSignatureRow, type ProjectedSyntaxLookupRow, type ProjectedTypeRow, type ProjectSummary, type ProvenanceCarrier, type RecomputationScope, type ResolvedImplementationTarget, type ResolvedInstanceInfo, type RetainedObjectFields, type SelectableQueryResult, type SelectedKeys, type SignatureParameterInfo, type SignatureProjectionSelection, type SignatureRef, type SourceFileOrigin, type SourceFileProjectOrigin, type SourceRange, type SourceTarget, type SummaryConflictDetails, type SummaryConflictParty, type SummaryDiscoverySource, type SyntaxKind, type SyntaxLookupSelection, type SyntaxNodeResult, type SyntaxRef, type TargetInstanceCleanupResult, type TypeAtResult, type TypeProjectionSelection, type TypePropertyInfo, type TypeRef, type TypeSummary, type ValueEndpoint, type ValuePropagationMode, type ValuePropagationOptions, type ValuePropagationPath, type ValuePropagationResult, type ValuePropagationStep, type ValuePropagationStepKind, type ValuePropagationTargetResult, } from "tssae";
|
|
8
|
+
export { REPORT_SCHEMA_VERSION, VeruleExecutionError, type AnalysisSession, type CheckReport, type CheckpointOutcome, type CheckpointTarget, type Diagnostic, type DiagnosticInput, type ExplainCheckpointTrace, type ExplainQueryStep, type ExplainReport, type ExplainResult, type ExplainStatus, type InlineIgnoreEntry, type InlineIgnoreStatus, type NormalizedVeruleConfig, type ObservationDetailEntry, type ObservationOverhead, type ObservationPhases, type ObservationReport, type ObservationRpcMetrics, type OpenSessionOptions, type ReportIdentity, type RequestSharedReportOptions, type Rule, type RuleContext, type RuleIdentitySummary, type RunCheckOptions, type SessionCheckOptions, type SessionUpdateOptions, type SessionUpdateResult, type SharedSession, type SharedSessionOptions, type VeruleConfig, type VeruleErrorCode, type WatchConfigLoadResult, type WatchEvent, type WatchFailureEvent, type WatchProjectOptions, type WatchReportEvent, type WatchTrigger, } from "./types.ts";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createAdditionalInputRegistry, createScopedAdditionalInputRegistrar, } from "./additional-inputs.js";
|
|
2
|
+
export { INLINE_IGNORE_RULE_ID } from "./inline-ignore.js";
|
|
3
|
+
export { parseObserveLimit, parseTargetSpec } from "./observation.js";
|
|
4
|
+
export { defineConfig, defineRule, openSession, runCheck } from "./session.js";
|
|
5
|
+
export { requestSharedReport, startSharedSession } from "./shared-session.js";
|
|
6
|
+
export { watchProject } from "./watch.js";
|
|
7
|
+
export { dedupeEvidence, evidenceOf, extractBasisEvidence, getEngineVersion, isSameInstance, normalizeEvidence, normalizeEvidenceItem, normalizeLocation, registerProvenance, resolveRetainedObjectFields, syntaxLocationOf, } from "tssae";
|
|
8
|
+
export { REPORT_SCHEMA_VERSION, VeruleExecutionError, } from "./types.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type DiagnosticLocation, type ProjectSummary, type ScannedComment } from "tssae";
|
|
2
|
+
import type { CollectedDiagnostic } from "./projects.ts";
|
|
3
|
+
import type { InlineIgnoreEntry } from "./types.ts";
|
|
4
|
+
export declare const INLINE_IGNORE_RULE_ID: "verule/inline-ignore";
|
|
5
|
+
export type ParsedDirectiveItem = {
|
|
6
|
+
readonly kind: "valid";
|
|
7
|
+
readonly ruleId: string;
|
|
8
|
+
readonly reason: string;
|
|
9
|
+
readonly at: DiagnosticLocation;
|
|
10
|
+
readonly targetLine: number | null;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "malformed";
|
|
13
|
+
readonly message: string;
|
|
14
|
+
readonly at: DiagnosticLocation;
|
|
15
|
+
};
|
|
16
|
+
/** Parses one `verule-ignore-next-code-line` directive from a TSSAE standalone comment. */
|
|
17
|
+
export declare function parseDirectiveFromComment(comment: ScannedComment): ParsedDirectiveItem | undefined;
|
|
18
|
+
/** Filters and parses all Verule inline ignore directives from scanned snapshot comments. */
|
|
19
|
+
export declare function parseInlineIgnoreDirectives(comments: readonly ScannedComment[]): readonly ParsedDirectiveItem[];
|
|
20
|
+
export type InlineIgnoreSuppression = {
|
|
21
|
+
readonly ruleId: string;
|
|
22
|
+
readonly at: DiagnosticLocation;
|
|
23
|
+
readonly directiveAt: DiagnosticLocation;
|
|
24
|
+
readonly reason: string;
|
|
25
|
+
};
|
|
26
|
+
export type InlineIgnoreSettlement = {
|
|
27
|
+
readonly diagnostics: readonly CollectedDiagnostic[];
|
|
28
|
+
readonly suppressions: readonly InlineIgnoreSuppression[];
|
|
29
|
+
readonly entries: readonly InlineIgnoreEntry[];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Resolves `verule-ignore-next-code-line` directives against collected rule diagnostics.
|
|
33
|
+
*
|
|
34
|
+
* Rules run normally and keep all gaps and evidence; suppression only hides diagnostics whose
|
|
35
|
+
* `(ruleId, file, start, end)` primary location uniquely matches the target code line.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveInlineIgnores(params: {
|
|
38
|
+
readonly directives: readonly ParsedDirectiveItem[];
|
|
39
|
+
readonly collected: readonly CollectedDiagnostic[];
|
|
40
|
+
readonly projects: readonly ProjectSummary[];
|
|
41
|
+
readonly configuredRuleIds: ReadonlySet<string>;
|
|
42
|
+
readonly executedRuleIds: ReadonlySet<string>;
|
|
43
|
+
readonly isPartialRuleSelection: boolean;
|
|
44
|
+
}): InlineIgnoreSettlement;
|