@allurereport/reader 3.0.0-beta.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.
Files changed (58) hide show
  1. package/README.md +25 -0
  2. package/dist/allure1/index.d.ts +2 -0
  3. package/dist/allure1/index.js +289 -0
  4. package/dist/allure2/index.d.ts +2 -0
  5. package/dist/allure2/index.js +306 -0
  6. package/dist/allure2/model.d.ts +78 -0
  7. package/dist/allure2/model.js +21 -0
  8. package/dist/attachments/index.d.ts +2 -0
  9. package/dist/attachments/index.js +8 -0
  10. package/dist/cucumberjson/index.d.ts +2 -0
  11. package/dist/cucumberjson/index.js +306 -0
  12. package/dist/cucumberjson/model.d.ts +65 -0
  13. package/dist/cucumberjson/model.js +2 -0
  14. package/dist/index.d.ts +7 -0
  15. package/dist/index.js +6 -0
  16. package/dist/junitxml/index.d.ts +2 -0
  17. package/dist/junitxml/index.js +158 -0
  18. package/dist/model.d.ts +20 -0
  19. package/dist/model.js +1 -0
  20. package/dist/properties.d.ts +1 -0
  21. package/dist/properties.js +229 -0
  22. package/dist/toolRunner.d.ts +17 -0
  23. package/dist/toolRunner.js +143 -0
  24. package/dist/utils.d.ts +13 -0
  25. package/dist/utils.js +27 -0
  26. package/dist/validation.d.ts +45 -0
  27. package/dist/validation.js +51 -0
  28. package/dist/xcresult/bundle.d.ts +7 -0
  29. package/dist/xcresult/bundle.js +63 -0
  30. package/dist/xcresult/index.d.ts +2 -0
  31. package/dist/xcresult/index.js +91 -0
  32. package/dist/xcresult/model.d.ts +61 -0
  33. package/dist/xcresult/model.js +1 -0
  34. package/dist/xcresult/utils.d.ts +43 -0
  35. package/dist/xcresult/utils.js +378 -0
  36. package/dist/xcresult/xcresulttool/cli.d.ts +10 -0
  37. package/dist/xcresult/xcresulttool/cli.js +46 -0
  38. package/dist/xcresult/xcresulttool/index.d.ts +7 -0
  39. package/dist/xcresult/xcresulttool/index.js +311 -0
  40. package/dist/xcresult/xcresulttool/legacy/index.d.ts +10 -0
  41. package/dist/xcresult/xcresulttool/legacy/index.js +456 -0
  42. package/dist/xcresult/xcresulttool/legacy/model.d.ts +75 -0
  43. package/dist/xcresult/xcresulttool/legacy/model.js +1 -0
  44. package/dist/xcresult/xcresulttool/legacy/parsing.d.ts +15 -0
  45. package/dist/xcresult/xcresulttool/legacy/parsing.js +41 -0
  46. package/dist/xcresult/xcresulttool/legacy/utils.d.ts +7 -0
  47. package/dist/xcresult/xcresulttool/legacy/utils.js +33 -0
  48. package/dist/xcresult/xcresulttool/legacy/xcModel.d.ts +357 -0
  49. package/dist/xcresult/xcresulttool/legacy/xcModel.js +5 -0
  50. package/dist/xcresult/xcresulttool/model.d.ts +17 -0
  51. package/dist/xcresult/xcresulttool/model.js +6 -0
  52. package/dist/xcresult/xcresulttool/utils.d.ts +3 -0
  53. package/dist/xcresult/xcresulttool/utils.js +74 -0
  54. package/dist/xcresult/xcresulttool/xcModel.d.ts +96 -0
  55. package/dist/xcresult/xcresulttool/xcModel.js +18 -0
  56. package/dist/xml-utils.d.ts +5 -0
  57. package/dist/xml-utils.js +29 -0
  58. package/package.json +56 -0
