@figulus/validator-core 0.5.0-alpha-dev-08 → 0.5.0-alpha-dev-10

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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Helpers, RegistryValidator } from "./registry-validator.js";
2
2
  export { settingsSchemaInput, settingsSchemaOutput, loadSettings, } from "./settings.js";
3
3
  export type { SettingsOutput, SettingsInput } from "./settings.js";
4
+ export type { ValidationSummary } from "./types.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { ValidationSummary } from "../types.js";
2
+ type Summary = Omit<ValidationSummary, "markdown">;
3
+ export declare function renderValidationMessage(summary: Summary): string;
4
+ export {};
5
+ //# sourceMappingURL=markdown-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-renderer.d.ts","sourceRoot":"","sources":["../../src/lib/markdown-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,KAAK,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;AA8CnD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAUhE"}
@@ -0,0 +1,42 @@
1
+ function renderError(error) {
2
+ return `• ${error.message}`;
3
+ }
4
+ function renderErrors(errors) {
5
+ return errors.map(renderError).join("\n");
6
+ }
7
+ function renderFailureResultsMessage(summary) {
8
+ const failures = summary.results.filter((r) => !r.result.success);
9
+ if (failures.length === 0)
10
+ return "";
11
+ let message = "### ❌ Validation failed. Please fix the following issues:\n\n";
12
+ failures.forEach((fileResult) => {
13
+ const result = fileResult.result;
14
+ message += `- \`${fileResult.file}\`\n`;
15
+ message += renderErrors(result.errors);
16
+ message += "\n\n";
17
+ });
18
+ return message.trim();
19
+ }
20
+ function renderWarningsMessage(summary) {
21
+ const warnings = summary.results.filter((r) => r.result.success && r.result.warnings?.length);
22
+ if (warnings.length === 0)
23
+ return "";
24
+ let message = "### ⚠️ Validation warnings:\n\n";
25
+ warnings.forEach((fileResult) => {
26
+ const result = fileResult.result;
27
+ message += `- \`${fileResult.file}\`\n`;
28
+ message += renderErrors(result.warnings || []);
29
+ message += "\n\n";
30
+ });
31
+ return message.trim();
32
+ }
33
+ export function renderValidationMessage(summary) {
34
+ if (summary.success)
35
+ return "### ✅ All validation checks passed!";
36
+ let message = renderFailureResultsMessage(summary);
37
+ const warningsMsg = renderWarningsMessage(summary);
38
+ if (warningsMsg)
39
+ message += "\n\n" + warningsMsg;
40
+ return message;
41
+ }
42
+ //# sourceMappingURL=markdown-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-renderer.js","sourceRoot":"","sources":["../../src/lib/markdown-renderer.ts"],"names":[],"mappings":"AAKA,SAAS,WAAW,CAAC,KAAsB;IACzC,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;AAC9B,CAAC;AA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,IAAI,YAAY,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;QAC/C,OAAO,IAAI,MAAM,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,IAAI,OAAO,CAAC,OAAO;QACjB,OAAO,qCAAqC,CAAC;IAE/C,IAAI,OAAO,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAEnD,MAAM,WAAW,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,WAAW;QAAE,OAAO,IAAI,MAAM,GAAG,WAAW,CAAC;IAEjD,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/pr.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../src/pr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EACL,eAAe,EACf,iBAAiB,EAElB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,qBAAa,EAAE;IAEJ,MAAM,EAAE,eAAe;IACvB,QAAQ,EAAE,iBAAiB;gBAD3B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,iBAAiB;IAG7B,SAAS,IAAI,MAAM;IAInB,WAAW,IAAI,cAAc;IAI7B,UAAU,IAAI,OAAO;IAIf,QAAQ,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAoEpD"}
1
+ {"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../src/pr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EACL,eAAe,EACf,iBAAiB,EAElB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,qBAAa,EAAE;IAEJ,MAAM,EAAE,eAAe;IACvB,QAAQ,EAAE,iBAAiB;gBAD3B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,iBAAiB;IAG7B,SAAS,IAAI,MAAM;IAInB,WAAW,IAAI,cAAc;IAI7B,UAAU,IAAI,OAAO;IAIf,QAAQ,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAkDpD"}
package/dist/pr.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ChangedFile } from "./changed-file.js";
2
+ import { renderValidationMessage } from "./lib/markdown-renderer.js";
2
3
  export class PR {
3
4
  prInfo;
4
5
  registry;
@@ -22,58 +23,44 @@ export class PR {
22
23
  let filesWithErrors = 0;
23
24
  let filesWithWarnings = 0;
24
25
  if (prInfo.changedFiles.length === 0) {
25
- helpers.console.log("No changed files to validate");
26
+ const msg = "No changed files to validate";
27
+ helpers.console.log(msg);
26
28
  return {
27
29
  success: true,
28
30
  totalFiles: 0,
29
31
  filesWithErrors: 0,
30
32
  filesWithWarnings: 0,
31
33
  results: [],
34
+ markdown: msg,
32
35
  };
33
36
  }
34
37
  for (const file of prInfo.changedFiles) {
35
38
  const result = await new ChangedFile(file, this).validate();
36
39
  results.push(result);
37
- if (!result.result.success) {
40
+ if (!result.result.success)
38
41
  filesWithErrors++;
39
- }
40
- else if (result.result.warnings?.length) {
42
+ else if (result.result.warnings?.length)
41
43
  filesWithWarnings++;
42
- }
43
44
  }
44
- // Output results
45
45
  const hasErrors = filesWithErrors > 0;
46
- if (hasErrors) {
47
- helpers.console.error("\n❌ Validation failed:\n");
48
- for (const result of results) {
49
- if (!result.result.success) {
50
- helpers.console.error(`📄 ${result.file}:`);
51
- result.result.errors.forEach((err) => {
52
- helpers.console.error(` • [${err.code}] ${err.message}`);
53
- });
54
- }
55
- }
56
- }
57
- else {
58
- helpers.console.log("✅ All validations passed!");
59
- }
60
- if (filesWithWarnings > 0) {
61
- helpers.console.log(`\n⚠️ ${filesWithWarnings} file(s) with warnings:\n`);
62
- for (const result of results) {
63
- if (result.result.success && result.result.warnings?.length) {
64
- helpers.console.log(`📄 ${result.file}:`);
65
- result.result.warnings.forEach((warn) => {
66
- helpers.console.log(` • [${warn.code}] ${warn.message}`);
67
- });
68
- }
69
- }
70
- }
46
+ const markdown = renderValidationMessage({
47
+ success: !hasErrors,
48
+ totalFiles: prInfo.changedFiles.length,
49
+ filesWithErrors,
50
+ filesWithWarnings,
51
+ results,
52
+ });
53
+ if (hasErrors)
54
+ helpers.console.error(markdown);
55
+ else
56
+ helpers.console.log(markdown);
71
57
  return {
72
58
  success: !hasErrors,
73
59
  totalFiles: prInfo.changedFiles.length,
74
60
  filesWithErrors,
75
61
  filesWithWarnings,
76
62
  results,
63
+ markdown,
77
64
  };
78
65
  }
79
66
  }
