mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 01:22:54 +00:00
refactor: update dependencies and fix resulting errors
Upgraded JSON Schema from version 6 to version 7 Upgraded TypeDoc version to latest Replaced 'jsonschema' with 'json-schema' package to better comply with 'ts-json-schema-generator' Replace JSON Schema validation with AJV in areas where it wasn't used previously Removed commander help output as it causes strange issues
This commit is contained in:
committed by
Rainer Killinger
parent
b7cdb6a9ad
commit
5330255b7e
@@ -15,11 +15,12 @@
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {existsSync, mkdir, PathLike, readFile, unlink, writeFile} from 'fs';
|
||||
import {Glob} from 'glob';
|
||||
import {Schema as JSONSchema, ValidationError} from 'jsonschema';
|
||||
import {JSONSchema7 as JSONSchema} from 'json-schema';
|
||||
import {platform} from 'os';
|
||||
import {join, sep} from 'path';
|
||||
import {Definition} from 'ts-json-schema-generator';
|
||||
import {Application, ProjectReflection} from 'typedoc';
|
||||
import {ModuleKind, ScriptTarget} from 'typescript';
|
||||
import {promisify} from 'util';
|
||||
import {LightweightType} from './uml/model/lightweight-type';
|
||||
|
||||
@@ -122,9 +123,67 @@ interface SchemaWithDefinitions extends JSONSchema {
|
||||
}
|
||||
|
||||
/**
|
||||
* An expectable error
|
||||
* The validation result
|
||||
*/
|
||||
export interface ExpectableValidationError extends ValidationError {
|
||||
export interface ValidationResult {
|
||||
/**
|
||||
* A list of errors that occurred
|
||||
*/
|
||||
errors: ValidationError[];
|
||||
|
||||
/**
|
||||
* whether the validation was successful
|
||||
*/
|
||||
valid: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* An error that occurred while validating
|
||||
*
|
||||
* This is a duplicate of the ValidationError in core/protocol/errors/validation because of incompatibilities
|
||||
* between TypeDoc and TypeScript
|
||||
*/
|
||||
export interface ValidationError {
|
||||
/**
|
||||
* JSON schema path
|
||||
*/
|
||||
dataPath: string;
|
||||
|
||||
/**
|
||||
* The instance
|
||||
*/
|
||||
instance: unknown;
|
||||
|
||||
/**
|
||||
* The message
|
||||
*
|
||||
* Provided by https://www.npmjs.com/package/better-ajv-errors
|
||||
*/
|
||||
message: string;
|
||||
|
||||
/**
|
||||
* Name of the error
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Path within the Schema
|
||||
*/
|
||||
schemaPath: string;
|
||||
|
||||
/**
|
||||
* Suggestion to fix the occurring error
|
||||
*
|
||||
* Provided by https://www.npmjs.com/package/better-ajv-errors
|
||||
*/
|
||||
suggestion?: string;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An expected error
|
||||
*/
|
||||
export interface ExpectedValidationError extends ValidationError {
|
||||
/**
|
||||
* Whether or not the error is expected
|
||||
*/
|
||||
@@ -132,10 +191,10 @@ export interface ExpectableValidationError extends ValidationError {
|
||||
}
|
||||
|
||||
/**
|
||||
* A map of files and their expectable validation errors
|
||||
* A map of files and their expected validation errors
|
||||
*/
|
||||
export interface ExpectableValidationErrors {
|
||||
[fileName: string]: ExpectableValidationError[];
|
||||
export interface ExpectedValidationErrors {
|
||||
[fileName: string]: ExpectedValidationError[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,10 +209,14 @@ export function getProjectReflection(srcPath: PathLike, excludeExternals = true)
|
||||
const tsconfigPath = getTsconfigPath(srcPath.toString());
|
||||
|
||||
// initialize new Typedoc application
|
||||
const app = new Application({
|
||||
const app = new Application();
|
||||
|
||||
app.options.setValues({
|
||||
excludeExternals: excludeExternals,
|
||||
ignoreCompilerErrors: false, // TODO: true
|
||||
includeDeclarations: true,
|
||||
module: 'commonjs',
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.Latest,
|
||||
tsconfig: join(tsconfigPath, 'tsconfig.json'),
|
||||
});
|
||||
|
||||
@@ -194,10 +257,11 @@ export function isSchemaWithDefinitions(
|
||||
*/
|
||||
export function isThingWithType(thing: unknown): thing is { type: string; } {
|
||||
return typeof thing === 'object' &&
|
||||
thing !== null &&
|
||||
'type' in thing &&
|
||||
typeof (thing as { type: string; }).type === 'string';
|
||||
thing !== null &&
|
||||
'type' in thing &&
|
||||
typeof (thing as { type: unknown; }).type === 'string';
|
||||
}
|
||||
|
||||
// tslint:enable: completed-docs
|
||||
|
||||
/**
|
||||
@@ -233,16 +297,16 @@ export function getTsconfigPath(startPath: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a comma seperated string into a string array
|
||||
* Converts a comma separated string into a string array
|
||||
*
|
||||
* @param val Comma seperated string
|
||||
* @param val Comma separated string
|
||||
*/
|
||||
export function toArray(val: string): string[] {
|
||||
return val.split(',');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the full name of a lightweight type recursivly
|
||||
* Creates the full name of a lightweight type recursively
|
||||
*
|
||||
* @param type Type to get the full name of
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user