@@ -0,0 +1,20 @@
1
+ export interface ExecutorInfo {
2
+ name: string;
3
+ type: string;
4
+ url: string;
5
+ buildOrder: number;
6
+ buildName: string;
7
+ buildUrl: string;
8
+ reportName: string;
9
+ reportUrl: string;
10
+ }
11
+ export interface Category {
12
+ name: string;
13
+ description?: string;
14
+ descriptionHtml?: string;
15
+ messageRegex?: string;
16
+ traceRegex?: string;
17
+ matchedStatuses: string[];
18
+ flaky?: boolean;
19
+ }
20
+ export type EnvironmentInfo = Record<string, string | undefined>;
package/dist/model.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const parseProperties: (input: string) => Record<string, string | undefined>;
@@ -0,0 +1,229 @@
1
+ export const parseProperties = (input) => {
2
+ if (!input) {
3
+ return {};
4
+ }
5
+ const result = {};
6
+ let escape = false;
7
+ let skipSpace = true;
8
+ let isCommentLine = false;
9
+ let newLine = true;
10
+ let multiLine = false;
11
+ let isKey = true;
12
+ let key = "";
13
+ let value = "";
14
+ let unicode;
15
+ let unicodeRemaining = 0;
16
+ let escapingUnicode = false;
17
+ let keySpace = false;
18
+ let sep = false;
19
+ const line = () => {
20
+ if (key || value || sep) {
21
+ result[key] = value;
22
+ key = "";
23
+ value = "";
24
+ sep = false;
25
+ }
26
+ };
27
+ const decodeString = (output, char) => {
28
+ if (escapingUnicode && unicodeRemaining) {
29
+ unicode = (unicode << 4) + hex(char);
30
+ if (--unicodeRemaining) {
31
+ return output;
32
+ }
33
+ escape = false;
34
+ escapingUnicode = false;
35
+ return output + String.fromCharCode(unicode);
36
+ }
37
+ if (char === "u") {
38
+ unicode = 0;
39
+ escapingUnicode = true;
40
+ unicodeRemaining = 4;
41
+ return output;
42
+ }
43
+ escape = false;
44
+ switch (char) {
45
+ case "t":
46
+ return `${output}\t`;
47
+ case "r":
48
+ return `${output}\r`;
49
+ case "n":
50
+ return `${output}\n`;
51
+ case "f":
52
+ return `${output}\f`;
53
+ }
54
+ return output + char;
55
+ };
56
+ for (const char of input) {
57
+ if (char === "\r") {
58
+ continue;
59
+ }
60
+ if (isCommentLine) {
61
+ if (char === "\n") {
62
+ isCommentLine = false;
63
+ newLine = true;
64
+ skipSpace = true;
65
+ }
66
+ continue;
67
+ }
68
+ if (skipSpace) {
69
+ if (isWhitespace(char)) {
70
+ continue;
71
+ }
72
+ if (!multiLine && char === "\n") {
73
+ isKey = true;
74
+ keySpace = false;
75
+ newLine = true;
76
+ line();
77
+ continue;
78
+ }
79
+ skipSpace = false;
80
+ multiLine = false;
81
+ }
82
+ if (newLine) {
83
+ newLine = false;
84
+ if (isComment(char)) {
85
+ isCommentLine = true;
86
+ continue;
87
+ }
88
+ }
89
+ if (char !== "\n") {
90
+ if (!escape && isKey && isSeparator(char)) {
91
+ sep = true;
92
+ isKey = false;
93
+ keySpace = false;
94
+ skipSpace = true;
95
+ continue;
96
+ }
97
+ if (char === "\\") {
98
+ if (escape) {
99
+ if (escapingUnicode) {
100
+ continue;
101
+ }
102
+ if (keySpace) {
103
+ keySpace = false;
104
+ isKey = false;
105
+ }
106
+ if (isKey) {
107
+ key += "\\";
108
+ }
109
+ else {
110
+ value += "\\";
111
+ }
112
+ }
113
+ escape = !escape;
114
+ }
115
+ else {
116
+ if (keySpace) {
117
+ keySpace = false;
118
+ isKey = false;
119
+ }
120
+ if (isKey) {
121
+ if (escape) {
122
+ key = decodeString(key, char);
123
+ }
124
+ else {
125
+ if (isWhitespace(char)) {
126
+ keySpace = true;
127
+ skipSpace = true;
128
+ continue;
129
+ }
130
+ key += char;
131
+ }
132
+ }
133
+ else {
134
+ if (escape) {
135
+ value = decodeString(value, char);
136
+ }
137
+ else {
138
+ value += char;
139
+ }
140
+ }
141
+ }
142
+ }
143
+ else {
144
+ if (escape) {
145
+ if (!escapingUnicode) {
146
+ escape = false;
147
+ }
148
+ skipSpace = true;
149
+ multiLine = true;
150
+ }
151
+ else {
152
+ newLine = true;
153
+ skipSpace = true;
154
+ isKey = true;
155
+ line();
156
+ }
157
+ }
158
+ }
159
+ line();
160
+ return result;
161
+ };
162
+ const hex = (char) => {
163
+ switch (char) {
164
+ case "0":
165
+ return 0;
166
+ case "1":
167
+ return 1;
168
+ case "2":
169
+ return 2;
170
+ case "3":
171
+ return 3;
172
+ case "4":
173
+ return 4;
174
+ case "5":
175
+ return 5;
176
+ case "6":
177
+ return 6;
178
+ case "7":
179
+ return 7;
180
+ case "8":
181
+ return 8;
182
+ case "9":
183
+ return 9;
184
+ case "a":
185
+ case "A":
186
+ return 10;
187
+ case "b":
188
+ case "B":
189
+ return 11;
190
+ case "c":
191
+ case "C":
192
+ return 12;
193
+ case "d":
194
+ case "D":
195
+ return 13;
196
+ case "e":
197
+ case "E":
198
+ return 14;
199
+ case "f":
200
+ case "F":
201
+ return 15;
202
+ }
203
+ throw new Error(`Non-hex char ${char}`);
204
+ };
205
+ const isWhitespace = (char) => {
206
+ switch (char) {
207
+ case "\t":
208
+ case "\f":
209
+ case " ":
210
+ return true;
211
+ }
212
+ return false;
213
+ };
214
+ const isSeparator = (char) => {
215
+ switch (char) {
216
+ case "=":
217
+ case ":":
218
+ return true;
219
+ }
220
+ return false;
221
+ };
222
+ const isComment = (char) => {
223
+ switch (char) {
224
+ case "#":
225
+ case "!":
226
+ return true;
227
+ }
228
+ return false;
229
+ };
@@ -0,0 +1,17 @@
1
+ import type { Unknown } from "./validation.js";
2
+ export type ProcessRunOptions = {
3
+ exitCode?: number | ((code: number) => boolean);
4
+ encoding?: BufferEncoding;
5
+ stderrEncoding?: BufferEncoding;
6
+ timeout?: number;
7
+ timeoutSignal?: NodeJS.Signals;
8
+ ignoreStderr?: boolean;
9
+ };
10
+ export declare const invokeCliTool: (executable: string, args: readonly string[], { timeout, timeoutSignal, ignoreStderr, encoding, exitCode: expectedExitCode }?: ProcessRunOptions) => Promise<void>;
11
+ type ResolveCliOutput<T> = T extends {
12
+ encoding: BufferEncoding;
13
+ } ? string : Buffer;
14
+ export declare const invokeStdoutCliTool: <T extends ProcessRunOptions | undefined>(executable: string, args: readonly string[], options?: T) => AsyncGenerator<ResolveCliOutput<T>, void, unknown>;
15
+ export declare const invokeTextStdoutCliTool: (executable: string, args: readonly string[], options?: ProcessRunOptions) => AsyncGenerator<string, void, unknown>;
16
+ export declare const invokeJsonCliTool: <T>(tool: string, args: readonly string[], options?: ProcessRunOptions) => Promise<Unknown<T>>;
17
+ export {};
@@ -0,0 +1,143 @@
1
+ import { spawn } from "node:child_process";
2
+ const LINE_SPLIT_PATTERN = /\r\n|\r|\n/;
3
+ export const invokeCliTool = async (executable, args, { timeout, timeoutSignal, ignoreStderr, encoding, exitCode: expectedExitCode = 0 } = {}) => {
4
+ const toolProcess = spawn(executable, args, {
5
+ stdio: ["ignore", "ignore", ignoreStderr ? "ignore" : "pipe"],
6
+ shell: false,
7
+ timeout: timeout,
8
+ killSignal: timeoutSignal,
9
+ });
10
+ const stderr = [];
11
+ if (!ignoreStderr) {
12
+ toolProcess.stderr?.setEncoding(encoding ?? "utf-8").on("data", (chunk) => stderr.push(String(chunk)));
13
+ }
14
+ let onSuccess;
15
+ let onError;
16
+ const resultPromise = new Promise((resolve, reject) => {
17
+ onSuccess = resolve;
18
+ onError = reject;
19
+ });
20
+ toolProcess.on("exit", (code, signal) => {
21
+ if (signal) {
22
+ onError(new Error(timeout && toolProcess.killed
23
+ ? `${executable} was terminated by timeout (${timeout} ms)`
24
+ : `${executable} was terminated with ${signal}`));
25
+ return;
26
+ }
27
+ if (typeof expectedExitCode === "number" ? code !== expectedExitCode : expectedExitCode(code)) {
28
+ onError(new Error(`${executable} finished with an unexpected exit code ${code}`));
29
+ return;
30
+ }
31
+ onSuccess();
32
+ });
33
+ return await resultPromise;
34
+ };
35
+ export const invokeStdoutCliTool = async function* (executable, args, options) {
36
+ const { timeout, timeoutSignal, encoding, stderrEncoding, exitCode: expectedExitCode = 0, ignoreStderr, } = options ?? {};
37
+ const emitTextChunk = (chunk) => {
38
+ const lines = (unfinishedLineBuffer + chunk).split(LINE_SPLIT_PATTERN);
39
+ if (lines.length) {
40
+ unfinishedLineBuffer = lines.at(-1);
41
+ stdoutChunks.push(...lines.slice(0, -1));
42
+ maybeContinueConsumption();
43
+ }
44
+ };
45
+ const emitFinalTextChunk = () => {
46
+ if (unfinishedLineBuffer) {
47
+ stdoutChunks.push(unfinishedLineBuffer);
48
+ unfinishedLineBuffer = "";
49
+ maybeContinueConsumption();
50
+ }
51
+ };
52
+ const emitBinaryChunk = (chunk) => {
53
+ stdoutChunks.push(chunk);
54
+ maybeContinueConsumption();
55
+ };
56
+ const emitError = (message) => {
57
+ if (stderrChunks.length) {
58
+ message = `${message}\n\nStandard error:\n\n${stderrChunks.join("")}`;
59
+ }
60
+ bufferedError = new Error(message);
61
+ maybeContinueConsumption();
62
+ };
63
+ const checkExitCode = (code) => {
64
+ if (typeof expectedExitCode === "number") {
65
+ return code === expectedExitCode;
66
+ }
67
+ return expectedExitCode(code);
68
+ };
69
+ const maybeContinueConsumption = () => {
70
+ if (continueConsumption) {
71
+ const continueConsumptionLocal = continueConsumption;
72
+ continueConsumption = undefined;
73
+ continueConsumptionLocal();
74
+ }
75
+ };
76
+ const stdoutChunks = [];
77
+ let unfinishedLineBuffer = "";
78
+ let done = false;
79
+ let bufferedError;
80
+ const stderrChunks = [];
81
+ let continueConsumption;
82
+ const toolProcess = spawn(executable, args, {
83
+ stdio: ["ignore", "pipe", ignoreStderr ? "ignore" : "pipe"],
84
+ shell: false,
85
+ timeout,
86
+ killSignal: timeoutSignal,
87
+ });
88
+ const { stdout, stderr } = toolProcess;
89
+ if (stdout) {
90
+ if (encoding) {
91
+ stdout.setEncoding(encoding).on("data", emitTextChunk);
92
+ }
93
+ else {
94
+ stdout.on("data", emitBinaryChunk);
95
+ }
96
+ }
97
+ if (stderr) {
98
+ stderr.setEncoding(stderrEncoding ?? encoding ?? "utf-8").on("data", stderrChunks.push.bind(stderrChunks));
99
+ }
100
+ toolProcess.on("exit", (code, signal) => {
101
+ emitFinalTextChunk();
102
+ done = true;
103
+ if (bufferedError) {
104
+ return;
105
+ }
106
+ if (signal) {
107
+ emitError(timeout && toolProcess.killed
108
+ ? `${executable} was terminated by timeout (${timeout} ms)`
109
+ : `${executable} was terminated with ${signal}`);
110
+ return;
111
+ }
112
+ if (!checkExitCode(code)) {
113
+ emitError(`${executable} finished with an unexpected exit code ${code}`);
114
+ return;
115
+ }
116
+ continueConsumption?.();
117
+ });
118
+ while (true) {
119
+ if (stdoutChunks.length) {
120
+ yield* stdoutChunks;
121
+ stdoutChunks.splice(0);
122
+ }
123
+ if (bufferedError) {
124
+ throw bufferedError;
125
+ }
126
+ if (done) {
127
+ return;
128
+ }
129
+ await new Promise((resolve) => {
130
+ continueConsumption = resolve;
131
+ });
132
+ }
133
+ };
134
+ export const invokeTextStdoutCliTool = async function* (executable, args, options = {}) {
135
+ yield* invokeStdoutCliTool(executable, args, { encoding: "utf-8", ...options });
136
+ };
137
+ export const invokeJsonCliTool = async (tool, args, options = {}) => {
138
+ const lines = [];
139
+ for await (const line of invokeTextStdoutCliTool(tool, args, options)) {
140
+ lines.push(line);
141
+ }
142
+ return JSON.parse(lines.join(""));
143
+ };
@@ -0,0 +1,13 @@
1
+ export declare const isBoolean: (value: unknown) => value is boolean;
2
+ export declare const isString: (value: unknown) => value is string;
3
+ export declare const isArray: <T = unknown>(value: unknown) => value is T[];
4
+ export declare const isNonNullObject: <T extends object = object>(value: unknown) => value is T;
5
+ export declare function ensureBoolean(value: unknown): boolean | undefined;
6
+ export declare function ensureBoolean(value: unknown, fallback: boolean): boolean;
7
+ export declare const ensureInt: (obj: unknown) => number | undefined;
8
+ export declare function ensureString(value: unknown): string | undefined;
9
+ export declare function ensureString(value: unknown, fallback: string): string;
10
+ export declare function ensureArray<T = unknown>(value: unknown): T[] | undefined;
11
+ export declare function ensureArray<T = unknown>(value: unknown, fallback: T[]): T[];
12
+ export declare function ensureObject<T extends object = object>(value: unknown): T | undefined;
13
+ export declare function ensureObject<T extends object = object>(value: unknown, fallback: T): T;
package/dist/utils.js ADDED
@@ -0,0 +1,27 @@
1
+ export const isBoolean = (value) => typeof value === "boolean";
2
+ export const isString = (value) => typeof value === "string";
3
+ export const isArray = (value) => Array.isArray(value);
4
+ export const isNonNullObject = (value) => typeof value === "object" && value !== null;
5
+ export function ensureBoolean(value, fallback) {
6
+ return isBoolean(value) ? value : fallback;
7
+ }
8
+ export const ensureInt = (obj) => {
9
+ if (typeof obj === "number") {
10
+ return obj;
11
+ }
12
+ const stringValue = ensureString(obj);
13
+ if (!stringValue) {
14
+ return undefined;
15
+ }
16
+ const parsed = parseInt(stringValue, 10);
17
+ return isNaN(parsed) ? undefined : parsed;
18
+ };
19
+ export function ensureString(value, fallback) {
20
+ return isString(value) ? value : fallback;
21
+ }
22
+ export function ensureArray(value, fallback) {
23
+ return isArray(value) ? value : fallback;
24
+ }
25
+ export function ensureObject(value, fallback) {
26
+ return isNonNullObject(value) ? value : fallback;
27
+ }
@@ -0,0 +1,45 @@
1
+ declare const unknownKey: unique symbol;
2
+ export type Unknown<T> = typeof unknownKey | ShallowKnown<T> | undefined | null;
3
+ export type ShallowKnown<T> = T extends object ? T extends (...v: any[]) => any ? T : {
4
+ [key in keyof T]: Unknown<T[key]>;
5
+ } : T;
6
+ export type IsSuper<SuperType, SubType> = [SubType] extends [never] ? never : [SubType] extends [SuperType] ? SuperType : never;
7
+ export type Narrow<SuperType, SubType> = [SubType] extends [never] ? never : [SubType] extends [SuperType] ? SubType : never;
8
+ export type ArrayElement<T> = T extends readonly (infer E)[] ? E : never;
9
+ export type IsHomogeneousObject<T> = T extends object ? T extends readonly any[] ? never : T extends {
10
+ [key in keyof T]: infer U;
11
+ } ? {
12
+ [key in keyof T]: U;
13
+ } extends T ? T : never : never : never;
14
+ export type NarrowHomogeneousObject<T, R> = T extends object ? T extends readonly any[] ? never : T extends {
15
+ [key in keyof T]: infer U;
16
+ } ? {
17
+ [key in keyof T]: U;
18
+ } extends T ? {
19
+ [key in keyof T]?: R;
20
+ } : never : never : never;
21
+ export type HomogeneousObjectItem<T> = T extends object ? T extends readonly any[] ? never : T extends {
22
+ [key in keyof T]: infer U;
23
+ } ? {
24
+ [key in keyof T]: U;
25
+ } extends T ? U : never : never : never;
26
+ export type ConditionalUnion<CA, A, CB, B> = [CA] extends [never] ? B : [CB] extends [never] ? A : A | B;
27
+ export declare const isDefined: <T>(value: T | undefined) => value is T;
28
+ export declare const isString: <T>(value: Unknown<IsSuper<T, string>>) => value is ShallowKnown<Narrow<T, string>>;
29
+ export declare const isNumber: <T>(value: Unknown<IsSuper<T, number>>) => value is ShallowKnown<Narrow<T, number>>;
30
+ export declare const isBoolean: <T>(value: Unknown<IsSuper<T, boolean>>) => value is ShallowKnown<Narrow<T, boolean>>;
31
+ export declare const isArray: <T>(value: Unknown<IsSuper<T, Extract<T, readonly any[]>>>) => value is ShallowKnown<Extract<Narrow<T, Extract<T, readonly any[]>>, readonly any[]>>;
32
+ export declare const isObject: <T>(value: Unknown<IsSuper<T, Extract<Exclude<T, readonly any[]>, object>>>) => value is ShallowKnown<Narrow<T, Extract<Exclude<T, readonly any[]>, object>>>;
33
+ export declare const isLiteral: <T, const L extends readonly any[]>(value: Unknown<IsSuper<T, L[number]>>, literals: L) => value is ShallowKnown<L[number]>;
34
+ export declare const ensureString: <T>(value: Unknown<T>) => string | undefined;
35
+ export declare const ensureNumber: <T>(value: Unknown<T>) => number | undefined;
36
+ export declare const ensureBoolean: <T>(value: Unknown<T>) => boolean | undefined;
37
+ export declare const ensureInt: <T>(value: Unknown<T>) => number | undefined;
38
+ export declare const ensureFloat: <T>(value: Unknown<T>) => number | undefined;
39
+ export declare const ensureArray: <T>(value: Unknown<IsSuper<T, Extract<T, readonly any[]>>>) => ShallowKnown<Extract<Narrow<T, Extract<T, readonly any[]>>, readonly any[]>> | undefined;
40
+ export declare const ensureObject: <T>(value: Unknown<IsSuper<T, Extract<Exclude<T, readonly any[]>, object>>>) => ShallowKnown<Narrow<T, Extract<Exclude<T, readonly any[]>, object>>> | undefined;
41
+ export declare const ensureLiteral: <T, const L extends readonly any[]>(value: Unknown<T>, literals: L) => ShallowKnown<L[number]> | undefined;
42
+ export declare const ensureArrayWithItems: <T, R extends ShallowKnown<ArrayElement<T>>>(value: Unknown<IsSuper<T, Extract<T, ArrayElement<T>[]>>>, guard: (v: Unknown<ArrayElement<T>>) => v is R) => R[] | undefined;
43
+ export declare const ensureObjectWithProps: <T, R extends ShallowKnown<HomogeneousObjectItem<T>>>(value: Unknown<IsSuper<T, Extract<T, IsHomogeneousObject<T>>>>, guard: (v: Unknown<HomogeneousObjectItem<T>>) => v is R) => NarrowHomogeneousObject<T, R> | undefined;
44
+ export declare const ensureItems: <T, R extends ShallowKnown<HomogeneousObjectItem<T> | ArrayElement<T>>>(value: Unknown<IsSuper<T, Extract<T, IsHomogeneousObject<T> | ArrayElement<T>[]>>>, guard: (v: Unknown<HomogeneousObjectItem<T> | ArrayElement<T>>) => v is R) => ConditionalUnion<ArrayElement<T>, R[], IsHomogeneousObject<T>, NarrowHomogeneousObject<T, R>> | undefined;
45
+ export {};
@@ -0,0 +1,51 @@
1
+ const unknownKey = Symbol("This must be an Unknown<T>");
2
+ export const isDefined = (value) => typeof value !== "undefined";
3
+ export const isString = (value) => typeof value === "string";
4
+ export const isNumber = (value) => typeof value === "number";
5
+ export const isBoolean = (value) => typeof value === "boolean";
6
+ export const isArray = (value) => Array.isArray(value);
7
+ export const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8
+ export const isLiteral = (value, literals) => literals.includes(value);
9
+ export const ensureString = (value) => typeof value === "string" ? value : undefined;
10
+ export const ensureNumber = (value) => typeof value === "number" ? value : undefined;
11
+ export const ensureBoolean = (value) => typeof value === "boolean" ? value : undefined;
12
+ export const ensureInt = (value) => {
13
+ if (typeof value === "number") {
14
+ return Math.floor(value);
15
+ }
16
+ if (typeof value === "string") {
17
+ const parsed = parseInt(value, 10);
18
+ if (!isNaN(parsed)) {
19
+ return parsed;
20
+ }
21
+ }
22
+ };
23
+ export const ensureFloat = (value) => {
24
+ if (typeof value === "number") {
25
+ return value;
26
+ }
27
+ if (typeof value === "string") {
28
+ const parsed = parseFloat(value);
29
+ if (!isNaN(parsed)) {
30
+ return parsed;
31
+ }
32
+ }
33
+ };
34
+ export const ensureArray = (value) => isArray(value) ? value : undefined;
35
+ export const ensureObject = (value) => isObject(value) ? value : undefined;
36
+ export const ensureLiteral = (value, literals) => literals.includes(value) ? value : undefined;
37
+ export const ensureArrayWithItems = (value, guard) => ensureArray(value)?.filter(guard);
38
+ export const ensureObjectWithProps = (value, guard) => {
39
+ const obj = ensureObject(value);
40
+ if (obj) {
41
+ return Object.entries(obj).reduce((a, [k, v]) => {
42
+ if (guard(v)) {
43
+ a[k] = v;
44
+ }
45
+ return a;
46
+ }, {});
47
+ }
48
+ };
49
+ export const ensureItems = (value, guard) => {
50
+ return ensureArrayWithItems(value, guard) ?? ensureObjectWithProps(value, guard);
51
+ };
@@ -0,0 +1,7 @@
1
+ export declare const XCRESULTTOOL_MISSING_MESSAGE = "'xcresulttool' is required to parse Xcode Result bundles, but we can't access it on this machine. This tool is a part of Xcode. Please make sure Xcode is installed. Visit this page to learn more about the installation:\n\n https://developer.apple.com/documentation/safari-developer-tools/installing-xcode-and-simulators\n\nNote that 'xcresulttool' doesn't come with Command Line Tools for Xcode. You need to install the full Xcode package to get it. If you have both installed, make sure the full installation is selected. Switch to it with xcode-select if necessary (the path to Xcode's Developer directory might be different on your machine):\n\n sudo xcode-select -s /Applications/Xcode.app/Contents/Developer\n\nThe original error that led to this message is shown below.\n";
2
+ export declare const IS_MAC: boolean;
3
+ export declare const isXcResultBundle: (directory: string) => Promise<boolean>;
4
+ export declare const checkUniformTypeIdentifier: (itemPath: string, uti: string) => Promise<boolean | undefined>;
5
+ export declare const isMostProbablyXcResultBundle: (directory: string) => Promise<boolean>;
6
+ export declare const followsXcResultNaming: (directory: string) => boolean;
7
+ export declare const findBundleInfoFile: (directory: string) => Promise<string | undefined>;
@@ -0,0 +1,63 @@
1
+ import { lstat } from "node:fs/promises";
2
+ import { platform } from "node:os";
3
+ import path from "node:path";
4
+ import { invokeStdoutCliTool } from "../toolRunner.js";
5
+ import { isDefined } from "../validation.js";
6
+ const XCODE_INSTALL_URL = "https://developer.apple.com/documentation/safari-developer-tools/installing-xcode-and-simulators";
7
+ const XCODE_SWITCH_COMMAND = "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer";
8
+ export const XCRESULTTOOL_MISSING_MESSAGE = `'xcresulttool' is required to parse Xcode Result bundles, but we can't \
9
+ access it on this machine. This tool is a part of Xcode. Please make sure Xcode is installed. Visit this page to learn \
10
+ more about the installation:
11
+
12
+ ${XCODE_INSTALL_URL}
13
+
14
+ Note that 'xcresulttool' doesn't come with Command Line Tools for Xcode. You need to install the full Xcode package to \
15
+ get it. If you have both installed, make sure the full installation is selected. Switch to it with xcode-select if \
16
+ necessary (the path to Xcode's Developer directory might be different on your machine):
17
+
18
+ ${XCODE_SWITCH_COMMAND}
19
+
20
+ The original error that led to this message is shown below.
21
+ `;
22
+ const bundleInfoFilePaths = new Set([
23
+ "Info.plist",
24
+ "Contents/Info.plist",
25
+ "Support Files/Info.plist",
26
+ "Resources/Info.plist",
27
+ ]);
28
+ export const IS_MAC = platform() === "darwin";
29
+ export const isXcResultBundle = async (directory) => {
30
+ const hasXcResultUti = IS_MAC
31
+ ? await checkUniformTypeIdentifier(directory, "com.apple.xcode.resultbundle")
32
+ : undefined;
33
+ return hasXcResultUti ?? (await isMostProbablyXcResultBundle(directory));
34
+ };
35
+ export const checkUniformTypeIdentifier = async (itemPath, uti) => {
36
+ const mdlsArgs = ["-raw", "-attr", "kMDItemContentTypeTree", itemPath];
37
+ const stringToSearch = `"${uti}"`;
38
+ try {
39
+ for await (const line of invokeStdoutCliTool("mdls", mdlsArgs)) {
40
+ if (line.indexOf(stringToSearch) !== -1) {
41
+ return true;
42
+ }
43
+ }
44
+ }
45
+ catch {
46
+ return undefined;
47
+ }
48
+ return false;
49
+ };
50
+ export const isMostProbablyXcResultBundle = async (directory) => isDefined(await findBundleInfoFile(directory)) || followsXcResultNaming(directory);
51
+ export const followsXcResultNaming = (directory) => directory.endsWith(".xcresult");
52
+ export const findBundleInfoFile = async (directory) => {
53
+ for (const infoFilePath of bundleInfoFilePaths) {
54
+ const infoFileAbsPath = path.join(directory, infoFilePath);
55
+ try {
56
+ const stat = await lstat(infoFileAbsPath);
57
+ if (stat.isFile()) {
58
+ return infoFileAbsPath;
59
+ }
60
+ }
61
+ catch { }
62
+ }
63
+ };
@@ -0,0 +1,2 @@
1
+ import type { ResultsVisitor } from "@allurereport/reader-api";
2
+ export declare const readXcResultBundle: (visitor: ResultsVisitor, directory: string) => Promise<boolean>;