package/dist/pr.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pr.js","sourceRoot":"","sources":["../src/pr.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,OAAO,EAAE;IAEJ;IACA;IAFT,YACS,MAAuB,EACvB,QAA2B;QAD3B,WAAM,GAAN,MAAM,CAAiB;QACvB,aAAQ,GAAR,QAAQ,CAAmB;IACjC,CAAC;IAEG,SAAS;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAEM,WAAW;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAChC,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAClC,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAE7B,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,IAAI,eAAe,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M;gBAAE,iBAAiB,EAAE,CAAC;QAC/D,CAAC;QAED,MAAM,SAAS,GAAG,eAAe,GAAG,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,uBAAuB,CAAC;YACvC,OAAO,EAAE,CAAC,SAAS;YACnB,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM;YACtC,eAAe;YACf,iBAAiB;YACjB,OAAO;SACR,CAAC,CAAC;QAEH,IAAG,SAAS;YAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;;YACzC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEnC,OAAO;YACL,OAAO,EAAE,CAAC,SAAS;YACnB,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM;YACtC,eAAe;YACf,iBAAiB;YACjB,OAAO;YACP,QAAQ;SACT,CAAC;IACJ,CAAC;CACF"}
package/dist/types.d.ts CHANGED
@@ -16,5 +16,6 @@ export interface ValidationSummary {
16
16
  filesWithErrors: number;
17
17
  filesWithWarnings: number;
18
18
  results: FileValidationResult[];
19
+ markdown: string;
19
20
  }
20
21
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,oBAAoB,EAAE,CAAC;CACjC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@figulus/validator-core",
3
- "version": "0.5.0-alpha-dev-08",
3
+ "version": "0.5.0-alpha-dev-10",
4
4
  "description": "Core logic for the Figulus Validator",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,60 @@
