@thymian/common-cli 0.0.0-PLACEHOLDER

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.
Files changed (111) hide show
  1. package/README.md +59 -0
  2. package/dist/base-cli-run-command.d.ts +94 -0
  3. package/dist/base-cli-run-command.d.ts.map +1 -0
  4. package/dist/base-cli-run-command.js +440 -0
  5. package/dist/base-cli-run-command.js.map +1 -0
  6. package/dist/default-config.d.ts +3 -0
  7. package/dist/default-config.d.ts.map +1 -0
  8. package/dist/default-config.js +27 -0
  9. package/dist/default-config.js.map +1 -0
  10. package/dist/error-cache.d.ts +31 -0
  11. package/dist/error-cache.d.ts.map +1 -0
  12. package/dist/error-cache.js +36 -0
  13. package/dist/error-cache.js.map +1 -0
  14. package/dist/feedback.d.ts +13 -0
  15. package/dist/feedback.d.ts.map +1 -0
  16. package/dist/feedback.js +30 -0
  17. package/dist/feedback.js.map +1 -0
  18. package/dist/flags/filter-flag.d.ts +20 -0
  19. package/dist/flags/filter-flag.d.ts.map +1 -0
  20. package/dist/flags/filter-flag.js +63 -0
  21. package/dist/flags/filter-flag.js.map +1 -0
  22. package/dist/flags/option-flag.d.ts +39 -0
  23. package/dist/flags/option-flag.d.ts.map +1 -0
  24. package/dist/flags/option-flag.js +144 -0
  25. package/dist/flags/option-flag.js.map +1 -0
  26. package/dist/flags/rule-set-flag.d.ts +5 -0
  27. package/dist/flags/rule-set-flag.d.ts.map +1 -0
  28. package/dist/flags/rule-set-flag.js +9 -0
  29. package/dist/flags/rule-set-flag.js.map +1 -0
  30. package/dist/flags/spec-flag.d.ts +11 -0
  31. package/dist/flags/spec-flag.d.ts.map +1 -0
  32. package/dist/flags/spec-flag.js +25 -0
  33. package/dist/flags/spec-flag.js.map +1 -0
  34. package/dist/flags/traffic-flag.d.ts +10 -0
  35. package/dist/flags/traffic-flag.d.ts.map +1 -0
  36. package/dist/flags/traffic-flag.js +24 -0
  37. package/dist/flags/traffic-flag.js.map +1 -0
  38. package/dist/get-config.d.ts +20 -0
  39. package/dist/get-config.d.ts.map +1 -0
  40. package/dist/get-config.js +82 -0
  41. package/dist/get-config.js.map +1 -0
  42. package/dist/hooks/feedback-hook.d.ts +9 -0
  43. package/dist/hooks/feedback-hook.d.ts.map +1 -0
  44. package/dist/hooks/feedback-hook.js +2 -0
  45. package/dist/hooks/feedback-hook.js.map +1 -0
  46. package/dist/hooks/plugin-init-hook.d.ts +20 -0
  47. package/dist/hooks/plugin-init-hook.d.ts.map +1 -0
  48. package/dist/hooks/plugin-init-hook.js +2 -0
  49. package/dist/hooks/plugin-init-hook.js.map +1 -0
  50. package/dist/hooks/spec-search-hook.d.ts +18 -0
  51. package/dist/hooks/spec-search-hook.d.ts.map +1 -0
  52. package/dist/hooks/spec-search-hook.js +2 -0
  53. package/dist/hooks/spec-search-hook.js.map +1 -0
  54. package/dist/hooks/traffic-search-hook.d.ts +18 -0
  55. package/dist/hooks/traffic-search-hook.d.ts.map +1 -0
  56. package/dist/hooks/traffic-search-hook.js +2 -0
  57. package/dist/hooks/traffic-search-hook.js.map +1 -0
  58. package/dist/index.d.ts +20 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +20 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/merge-inputs.d.ts +34 -0
  63. package/dist/merge-inputs.d.ts.map +1 -0
  64. package/dist/merge-inputs.js +50 -0
  65. package/dist/merge-inputs.js.map +1 -0
  66. package/dist/oclif.d.ts +2 -0
  67. package/dist/oclif.d.ts.map +1 -0
  68. package/dist/oclif.js +2 -0
  69. package/dist/oclif.js.map +1 -0
  70. package/dist/promise-queue.d.ts +7 -0
  71. package/dist/promise-queue.d.ts.map +1 -0
  72. package/dist/promise-queue.js +24 -0
  73. package/dist/promise-queue.js.map +1 -0
  74. package/dist/prompts.d.ts +5 -0
  75. package/dist/prompts.d.ts.map +1 -0
  76. package/dist/prompts.js +7 -0
  77. package/dist/prompts.js.map +1 -0
  78. package/dist/read-plugins.d.ts +2 -0
  79. package/dist/read-plugins.d.ts.map +1 -0
  80. package/dist/read-plugins.js +23 -0
  81. package/dist/read-plugins.js.map +1 -0
  82. package/dist/safe-parse.d.ts +2 -0
  83. package/dist/safe-parse.d.ts.map +1 -0
  84. package/dist/safe-parse.js +22 -0
  85. package/dist/safe-parse.js.map +1 -0
  86. package/dist/thymian-base-command.d.ts +21 -0
  87. package/dist/thymian-base-command.d.ts.map +1 -0
  88. package/dist/thymian-base-command.js +60 -0
  89. package/dist/thymian-base-command.js.map +1 -0
  90. package/dist/thymian-config-schema.d.ts +85 -0
  91. package/dist/thymian-config-schema.d.ts.map +1 -0
  92. package/dist/thymian-config-schema.js +79 -0
  93. package/dist/thymian-config-schema.js.map +1 -0
  94. package/dist/thymian-config-schema.json +116 -0
  95. package/dist/thymian-config.d.ts +19 -0
  96. package/dist/thymian-config.d.ts.map +1 -0
  97. package/dist/thymian-config.js +2 -0
  98. package/dist/thymian-config.js.map +1 -0
  99. package/dist/validate-config.d.ts +8 -0
  100. package/dist/validate-config.d.ts.map +1 -0
  101. package/dist/validate-config.js +18 -0
  102. package/dist/validate-config.js.map +1 -0
  103. package/dist/workflow-outcome.d.ts +21 -0
  104. package/dist/workflow-outcome.d.ts.map +1 -0
  105. package/dist/workflow-outcome.js +51 -0
  106. package/dist/workflow-outcome.js.map +1 -0
  107. package/dist/yaml.d.ts +2 -0
  108. package/dist/yaml.d.ts.map +1 -0
  109. package/dist/yaml.js +2 -0
  110. package/dist/yaml.js.map +1 -0
  111. package/package.json +52 -0
