@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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { text } from "@boringparts/cli-contract";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { loadProjectConfigWithDependencies } from "./config-loader.js";
|
|
5
|
+
import { REPORT_SCHEMA_VERSION, VeruleExecutionError, startSharedSession, } from "./index.js";
|
|
6
|
+
import { projectSummarySchema, toWireProjects } from "./report-wire.js";
|
|
7
|
+
export const sessionReadyRecordSchema = z.object({
|
|
8
|
+
reportVersion: z.literal(REPORT_SCHEMA_VERSION),
|
|
9
|
+
endpoint: z.string(),
|
|
10
|
+
snapshotId: z.number().int().positive(),
|
|
11
|
+
projects: z.array(projectSummarySchema),
|
|
12
|
+
});
|
|
13
|
+
export function formatSessionReadyText(record) {
|
|
14
|
+
return text.line(`Shared session ready at ${record.endpoint} (snapshot #${record.snapshotId}, ${record.projects.length} project(s)).`);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Starts a long-lived shared session bound to a single project configuration, emits
|
|
18
|
+
* a ready notification, serves cross-process `verule check --session` queries, and cleans
|
|
19
|
+
* up the socket endpoint and engine subprocess on shutdown.
|
|
20
|
+
*/
|
|
21
|
+
export async function* streamSharedSession(workingDirectory, configOption, socketOption, signal, outcome) {
|
|
22
|
+
let sharedSession;
|
|
23
|
+
try {
|
|
24
|
+
const initial = await loadProjectConfigWithDependencies(workingDirectory, configOption);
|
|
25
|
+
const watchFiles = new Set(initial.watchFiles);
|
|
26
|
+
if (configOption !== undefined) {
|
|
27
|
+
watchFiles.add(resolve(workingDirectory, configOption));
|
|
28
|
+
}
|
|
29
|
+
sharedSession = await startSharedSession({
|
|
30
|
+
cwd: workingDirectory,
|
|
31
|
+
endpoint: socketOption,
|
|
32
|
+
config: initial.config,
|
|
33
|
+
watchFiles: [...watchFiles],
|
|
34
|
+
...(signal !== undefined ? { signal } : {}),
|
|
35
|
+
loadConfig: async () => {
|
|
36
|
+
const loaded = await loadProjectConfigWithDependencies(workingDirectory, configOption);
|
|
37
|
+
return {
|
|
38
|
+
config: loaded.config,
|
|
39
|
+
watchFiles: loaded.watchFiles,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
const failure = err instanceof VeruleExecutionError
|
|
46
|
+
? {
|
|
47
|
+
reportVersion: REPORT_SCHEMA_VERSION,
|
|
48
|
+
code: err.code,
|
|
49
|
+
message: err.message,
|
|
50
|
+
}
|
|
51
|
+
: {
|
|
52
|
+
reportVersion: REPORT_SCHEMA_VERSION,
|
|
53
|
+
code: "ENGINE_ERROR",
|
|
54
|
+
message: err instanceof Error ? err.message : String(err),
|
|
55
|
+
};
|
|
56
|
+
return outcome.failure.failed(failure);
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
yield outcome.record.ready({
|
|
60
|
+
reportVersion: REPORT_SCHEMA_VERSION,
|
|
61
|
+
endpoint: sharedSession.endpoint,
|
|
62
|
+
snapshotId: sharedSession.snapshotId,
|
|
63
|
+
projects: toWireProjects(sharedSession.projects),
|
|
64
|
+
});
|
|
65
|
+
await sharedSession.waitUntilClosed();
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
await sharedSession.close();
|
|
69
|
+
}
|
|
70
|
+
return outcome.streamSuccess();
|
|
71
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AnalysisSession, type CheckReport, type NormalizedVeruleConfig, type OpenSessionOptions, type Rule, type RunCheckOptions, type VeruleConfig } from "./types.ts";
|
|
2
|
+
/** Returns all workspace source file paths tracked by the active session for file watching. */
|
|
3
|
+
export declare function getSessionWorkspaceFiles(session: AnalysisSession): readonly string[];
|
|
4
|
+
/** Validates and normalizes a rule definition. */
|
|
5
|
+
export declare function defineRule(rule: Rule): Rule;
|
|
6
|
+
/** Validates and normalizes a Verule project configuration, defaulting to zero rules. */
|
|
7
|
+
export declare function defineConfig(config: VeruleConfig | NormalizedVeruleConfig): NormalizedVeruleConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Opens an analysis session backed by a single TSSAE `ProjectSession`.
|
|
10
|
+
*
|
|
11
|
+
* Call `session.close()` when finished to release the snapshot and terminate the engine process.
|
|
12
|
+
*/
|
|
13
|
+
export declare function openSession(options: OpenSessionOptions): Promise<AnalysisSession>;
|
|
14
|
+
/** Runs a one-shot check in a dedicated analysis session and releases resources before returning. */
|
|
15
|
+
export declare function runCheck(options: RunCheckOptions): Promise<CheckReport>;
|