repo-contract 0.6.0 → 0.7.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/CHANGELOG.md +18 -0
- package/dist/.dts/errors.d.ts +1 -13
- package/dist/.dts/errors.d.ts.map +1 -1
- package/dist/.dts/index.d.ts +1 -1
- package/dist/.dts/index.d.ts.map +1 -1
- package/dist/.dts/parsing/parse-output.d.ts +10 -13
- package/dist/.dts/parsing/parse-output.d.ts.map +1 -1
- package/dist/.dts/types.d.ts +10 -3
- package/dist/.dts/types.d.ts.map +1 -1
- package/dist/index.cjs +4 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -9
- package/schemas/evidence.schema.json +2 -3
- package/src/config/validate-config.ts +1 -1
- package/src/errors.ts +2 -29
- package/src/evidence/build-evidence.ts +6 -6
- package/src/index.ts +0 -1
- package/src/parsing/parse-output.ts +12 -23
- package/src/types.ts +10 -3
- package/dist/.dts/parsing/parse-yaml.d.ts +0 -21
- package/dist/.dts/parsing/parse-yaml.d.ts.map +0 -1
- package/src/parsing/parse-yaml.ts +0 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.7.0](https://github.com/MaverickCER/repo-contract/compare/repo-contract-v0.6.0...repo-contract-v0.7.0) (2026-09-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* OutputFormat no longer includes "yaml", and ParserDependencyMissingError (thrown only for a missing "yaml" peer dependency) is removed from the public API. A config using output.format: "yaml" will now fail config validation.
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* drop first-class YAML output-format support ([99f7b6d](https://github.com/MaverickCER/repo-contract/commit/99f7b6db13ef60e159b2eb589317fdf0e99f0726))
|
|
13
|
+
* **security-socket:** reject supplyChainRisk alerts on shipped dependencies outright ([bf7f2b3](https://github.com/MaverickCER/repo-contract/commit/bf7f2b32ed47c496aea4877b20adb474592b85ad))
|
|
14
|
+
* **security-socket:** reject supplyChainRisk alerts on shipped dependencies outright ([d0a0563](https://github.com/MaverickCER/repo-contract/commit/d0a0563eb7f783577333291e94383408bb9e8c53))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **security-socket:** peerDependencies also count as shipped for supplyChainRisk ([e5db3cd](https://github.com/MaverickCER/repo-contract/commit/e5db3cd443c46c131ab0afc076451484132edede))
|
|
20
|
+
|
|
3
21
|
## [0.6.0](https://github.com/MaverickCER/repo-contract/compare/repo-contract-v0.5.2...repo-contract-v0.6.0) (2026-09-20)
|
|
4
22
|
|
|
5
23
|
|
package/dist/.dts/errors.d.ts
CHANGED
|
@@ -63,23 +63,12 @@ export declare class DependencyDeclaredLaterError extends RepoContractError {
|
|
|
63
63
|
readonly dependencyId: string;
|
|
64
64
|
constructor(checkId: string, dependencyId: string);
|
|
65
65
|
}
|
|
66
|
-
/** A check requested `output: { format: "yaml" }` but the optional `yaml` peer dependency is not installed. Thrown when that check's output is parsed, not at config-validation time (parsing only happens after the process has already run). */
|
|
67
|
-
export declare class ParserDependencyMissingError extends RepoContractError {
|
|
68
|
-
/** Always `"REPO_CONTRACT_PARSER_DEPENDENCY_MISSING"`. */
|
|
69
|
-
readonly code = "REPO_CONTRACT_PARSER_DEPENDENCY_MISSING";
|
|
70
|
-
/** The id of the check whose output could not be parsed. */
|
|
71
|
-
readonly checkId: string;
|
|
72
|
-
/** The output format that was requested but whose optional peer dependency is missing. */
|
|
73
|
-
readonly format: OutputFormatForError;
|
|
74
|
-
constructor(checkId: string, format: OutputFormatForError, cause: unknown);
|
|
75
|
-
}
|
|
76
|
-
type OutputFormatForError = "yaml";
|
|
77
66
|
/**
|
|
78
67
|
* A check's `output.schema["~standard"].validate()` threw synchronously, or returned a `Promise`
|
|
79
68
|
* that rejected, instead of returning a `Result`. This is a bug in the consumer-supplied schema
|
|
80
69
|
* object, not malformed check output -- the same distinction `PolicyThrewError` below draws for a
|
|
81
70
|
* throwing policy: a schema *returning* failure `issues` becomes an ordinary
|
|
82
|
-
* `ParsedOutputFailure` (reported as data, exactly like a malformed-JSON
|
|
71
|
+
* `ParsedOutputFailure` (reported as data, exactly like a malformed-JSON parse failure), but
|
|
83
72
|
* a schema *throwing* means the validator itself is broken, so it propagates as a rejected
|
|
84
73
|
* `runRepoContract()` promise instead. The original thrown/rejected value is preserved verbatim
|
|
85
74
|
* via the native `Error` `cause` chain.
|
|
@@ -168,5 +157,4 @@ export declare class PolicyReadFailedParseValueError extends RepoContractError {
|
|
|
168
157
|
readonly checkId: string;
|
|
169
158
|
constructor(checkId: string, property: string, cause: unknown);
|
|
170
159
|
}
|
|
171
|
-
export {};
|
|
172
160
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,8BAAsB,iBAAkB,SAAQ,KAAK;IACnD,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAC/B;AAED,+aAA+a;AAC/a,qBAAa,8BAA+B,SAAQ,iBAAiB;IACnE,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,kCAAiC;gBAElC,MAAM,EAAE,MAAM;CAI3B;AAED,sPAAsP;AACtP,qBAAa,uBAAwB,SAAQ,iBAAiB;IAC5D,qDAAqD;IACrD,QAAQ,CAAC,IAAI,wCAAuC;IACpD,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;gBAEZ,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAK5C;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,iBAAiB;I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HANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { defineRepoContract } from "./config/define-repo-contract.js";
|
|
10
10
|
export { runRepoContract } from "./run-repo-contract.js";
|
|
11
|
-
export { DependencyDeclaredLaterError, InvalidCheckConfigError, InvalidRepoContractConfigError,
|
|
11
|
+
export { DependencyDeclaredLaterError, InvalidCheckConfigError, InvalidRepoContractConfigError, PolicyReadFailedParseValueError, PolicyReadUnrequestedOutputError, PolicyThrewError, RepoContractError, StandardSchemaValidateThrewError, UnknownCheckIdError, } from "./errors.js";
|
|
12
12
|
export type { StandardSchemaV1 } from "./standard-schema/types.js";
|
|
13
13
|
export type { CheckDefinition, CheckDefinitionConfig, CheckEvidence, CheckSchema, CheckStatus, Evidence, OutputFormat, ParsedOutput, ParsedOutputFailure, ParsedOutputSuccess, Policy, PolicyContext, PolicyOutcome, PolicyResult, RepoContractConfig, RunRepoContractOptions, Spawner, SyncSpawner, ValidatedCheckSchema, Verdict, } from "./types.js";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/.dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,EAChC,gBAAgB,EAChB,iBAAiB,EACjB,gCAAgC,EAChC,mBAAmB,GACpB,MAAM,aAAa,CAAA;AAEpB,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAElE,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,OAAO,EACP,WAAW,EACX,oBAAoB,EACpB,OAAO,GACR,MAAM,YAAY,CAAA"}
|
|
@@ -3,21 +3,18 @@ import type { OutputFormat, ParsedOutput } from "../types.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Dispatches to the parser for `format`, then -- only on a successful parse, and only if `schema`
|
|
5
5
|
* is supplied -- runs `schema["~standard"].validate()` against the parsed value
|
|
6
|
-
* (https://standardschema.dev). `parse-json.ts`/`parse-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
14
|
-
* malformed
|
|
15
|
-
* `ParsedOutputFailure`. Never throws for a malformed-output parse failure -- see each parser's
|
|
16
|
-
* own documentation. May throw `ParserDependencyMissingError` for `format: "yaml"` if the
|
|
17
|
-
* optional `yaml` peer dependency is unavailable.
|
|
6
|
+
* (https://standardschema.dev). `parse-json.ts`/`parse-text.ts` stay entirely unaware of `schema`;
|
|
7
|
+
* this is the sole orchestration point. `validate()` may return its `Result` synchronously or as a
|
|
8
|
+
* `Promise` -- `await`ing either uniformly is a no-op for the synchronous case, but this function
|
|
9
|
+
* still needs to be `async` for that awaited call. A successful `Result` (`issues === undefined`)
|
|
10
|
+
* replaces `value` with the schema's own (possibly transformed) output; a failing `Result`
|
|
11
|
+
* becomes a `ParsedOutputFailure` whose `error` is built by `formatSchemaIssues`. `schema.validate()`
|
|
12
|
+
* itself throwing or rejecting is a bug in the consumer-supplied schema, not malformed output -- it
|
|
13
|
+
* throws `StandardSchemaValidateThrewError` rather than becoming a `ParsedOutputFailure`. Never
|
|
14
|
+
* throws for a malformed-output parse failure -- see each parser's own documentation.
|
|
18
15
|
* @param format - which parser to dispatch to.
|
|
19
16
|
* @param stdout - the check's raw stdout to parse.
|
|
20
|
-
* @param checkId - identifies which check's output is being parsed, used in a thrown `
|
|
17
|
+
* @param checkId - identifies which check's output is being parsed, used in a thrown `StandardSchemaValidateThrewError`.
|
|
21
18
|
* @param schema - an optional Standard Schema-compliant validator to run against a successful parse's value.
|
|
22
19
|
* @returns the parsed (and, if `schema` was supplied and validation succeeded, schema-transformed) output.
|
|
23
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-output.d.ts","sourceRoot":"","sources":["../../../src/parsing/parse-output.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"parse-output.d.ts","sourceRoot":"","sources":["../../../src/parsing/parse-output.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK7D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAehC"}
|
package/dist/.dts/types.d.ts
CHANGED
|
@@ -6,8 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ChildProcess, SpawnOptions, SpawnSyncOptions, SpawnSyncReturns } from "node:child_process";
|
|
8
8
|
import type { StandardSchemaV1 } from "./standard-schema/types.js";
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Output interpretation a check can explicitly request. No format requested means no parsing --
|
|
11
|
+
* the consumer gets raw stdout/stderr only. Format conversion (e.g. YAML) is deliberately not a
|
|
12
|
+
* core concern of this package -- JSON and plain text cover every check this package or its
|
|
13
|
+
* consumers actually run; a check whose tool emits another format converts it in its own `run`
|
|
14
|
+
* step or reads it directly in its `policy` function, using whatever library it already depends
|
|
15
|
+
* on, rather than this package carrying an optional peer dependency on everyone's behalf.
|
|
16
|
+
*/
|
|
17
|
+
export type OutputFormat = "json" | "text";
|
|
11
18
|
/**
|
|
12
19
|
* Why a check's process ended up in its terminal state. `"completed"` means
|
|
13
20
|
* the process ran to exit on its own -- the exit code may still be
|
|
@@ -68,7 +75,7 @@ export type ParsedOutput<T> = ParsedOutputSuccess<T> | ParsedOutputFailure;
|
|
|
68
75
|
* is attempting to close: a schema still gives its own author real compile-time input/output
|
|
69
76
|
* typing via `StandardSchemaV1<Input, Output>` for their own code, just not threaded through this
|
|
70
77
|
* shared `CheckEvidence` shape. A policy author narrows or casts `.value` themselves, exactly as
|
|
71
|
-
* they already must for `"json"`/`"
|
|
78
|
+
* they already must for `"json"`/`"text"` with no schema supplied.
|
|
72
79
|
*/
|
|
73
80
|
export interface CheckEvidence {
|
|
74
81
|
/** The executable that was actually spawned (after tokenization, if `run` was a string). */
|
package/dist/.dts/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,gBAA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EAAE,gBAAgB,KACtB,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;AAEtC,gFAAgF;AAChF,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW;IAC3E,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,6HAA6H;IAC7H,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB;;;;;;;;;OASG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,WAAW,CAAA;CACvC;AAED,uDAAuD;AACvD,MAAM,WAAW,sBAAsB;IACrC,oOAAoO;IACpO,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,yIAAyI;IACzI,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAO,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW;IAChE,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,OAAO,GAAG,YAAY;KAAE,CAAA;CACjE"}
|
package/dist/index.cjs
CHANGED
|
@@ -79,23 +79,6 @@ var DependencyDeclaredLaterError = class extends RepoContractError {
|
|
|
79
79
|
this.dependencyId = dependencyId;
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
var ParserDependencyMissingError = class extends RepoContractError {
|
|
83
|
-
/** Always `"REPO_CONTRACT_PARSER_DEPENDENCY_MISSING"`. */
|
|
84
|
-
code = "REPO_CONTRACT_PARSER_DEPENDENCY_MISSING";
|
|
85
|
-
/** The id of the check whose output could not be parsed. */
|
|
86
|
-
checkId;
|
|
87
|
-
/** The output format that was requested but whose optional peer dependency is missing. */
|
|
88
|
-
format;
|
|
89
|
-
constructor(checkId, format, cause) {
|
|
90
|
-
super(
|
|
91
|
-
`Check "${checkId}" requested output.format: "${format}", but the optional "${format}" peer dependency is not installed -- run \`npm install ${format}\` to enable it.`,
|
|
92
|
-
{ cause }
|
|
93
|
-
);
|
|
94
|
-
this.name = "ParserDependencyMissingError";
|
|
95
|
-
this.checkId = checkId;
|
|
96
|
-
this.format = format;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
82
|
var StandardSchemaValidateThrewError = class extends RepoContractError {
|
|
100
83
|
/** Always `"REPO_CONTRACT_STANDARD_SCHEMA_VALIDATE_THREW"`. */
|
|
101
84
|
code = "REPO_CONTRACT_STANDARD_SCHEMA_VALIDATE_THREW";
|
|
@@ -128,7 +111,7 @@ var PolicyReadUnrequestedOutputError = class extends RepoContractError {
|
|
|
128
111
|
checkId;
|
|
129
112
|
constructor(checkId, property, cause) {
|
|
130
113
|
super(
|
|
131
|
-
`Policy for check "${checkId}" read \`result.output.${property}\`, but "${checkId}" never requested an output format, so \`result.output\` is undefined -- add \`output: { format: "json" }\` (or "
|
|
114
|
+
`Policy for check "${checkId}" read \`result.output.${property}\`, but "${checkId}" never requested an output format, so \`result.output\` is undefined -- add \`output: { format: "json" }\` (or "text") to check "${checkId}"'s definition to parse its stdout, then narrow with \`result.output?.success\` before reading \`.value\`/\`.error\`.`,
|
|
132
115
|
{ cause }
|
|
133
116
|
);
|
|
134
117
|
this.name = "PolicyReadUnrequestedOutputError";
|
|
@@ -239,7 +222,7 @@ function tokenizeRunString(run, checkId) {
|
|
|
239
222
|
}
|
|
240
223
|
|
|
241
224
|
// src/config/validate-config.ts
|
|
242
|
-
var OUTPUT_FORMATS = ["json", "
|
|
225
|
+
var OUTPUT_FORMATS = ["json", "text"];
|
|
243
226
|
function validateRepoContractConfig(config) {
|
|
244
227
|
const untrusted = config;
|
|
245
228
|
if (untrusted === null || typeof untrusted !== "object") {
|
|
@@ -514,28 +497,9 @@ function parseText(stdout) {
|
|
|
514
497
|
return { format: "text", success: true, value: stdout.trim() };
|
|
515
498
|
}
|
|
516
499
|
|
|
517
|
-
// src/parsing/parse-yaml.ts
|
|
518
|
-
async function parseYaml(stdout, checkId) {
|
|
519
|
-
let yamlModule;
|
|
520
|
-
try {
|
|
521
|
-
yamlModule = await import('yaml');
|
|
522
|
-
} catch (error) {
|
|
523
|
-
throw new ParserDependencyMissingError(checkId, "yaml", error);
|
|
524
|
-
}
|
|
525
|
-
try {
|
|
526
|
-
return { format: "yaml", success: true, value: yamlModule.parse(stdout) };
|
|
527
|
-
} catch (error) {
|
|
528
|
-
return {
|
|
529
|
-
format: "yaml",
|
|
530
|
-
success: false,
|
|
531
|
-
error: error instanceof Error ? error.message : String(error)
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
500
|
// src/parsing/parse-output.ts
|
|
537
501
|
async function parseOutput(format, stdout, checkId, schema) {
|
|
538
|
-
const parsed =
|
|
502
|
+
const parsed = dispatch(format, stdout);
|
|
539
503
|
if (!parsed.success || schema === void 0) return parsed;
|
|
540
504
|
let result;
|
|
541
505
|
try {
|
|
@@ -548,12 +512,10 @@ async function parseOutput(format, stdout, checkId, schema) {
|
|
|
548
512
|
}
|
|
549
513
|
return { format, success: false, error: formatSchemaIssues(result.issues) };
|
|
550
514
|
}
|
|
551
|
-
|
|
515
|
+
function dispatch(format, stdout) {
|
|
552
516
|
switch (format) {
|
|
553
517
|
case "json":
|
|
554
518
|
return parseJson(stdout);
|
|
555
|
-
case "yaml":
|
|
556
|
-
return parseYaml(stdout, checkId);
|
|
557
519
|
case "text":
|
|
558
520
|
return parseText(stdout);
|
|
559
521
|
}
|
|
@@ -1179,7 +1141,6 @@ async function runRepoContractAfterValidation(config, options) {
|
|
|
1179
1141
|
exports.DependencyDeclaredLaterError = DependencyDeclaredLaterError;
|
|
1180
1142
|
exports.InvalidCheckConfigError = InvalidCheckConfigError;
|
|
1181
1143
|
exports.InvalidRepoContractConfigError = InvalidRepoContractConfigError;
|
|
1182
|
-
exports.ParserDependencyMissingError = ParserDependencyMissingError;
|
|
1183
1144
|
exports.PolicyReadFailedParseValueError = PolicyReadFailedParseValueError;
|
|
1184
1145
|
exports.PolicyReadUnrequestedOutputError = PolicyReadUnrequestedOutputError;
|
|
1185
1146
|
exports.PolicyThrewError = PolicyThrewError;
|