@@ -0,0 +1,85 @@
1
+ export declare const thymianConfigSchema: {
2
+ type: string;
3
+ properties: {
4
+ autoload: {
5
+ type: string;
6
+ };
7
+ logLevel: {
8
+ type: string;
9
+ enum: string[];
10
+ };
11
+ specifications: {
12
+ type: string;
13
+ items: {
14
+ type: string;
15
+ required: string[];
16
+ additionalProperties: boolean;
17
+ properties: {
18
+ type: {
19
+ type: string;
20
+ };
21
+ location: {};
22
+ options: {
23
+ type: string;
24
+ additionalProperties: boolean;
25
+ };
26
+ };
27
+ };
28
+ };
29
+ traffic: {
30
+ type: string;
31
+ items: {
32
+ type: string;
33
+ required: string[];
34
+ additionalProperties: boolean;
35
+ properties: {
36
+ type: {
37
+ type: string;
38
+ };
39
+ location: {};
40
+ options: {
41
+ type: string;
42
+ additionalProperties: boolean;
43
+ };
44
+ };
45
+ };
46
+ };
47
+ ruleSets: {
48
+ type: string;
49
+ items: {
50
+ type: string;
51
+ };
52
+ };
53
+ ruleSeverity: {
54
+ type: string;
55
+ enum: string[];
56
+ };
57
+ rules: {
58
+ type: string;
59
+ additionalProperties: boolean;
60
+ };
61
+ targetUrl: {
62
+ type: string;
63
+ };
64
+ plugins: {
65
+ type: string;
66
+ additionalProperties: {
67
+ type: string;
68
+ additionalProperties: boolean;
69
+ properties: {
70
+ path: {
71
+ type: string;
72
+ };
73
+ verbose: {
74
+ type: string;
75
+ };
76
+ options: {
77
+ type: string;
78
+ additionalProperties: boolean;
79
+ };
80
+ };
81
+ };
82
+ };
83
+ };
84
+ };
85
+ //# sourceMappingURL=thymian-config-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thymian-config-schema.d.ts","sourceRoot":"","sources":["../src/thymian-config-schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6E/B,CAAC"}
@@ -0,0 +1,79 @@
1
+ export const thymianConfigSchema = {
2
+ type: 'object',
3
+ properties: {
4
+ autoload: {
5
+ type: 'boolean',
6
+ },
7
+ logLevel: {
8
+ type: 'string',
9
+ enum: ['trace', 'debug', 'info', 'warn', 'error', 'silent'],
10
+ },
11
+ specifications: {
12
+ type: 'array',
13
+ items: {
14
+ type: 'object',
15
+ required: ['type', 'location'],
16
+ additionalProperties: false,
17
+ properties: {
18
+ type: { type: 'string' },
19
+ location: {},
20
+ options: {
21
+ type: 'object',
22
+ additionalProperties: true,
23
+ },
24
+ },
25
+ },
26
+ },
27
+ traffic: {
28
+ type: 'array',
29
+ items: {
30
+ type: 'object',
31
+ required: ['type', 'location'],
32
+ additionalProperties: false,
33
+ properties: {
34
+ type: { type: 'string' },
35
+ location: {},
36
+ options: {
37
+ type: 'object',
38
+ additionalProperties: true,
39
+ },
40
+ },
41
+ },
42
+ },
43
+ ruleSets: {
44
+ type: 'array',
45
+ items: { type: 'string' },
46
+ },
47
+ ruleSeverity: {
48
+ type: 'string',
49
+ enum: ['off', 'error', 'warn', 'hint'],
50
+ },
51
+ rules: {
52
+ type: 'object',
53
+ additionalProperties: true,
54
+ },
55
+ targetUrl: {
56
+ type: 'string',
57
+ },
58
+ plugins: {
59
+ type: 'object',
60
+ additionalProperties: {
61
+ type: 'object',
62
+ additionalProperties: false,
63
+ properties: {
64
+ path: {
65
+ type: 'string',
66
+ },
67
+ verbose: {
68
+ type: 'boolean',
69
+ },
70
+ options: {
71
+ type: 'object',
72
+ additionalProperties: true,
73
+ },
74
+ },
75
+ },
76
+ },
77
+ },
78
+ };
79
+ //# sourceMappingURL=thymian-config-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thymian-config-schema.js","sourceRoot":"","sources":["../src/thymian-config-schema.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS;SAChB;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;SAC5D;QACD,cAAc,EAAE;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC;gBAC9B,oBAAoB,EAAE,KAAK;gBAC3B,UAAU,EAAE;oBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,QAAQ,EAAE,EAAE;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,QAAQ;wBACd,oBAAoB,EAAE,IAAI;qBAC3B;iBACF;aACF;SACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC;gBAC9B,oBAAoB,EAAE,KAAK;gBAC3B,UAAU,EAAE;oBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,QAAQ,EAAE,EAAE;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,QAAQ;wBACd,oBAAoB,EAAE,IAAI;qBAC3B;iBACF;aACF;SACF;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;SACvC;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,IAAI;SAC3B;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;SACf;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE;gBACpB,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;qBACf;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,SAAS;qBAChB;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,QAAQ;wBACd,oBAAoB,EAAE,IAAI;qBAC3B;iBACF;aACF;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,116 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "required": ["plugins"],
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "autoload": {
8
+ "type": "boolean"
9
+ },
10
+ "logLevel": {
11
+ "type": "string",
12
+ "enum": ["trace", "debug", "info", "warn", "error", "silent"]
13
+ },
14
+ "specifications": {
15
+ "type": "array",
16
+ "items": {
17
+ "type": "object",
18
+ "required": ["type", "location"],
19
+ "additionalProperties": false,
20
+ "properties": {
21
+ "type": {
22
+ "type": "string"
23
+ },
24
+ "location": {},
25
+ "options": {
26
+ "type": "object",
27
+ "additionalProperties": true
28
+ }
29
+ }
30
+ }
31
+ },
32
+ "traffic": {
33
+ "type": "array",
34
+ "items": {
35
+ "type": "object",
36
+ "required": ["type", "location"],
37
+ "additionalProperties": false,
38
+ "properties": {
39
+ "type": {
40
+ "type": "string"
41
+ },
42
+ "location": {},
43
+ "options": {
44
+ "type": "object",
45
+ "additionalProperties": true
46
+ }
47
+ }
48
+ }
49
+ },
50
+ "ruleSets": {
51
+ "type": "array",
52
+ "items": {
53
+ "type": "string"
54
+ }
55
+ },
56
+ "ruleSeverity": {
57
+ "type": "string",
58
+ "enum": ["off", "error", "warn", "hint"]
59
+ },
60
+ "targetUrl": {
61
+ "type": "string",
62
+ "description": "Override the target URL for all test requests. When set, all requests are sent to this origin instead of the servers defined in the specification."
63
+ },
64
+ "rules": {
65
+ "type": "object",
66
+ "additionalProperties": {
67
+ "oneOf": [
68
+ {
69
+ "type": "string",
70
+ "enum": ["error", "warn", "hint", "off"]
71
+ },
72
+ {
73
+ "type": "object",
74
+ "additionalProperties": true,
75
+ "properties": {
76
+ "severity": {
77
+ "type": "string",
78
+ "enum": ["error", "warn", "hint", "off"]
79
+ },
80
+ "options": {
81
+ "type": "object",
82
+ "additionalProperties": true
83
+ },
84
+ "skipOrigins": {
85
+ "type": "array",
86
+ "items": {
87
+ "type": "string"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ ]
93
+ }
94
+ },
95
+ "plugins": {
96
+ "type": "object",
97
+ "nullable": false,
98
+ "additionalProperties": {
99
+ "type": "object",
100
+ "additionalProperties": false,
101
+ "properties": {
102
+ "path": {
103
+ "type": "string"
104
+ },
105
+ "verbose": {
106
+ "type": "boolean"
107
+ },
108
+ "options": {
109
+ "type": "object",
110
+ "additionalProperties": true
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
@@ -0,0 +1,19 @@
1
+ import type { LogLevel, RulesConfiguration, RuleSeverity, SpecificationInput, TrafficInput } from '@thymian/core';
2
+ export interface ThymianPluginConfiguration<Options extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> {
3
+ path?: string;
4
+ verbose?: boolean;
5
+ autoload?: boolean;
6
+ options?: Options;
7
+ }
8
+ export interface ThymianConfig {
9
+ autoload?: boolean;
10
+ logLevel?: LogLevel;
11
+ specifications?: SpecificationInput[];
12
+ traffic?: TrafficInput[];
13
+ ruleSets?: string[];
14
+ ruleSeverity?: RuleSeverity;
15
+ rules?: RulesConfiguration;
16
+ targetUrl?: string;
17
+ plugins: Record<string, ThymianPluginConfiguration>;
18
+ }
19
+ //# sourceMappingURL=thymian-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thymian-config.d.ts","sourceRoot":"","sources":["../src/thymian-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,0BAA0B,CACzC,OAAO,SAAS,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC;IAE3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACtC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CACrD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=thymian-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thymian-config.js","sourceRoot":"","sources":["../src/thymian-config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export type ConfigValidationResult = {
2
+ valid: true;
3
+ } | {
4
+ valid: boolean;
5
+ message: string;
6
+ };
7
+ export declare function validateConfig(config: unknown): ConfigValidationResult;
8
+ //# sourceMappingURL=validate-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-config.d.ts","sourceRoot":"","sources":["../src/validate-config.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,sBAAsB,GAC9B;IACE,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,sBAAsB,CAatE"}
@@ -0,0 +1,18 @@
1
+ import { EOL } from 'node:os';
2
+ import { ajv } from '@thymian/core';
3
+ import thymianSchema from './thymian-config-schema.json' with { type: 'json' };
4
+ const validationFn = ajv.compile(thymianSchema);
5
+ export function validateConfig(config) {
6
+ const valid = validationFn(config);
7
+ if (valid) {
8
+ return { valid };
9
+ }
10
+ else {
11
+ return {
12
+ valid,
13
+ message: validationFn.errors?.map((e) => EOL + ' * ' + e.message).join('') ??
14
+ 'Unknown error',
15
+ };
16
+ }
17
+ }
18
+ //# sourceMappingURL=validate-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-config.js","sourceRoot":"","sources":["../src/validate-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,aAAa,MAAM,8BAA8B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE/E,MAAM,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAWhD,MAAM,UAAU,cAAc,CAAC,MAAe;IAC5C,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAEnC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC;SAAM,CAAC;QACN,OAAO;YACL,KAAK;YACL,OAAO,EACL,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnE,eAAe;SAClB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Command } from '@oclif/core';
2
+ import type { WorkflowClassification, WorkflowOutcome } from '@thymian/core';
3
+ /**
4
+ * Default threshold for the high-count brownfield guidance message.
5
+ * When total violation count exceeds this value, a contextual message
6
+ * is emitted to help developers understand that many findings are normal
7
+ * for brownfield APIs.
8
+ */
9
+ export declare const HIGH_COUNT_THRESHOLD = 20;
10
+ export declare function classificationToExitCode(classification: WorkflowClassification): 0 | 1 | 2;
11
+ /**
12
+ * Handle workflow outcome: print report text, emit guidance, and exit.
13
+ *
14
+ * Guidance is emitted **before** `command.exit()` because oclif's `exit()`
15
+ * throws an `ExitError` that terminates the command — any code after it
16
+ * is unreachable.
17
+ */
18
+ export declare function handleWorkflowOutcome(command: Pick<Command, 'exit'> & {
19
+ guidance(message: string): void;
20
+ }, outcome: WorkflowOutcome): void;
21
+ //# sourceMappingURL=workflow-outcome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-outcome.d.ts","sourceRoot":"","sources":["../src/workflow-outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE7E;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,sBAAsB,GACrC,CAAC,GAAG,CAAC,GAAG,CAAC,CASX;AA4BD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACpE,OAAO,EAAE,eAAe,GACvB,IAAI,CAYN"}
@@ -0,0 +1,51 @@
1
+ import { ux } from '@oclif/core';
2
+ /**
3
+ * Default threshold for the high-count brownfield guidance message.
4
+ * When total violation count exceeds this value, a contextual message
5
+ * is emitted to help developers understand that many findings are normal
6
+ * for brownfield APIs.
7
+ */
8
+ export const HIGH_COUNT_THRESHOLD = 20;
9
+ export function classificationToExitCode(classification) {
10
+ switch (classification) {
11
+ case 'clean-run':
12
+ return 0;
13
+ case 'findings':
14
+ return 1;
15
+ case 'tool-error':
16
+ return 2;
17
+ }
18
+ }
19
+ /**
20
+ * Emit post-report guidance hints to stderr via the command's `guidance()` method.
21
+ *
22
+ * Called internally by {@link handleWorkflowOutcome} before process exit so that
23
+ * guidance is guaranteed to reach the user even when exit code is non-zero.
24
+ */
25
+ function emitGuidance(command, outcome) {
26
+ if (outcome.classification !== 'findings') {
27
+ return;
28
+ }
29
+ const totalViolations = outcome.results.reduce((sum, r) => sum + r.violations.length, 0);
30
+ if (totalViolations > HIGH_COUNT_THRESHOLD) {
31
+ command.guidance(`\n${String.fromCodePoint(0x2139)} Running Thymian on an existing API often surfaces many findings. This doesn't mean your API is broken \u2014 it means there are HTTP conformance improvements available. Start with errors and work through them incrementally.`);
32
+ }
33
+ }
34
+ /**
35
+ * Handle workflow outcome: print report text, emit guidance, and exit.
36
+ *
37
+ * Guidance is emitted **before** `command.exit()` because oclif's `exit()`
38
+ * throws an `ExitError` that terminates the command — any code after it
39
+ * is unreachable.
40
+ */
41
+ export function handleWorkflowOutcome(command, outcome) {
42
+ if (outcome.text) {
43
+ ux.stdout(outcome.text);
44
+ }
45
+ emitGuidance(command, outcome);
46
+ const exitCode = classificationToExitCode(outcome.classification);
47
+ if (exitCode !== 0) {
48
+ command.exit(exitCode);
49
+ }
50
+ }
51
+ //# sourceMappingURL=workflow-outcome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-outcome.js","sourceRoot":"","sources":["../src/workflow-outcome.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,MAAM,UAAU,wBAAwB,CACtC,cAAsC;IAEtC,QAAQ,cAAc,EAAE,CAAC;QACvB,KAAK,WAAW;YACd,OAAO,CAAC,CAAC;QACX,KAAK,UAAU;YACb,OAAO,CAAC,CAAC;QACX,KAAK,YAAY;YACf,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CACnB,OAA4C,EAC5C,OAAwB;IAExB,IAAI,OAAO,CAAC,cAAc,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO;IACT,CAAC;IAED,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAC5C,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,EACrC,CAAC,CACF,CAAC;IAEF,IAAI,eAAe,GAAG,oBAAoB,EAAE,CAAC;QAC3C,OAAO,CAAC,QAAQ,CACd,KAAK,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,kOAAkO,CACpQ,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAoE,EACpE,OAAwB;IAExB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE/B,MAAM,QAAQ,GAAG,wBAAwB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAElE,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
package/dist/yaml.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from 'yaml';
2
+ //# sourceMappingURL=yaml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC"}
package/dist/yaml.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from 'yaml';
2
+ //# sourceMappingURL=yaml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml.js","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@thymian/common-cli",
3
+ "version": "0.0.0-PLACEHOLDER",
4
+ "description": "Shared CLI utilities, commands, and configuration management for Thymian",
5
+ "license": "AGPL-3.0-only",
6
+ "bugs": {
7
+ "url": "https://github.com/thymianofficial/thymian/issues"
8
+ },
9
+ "homepage": "https://thymian.dev",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/thymianofficial/thymian.git",
13
+ "directory": "packages/common-cli"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "keywords": [
19
+ "thymian",
20
+ "cli",
21
+ "oclif",
22
+ "api-governance",
23
+ "command-line",
24
+ "configuration"
25
+ ],
26
+ "type": "module",
27
+ "main": "./dist/index.js",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ "./package.json": "./package.json",
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.js",
35
+ "default": "./dist/index.js"
36
+ },
37
+ "./oclif": "./dist/oclif.js",
38
+ "./yaml": "./dist/yaml.js",
39
+ "./prompts": "./dist/prompts.js"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "!**/*.tsbuildinfo"
44
+ ],
45
+ "dependencies": {
46
+ "@inquirer/prompts": "^7.6.0",
47
+ "tslib": "^2.3.0",
48
+ "yaml": "^2.8.3",
49
+ "@oclif/core": "^4.3.3",
50
+ "@thymian/core": "0.0.0-PLACEHOLDER"
51
+ }
52
+ }