-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate-Docs.ts
72 lines (67 loc) · 1.47 KB
/
validate-Docs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import {
writeFile,
} from 'fs/promises';
import {
ValidationError,
} from './lib/DocsTsGenerator';
import {
NoMatchError,
} from './lib/Exceptions';
import {
docs,
} from './lib/helpers';
import {
setup_PerformanceObserver,
} from './setup_PerformanceObserver';
import {
__dirname_from_meta,
} from './lib/__dirname';
import {
versions,
} from './version-configs';
import {
FailedToCompileSchema,
} from '@satisfactory-dev/ajv-utilities';
const __dirname = __dirname_from_meta(import.meta);
setup_PerformanceObserver();
const version = 'update8';
const sub_path = versions.update8;
try {
await docs.get(version);
} catch (err) {
await writeFile(
`${__dirname}/failed-to-compile.${sub_path}.json`,
`${JSON.stringify({
err_is_Error: (err instanceof Error),
err_type: (
err instanceof Error
)
? err.constructor.name
: typeof err,
err_is_FailedToCompileSchema: (
(
err instanceof FailedToCompileSchema
&& err.err instanceof Error
)
? {
message: err.err?.message,
stack: err.err?.stack,
}
: 'nope'
),
err,
}, null, '\t')}\n`,
);
if (err instanceof ValidationError) {
for (const error of err.errors) {
process.stdout.write(JSON.stringify(error, null, '\t') + '\n');
}
} else if (err instanceof NoMatchError) {
const {property, ...rest} = err as NoMatchError;
delete rest.stack;
process.stdout.write(JSON.stringify(property, null, '\t') + '\n');
console.error(rest);
} else {
throw err;
}
}