1
+ import { ValidationSummary } from "../types.js";
2
+ import { FailureResult, SuccessResult, ValidationError } from "../validation-result.js";
3
+
4
+ type Summary = Omit<ValidationSummary, "markdown">;
5
+
6
+ function renderError(error: ValidationError): string {
7
+ return `• ${error.message}`;
8
+ }
9
+
10
+ function renderErrors(errors: ValidationError[]): string {
11
+ return errors.map(renderError).join("\n");
12
+ }
13
+
14
+ function renderFailureResultsMessage(summary: Summary): string {
15
+ const failures = summary.results.filter((r) => !r.result.success);
16
+
17
+ if (failures.length === 0)
18
+ return "";
19
+
20
+ let message = "### ❌ Validation failed. Please fix the following issues:\n\n";
21
+
22
+ failures.forEach((fileResult) => {
23
+ const result = fileResult.result as FailureResult;
24
+ message += `- \`${fileResult.file}\`\n`;
25
+ message += renderErrors(result.errors);
26
+ message += "\n\n";
27
+ });
28
+
29
+ return message.trim();
30
+ }
31
+
32
+ function renderWarningsMessage(summary: Summary): string {
33
+ const warnings = summary.results.filter((r) => r.result.success && r.result.warnings?.length);
34
+
35
+ if (warnings.length === 0)
36
+ return "";
37
+
38
+ let message = "### ⚠️ Validation warnings:\n\n";
39
+
40
+ warnings.forEach((fileResult) => {
41
+ const result = fileResult.result as SuccessResult;
42
+ message += `- \`${fileResult.file}\`\n`;
43
+ message += renderErrors(result.warnings || []);
44
+ message += "\n\n";
45
+ });
46
+
47
+ return message.trim();
48
+ }
49
+
50
+ export function renderValidationMessage(summary: Summary): string {
51
+ if (summary.success)
52
+ return "### ✅ All validation checks passed!";
53
+
54
+ let message = renderFailureResultsMessage(summary);
55
+
56
+ const warningsMsg = renderWarningsMessage(summary);
57
+ if (warningsMsg) message += "\n\n" + warningsMsg;
58
+
59
+ return message;
60
+ }
package/src/pr.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  } from "./types.js";
7
7
  import { ChangedFile } from "./changed-file.js";
8
8
  import { SettingsOutput } from "./settings.js";
9
+ import { renderValidationMessage } from "./lib/markdown-renderer.js";
9
10
 
10
11
  export class PR {
11
12
  constructor(
@@ -34,13 +35,15 @@ export class PR {
34
35
  let filesWithWarnings = 0;
35
36
 
36
37
  if (prInfo.changedFiles.length === 0) {
37
- helpers.console.log("No changed files to validate");
38
+ const msg = "No changed files to validate";
39
+ helpers.console.log(msg);
38
40
  return {
39
41
  success: true,
40
42
  totalFiles: 0,
41
43
  filesWithErrors: 0,
42
44
  filesWithWarnings: 0,
43
45
  results: [],
46
+ markdown: msg,
44
47
  };
45
48
  }
46
49
 
@@ -48,49 +51,29 @@ export class PR {
48
51
  const result = await new ChangedFile(file, this).validate();
49
52
  results.push(result);
50
53
 
51
- if (!result.result.success) {
52
- filesWithErrors++;
53
- } else if (result.result.warnings?.length) {
54
- filesWithWarnings++;
55
- }
54
+ if (!result.result.success) filesWithErrors++;
55
+ else if (result.result.warnings?.length) filesWithWarnings++;
56
56
  }
57
57
 
58
- // Output results
59
58
  const hasErrors = filesWithErrors > 0;
60
- if (hasErrors) {
61
- helpers.console.error("\n❌ Validation failed:\n");
62
- for (const result of results) {
63
- if (!result.result.success) {
64
- helpers.console.error(`📄 ${result.file}:`);
65
- result.result.errors.forEach((err) => {
66
- helpers.console.error(` • [${err.code}] ${err.message}`);
67
- });
68
- }
69
- }
70
- } else {
71
- helpers.console.log("✅ All validations passed!");
72
- }
73
-
74
- if (filesWithWarnings > 0) {
75
- helpers.console.log(
76
- `\n⚠️ ${filesWithWarnings} file(s) with warnings:\n`,
77
- );
78
- for (const result of results) {
79
- if (result.result.success && result.result.warnings?.length) {
80
- helpers.console.log(`📄 ${result.file}:`);
81
- result.result.warnings.forEach((warn) => {
82
- helpers.console.log(` • [${warn.code}] ${warn.message}`);
83
- });
84
- }
85
- }
86
- }
59
+ const markdown = renderValidationMessage({
60
+ success: !hasErrors,
61
+ totalFiles: prInfo.changedFiles.length,
62
+ filesWithErrors,
63
+ filesWithWarnings,
64
+ results,
65
+ });
87
66
 
67
+ if(hasErrors) helpers.console.error(markdown);
68
+ else helpers.console.log(markdown);
69
+
88
70
  return {
89
71
  success: !hasErrors,
90
72
  totalFiles: prInfo.changedFiles.length,
91
73
  filesWithErrors,
92
74
  filesWithWarnings,
93
75
  results,
76
+ markdown,
94
77
  };
95
78
  }
96
79
  }
package/src/settings.ts CHANGED
@@ -34,8 +34,6 @@ const settingsSchemaOptionalFields = {
34
34
  }),
35
35
  };
36
36
 
37
- console.log(Object.keys(settingsSchemaOptionalFields));
38
-
39
37
  export const settingsSchemaOutput = z.object({
40
38
  ...settingsSchemaOptionalFields,
41
39
  ...settingsSchemaRequiredFields,
package/src/types.ts CHANGED
@@ -20,4 +20,5 @@ export interface ValidationSummary {
20
20
  filesWithErrors: number;
21
21
  filesWithWarnings: number;
22
22
  results: FileValidationResult[];
23
+ markdown: string;
23
24
  }