@autometa/cli 1.0.0-rc.2

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.
@@ -0,0 +1,16 @@
1
+ import type { RuntimeSummary, ScenarioStatus, SummaryContext } from "../runtime/types";
2
+ export interface FormattedReport {
3
+ readonly status: ScenarioStatus;
4
+ readonly fullName: string;
5
+ readonly durationMs?: number;
6
+ readonly error?: Error;
7
+ readonly reason?: string;
8
+ }
9
+ export declare function formatScenarioReport(report: FormattedReport): string;
10
+ export declare function formatStatusLabel(status: ScenarioStatus): string;
11
+ export declare function formatDuration(ms: number): string;
12
+ export declare function formatError(error: Error): string;
13
+ export declare function formatReason(reason: string): string;
14
+ export declare function formatSummary(summary: RuntimeSummary, context: SummaryContext): string;
15
+ export declare function formatFeatureHeader(featureName: string): string;
16
+ export declare function formatRuleHeader(ruleName: string, indent?: number): string;
@@ -0,0 +1 @@
1
+ export declare function expandFilePatterns(patterns: readonly string[] | undefined, cwd: string): Promise<string[]>;
@@ -0,0 +1,11 @@
1
+ export interface SplitHandoverResult {
2
+ readonly patterns: readonly string[];
3
+ readonly runnerArgs: readonly string[];
4
+ }
5
+ export declare function extractArgsAfterDoubleDash(rawArgv: readonly string[]): readonly string[];
6
+ export declare function stripTrailingArgs(all: readonly string[], suffix: readonly string[]): readonly string[];
7
+ export declare function splitPatternsAndRunnerArgs(options: {
8
+ readonly patterns: readonly string[];
9
+ readonly rawArgv: readonly string[];
10
+ readonly handover?: boolean;
11
+ }): SplitHandoverResult;
@@ -0,0 +1,25 @@
1
+ export interface HierarchicalLog {
2
+ write(line: string, depth?: number): void;
3
+ flush(): void;
4
+ scoped(offset: number): HierarchicalLog;
5
+ }
6
+ export interface HierarchicalLogOptions {
7
+ readonly indent?: string;
8
+ }
9
+ export declare class BufferedHierarchicalLog implements HierarchicalLog {
10
+ private readonly sink;
11
+ private readonly indent;
12
+ private readonly entries;
13
+ constructor(sink?: (line: string) => void, options?: HierarchicalLogOptions);
14
+ write(line: string, depth?: number): void;
15
+ flush(): void;
16
+ scoped(offset: number): HierarchicalLog;
17
+ }
18
+ export declare class ImmediateHierarchicalLog implements HierarchicalLog {
19
+ private readonly sink;
20
+ private readonly indent;
21
+ constructor(sink?: (line: string) => void, options?: HierarchicalLogOptions);
22
+ write(line: string, depth?: number): void;
23
+ flush(): void;
24
+ scoped(offset: number): HierarchicalLog;
25
+ }
@@ -0,0 +1,88 @@
1
+ import type { HookLogEvent } from "@autometa/executor";
2
+ import type { RuntimeSummary, ScenarioReport } from "../runtime/types";
3
+ type SuiteHierarchyKind = "feature" | "rule" | "scenarioOutline" | "examples";
4
+ export interface RunStartEvent {
5
+ readonly timestamp: number;
6
+ }
7
+ export interface SuiteLifecycleEvent {
8
+ readonly title: string;
9
+ readonly ancestors: readonly string[];
10
+ readonly path: readonly string[];
11
+ readonly kind?: SuiteHierarchyKind;
12
+ readonly keyword?: string;
13
+ }
14
+ export interface TestResultEvent {
15
+ readonly result: ScenarioReport;
16
+ }
17
+ export interface RunEndEvent {
18
+ readonly timestamp: number;
19
+ readonly summary: RuntimeSummary;
20
+ }
21
+ export interface RuntimeReporter {
22
+ onRunStart?(event: RunStartEvent): void | Promise<void>;
23
+ onSuiteStart?(event: SuiteLifecycleEvent): void | Promise<void>;
24
+ onSuiteEnd?(event: SuiteLifecycleEvent): void | Promise<void>;
25
+ onTestResult?(event: TestResultEvent): void | Promise<void>;
26
+ onHookLog?(event: HookLogEvent): void;
27
+ onRunEnd?(event: RunEndEvent): void | Promise<void>;
28
+ }
29
+ export interface HierarchicalReporterOptions {
30
+ readonly showGherkinStack?: boolean;
31
+ readonly bufferOutput?: boolean;
32
+ }
33
+ export declare class HierarchicalReporter implements RuntimeReporter {
34
+ private suiteStack;
35
+ private rootSuites;
36
+ private readonly log;
37
+ private readonly gherkinContextPrinter;
38
+ private readonly baselineErrorRenderer;
39
+ private readonly scenarioErrorRenderer;
40
+ private readonly testNodesByFullName;
41
+ private readonly suiteMetadataCache;
42
+ private suiteFailureCache;
43
+ constructor(log?: (line: string) => void, options?: HierarchicalReporterOptions);
44
+ onRunStart(): Promise<void>;
45
+ onSuiteStart(event: SuiteLifecycleEvent): Promise<void>;
46
+ onSuiteEnd(): Promise<void>;
47
+ onTestResult(event: TestResultEvent): Promise<void>;
48
+ onHookLog(event: HookLogEvent): void;
49
+ onRunEnd(): Promise<void>;
50
+ private reset;
51
+ private flush;
52
+ private printNode;
53
+ private suiteHasFailingDescendant;
54
+ private formatSuiteHeading;
55
+ private resolveSuiteKeyword;
56
+ private sanitizeSuiteName;
57
+ private defaultSuiteKeyword;
58
+ private highlightSuiteKeyword;
59
+ private ensureSuitePathByNames;
60
+ private findSuite;
61
+ private findSuiteByPath;
62
+ private getSuitePathKey;
63
+ private applyMetadataFromCache;
64
+ private updateSuiteMetadataCache;
65
+ private ensureTestNode;
66
+ private extractSuiteNames;
67
+ private toSuiteHierarchyKind;
68
+ private findScenarioSegment;
69
+ private formatHookMessage;
70
+ private getHookTargetKind;
71
+ private formatStepHookMessage;
72
+ private formatContainerHookMessage;
73
+ private extractStepText;
74
+ private sanitizeHookMessage;
75
+ private wrapPhaseLabel;
76
+ private wrapStepKeyword;
77
+ private wrapContainerKeyword;
78
+ private describeStepStatus;
79
+ private static escapeRegExp;
80
+ private resolveTargetKeyword;
81
+ private describeFallbackTarget;
82
+ private extractStepKeyword;
83
+ private findSegmentKeyword;
84
+ private cleanKeyword;
85
+ private formatDuration;
86
+ private printError;
87
+ }
88
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { GherkinErrorContext } from "@autometa/errors";
2
+ import { type HierarchicalLog } from "../logging/hierarchical-log";
3
+ export interface GherkinContextPrinterOptions {
4
+ readonly includePath?: boolean;
5
+ readonly includeCodeFrame?: boolean;
6
+ }
7
+ export declare class GherkinContextPrinter {
8
+ private readonly log;
9
+ private readonly options;
10
+ constructor(log?: HierarchicalLog, options?: GherkinContextPrinterOptions);
11
+ printContext(context: GherkinErrorContext, depth: number): void;
12
+ private printCodeFrameSection;
13
+ private buildCodeFrame;
14
+ private printGherkinPath;
15
+ private describeGherkinSegment;
16
+ private describeCodeSegment;
17
+ private describePathKey;
18
+ private describePathLabel;
19
+ }
@@ -0,0 +1,3 @@
1
+ import type { SourceLocation } from "@autometa/errors";
2
+ export declare function formatSourceLocation(location: SourceLocation): string;
3
+ export declare function relativePath(filePath: string): string;
@@ -0,0 +1,26 @@
1
+ import type { GherkinErrorContext } from "@autometa/errors";
2
+ import { GherkinContextPrinter } from "./gherkin-context-printer";
3
+ import { type HierarchicalLog } from "../logging/hierarchical-log";
4
+ type BaselineOptions = {
5
+ readonly context?: GherkinErrorContext;
6
+ readonly depth: number;
7
+ readonly messageLines: readonly string[];
8
+ readonly formattedStack: readonly string[];
9
+ readonly truncated: boolean;
10
+ };
11
+ type ScenarioOptions = BaselineOptions & {
12
+ readonly context: GherkinErrorContext;
13
+ };
14
+ export declare class BaselineErrorRenderer {
15
+ private readonly contextPrinter;
16
+ private readonly log;
17
+ constructor(contextPrinter: GherkinContextPrinter, log?: HierarchicalLog);
18
+ print(options: BaselineOptions): void;
19
+ }
20
+ export declare class ScenarioErrorRenderer {
21
+ private readonly baselineRenderer;
22
+ private readonly log;
23
+ constructor(baselineRenderer: BaselineErrorRenderer, log?: HierarchicalLog);
24
+ print(options: ScenarioOptions): void;
25
+ }
26
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare function formatStackLines(lines: readonly string[], limit: number): {
2
+ lines: string[];
3
+ truncated: boolean;
4
+ };
5
+ export declare function partitionErrorLines(lines: readonly string[]): {
6
+ messageLines: string[];
7
+ stackLines: string[];
8
+ };
@@ -0,0 +1,6 @@
1
+ import type { ScenarioStatus } from "../../runtime/types";
2
+ import type { GherkinStepSummary } from "@autometa/errors";
3
+ export declare function getScenarioStatusIcon(status: ScenarioStatus): string;
4
+ export declare function colorizeScenarioStatus(text: string, status: ScenarioStatus): string;
5
+ export declare function getStepStatusIcon(status: GherkinStepSummary["status"]): string;
6
+ export declare function colorizeStepDescription(description: string, status: GherkinStepSummary["status"]): string;
@@ -0,0 +1,5 @@
1
+ import type { GherkinStepSummary } from "@autometa/errors";
2
+ export declare function describeStepSummary(step: GherkinStepSummary): {
3
+ description: string;
4
+ location?: string;
5
+ };
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@autometa/cli",
3
+ "version": "1.0.0-rc.2",
4
+ "description": "Command-line runner for Autometa features",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "bin": {
10
+ "autometa": "dist/bin.cjs"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "exports": {
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs",
18
+ "default": "./dist/index.js",
19
+ "types": "./dist/index.d.ts"
20
+ },
21
+ "license": "MIT",
22
+ "dependencies": {
23
+ "@babel/code-frame": "^7.23.5",
24
+ "commander": "^11.1.0",
25
+ "esbuild": "^0.18.20",
26
+ "fast-glob": "^3.3.2",
27
+ "picocolors": "^1.1.1",
28
+ "source-map-support": "^0.5.21",
29
+ "@autometa/config": "1.0.0-rc.0",
30
+ "@autometa/executor": "1.0.0-rc.0",
31
+ "@autometa/http": "2.0.0-rc.0",
32
+ "@autometa/gherkin": "1.0.0-rc.0",
33
+ "@autometa/coordinator": "1.0.0-rc.0",
34
+ "@autometa/errors": "1.0.0-rc.0",
35
+ "@autometa/runner": "1.0.0-rc.0",
36
+ "@autometa/scopes": "1.0.0-rc.0",
37
+ "@autometa/test-builder": "1.0.0-rc.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^18.11.18",
41
+ "@types/source-map-support": "^0.5.10",
42
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
43
+ "@typescript-eslint/parser": "^5.54.1",
44
+ "eslint": "^8.37.0",
45
+ "eslint-config-prettier": "^8.3.0",
46
+ "picocolors": "^1.1.1",
47
+ "rimraf": "^4.1.2",
48
+ "source-map-support": "^0.5.21",
49
+ "tsup": "^7.2.0",
50
+ "typescript": "^4.9.5",
51
+ "vitest": "1.4.0",
52
+ "eslint-config-custom": "0.6.0",
53
+ "tsconfig": "0.7.0",
54
+ "tsup-config": "0.1.0"
55
+ },
56
+ "scripts": {
57
+ "type-check": "tsc --noEmit -p tsconfig.dev.json",
58
+ "type-check:watch": "tsc --noEmit --watch -p tsconfig.dev.json",
59
+ "build": "tsup && pnpm run build:types",
60
+ "build:types": "rimraf tsconfig.types.tsbuildinfo && tsc --build tsconfig.types.json",
61
+ "build:watch": "tsup --watch",
62
+ "dev": "tsup --watch",
63
+ "test": "vitest run --passWithNoTests",
64
+ "test:watch": "vitest --passWithNoTests",
65
+ "test:ui": "vitest --ui --passWithNoTests",
66
+ "coverage": "vitest run --coverage --passWithNoTests",
67
+ "lint": "eslint . --max-warnings 0",
68
+ "lint:fix": "eslint . --fix",
69
+ "prettify": "prettier --config .prettierrc 'src/**/*.ts' --write",
70
+ "clean": "rimraf dist"
71
+ }
72
+ }