build: update dependencies

This commit is contained in:
Michel Jonathan Schmitz
2020-01-22 09:22:13 +01:00
parent 25a795bc91
commit 8b3a8f929b
20 changed files with 785 additions and 691 deletions

View File

@@ -13,7 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Logger} from '@openstapps/logger';
import * as commander from 'commander';
import {Command} from 'commander';
import {existsSync, readFileSync, writeFileSync} from 'fs';
import * as got from 'got';
import {join, resolve} from 'path';
@@ -38,12 +38,16 @@ import {UMLConfig} from './uml/uml-config';
import {validateFiles, writeReport} from './validate';
// handle unhandled promise rejections
process.on('unhandledRejection', async (error: Error) => {
await Logger.error(error.message);
Logger.info(error.stack);
process.on('unhandledRejection', async (reason: unknown) => {
if (reason instanceof Error) {
await Logger.error(reason.message);
Logger.info(reason.stack);
}
process.exit(1);
});
const commander = new Command('openstapps-core-tools');
commander
.version(JSON.parse(
readFileSync(resolve(__dirname, '..', 'package.json'))

View File

@@ -14,7 +14,7 @@
*/
import {Logger} from '@openstapps/logger';
import {existsSync, mkdir, PathLike, readFile, unlink, writeFile} from 'fs';
import * as glob from 'glob';
import {Glob} from 'glob';
import {Schema as JSONSchema, ValidationError} from 'jsonschema';
import {platform} from 'os';
import {join, sep} from 'path';
@@ -23,7 +23,7 @@ import {Application, ProjectReflection} from 'typedoc';
import {promisify} from 'util';
import {LightweightType} from './uml/model/lightweight-type';
export const globPromisified = promisify(glob);
export const globPromisified = promisify(Glob);
export const mkdirPromisified = promisify(mkdir);
export const readFilePromisified = promisify(readFile);
export const writeFilePromisified = promisify(writeFile);

View File

@@ -13,7 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Logger} from '@openstapps/logger';
import * as deepmerge from 'deepmerge';
import merge from 'deepmerge';
import {stringify} from 'flatted';
import {DeclarationReflection, ProjectReflection} from 'typedoc';
import {
@@ -331,7 +331,7 @@ function handleUnionType(type: UnionType,
let out = list[0];
for (const item of list) {
out = deepmerge(out, item);
out = merge<ElasticsearchValue>(out, item);
}
return out;

View File

@@ -13,7 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Logger} from '@openstapps/logger';
import * as del from 'del';
import del from 'del';
import {existsSync} from 'fs';
import {basename, dirname, join} from 'path';
import {cwd} from 'process';
@@ -130,7 +130,7 @@ async function getAllTypeDefinitions(): Promise<string[]> {
],
});
const promises = fileNames.map(async (fileName) => {
const promises = fileNames.map(async (fileName: string) => {
return readFilePromisified(fileName, 'utf8');
});
@@ -241,7 +241,7 @@ async function getAllJavaScriptModules(): Promise<JavaScriptModule[]> {
],
});
const promises = fileNames.map(async (fileName) => {
const promises = fileNames.map(async (fileName: string) => {
const fileContent = await readFilePromisified(fileName, 'utf8');
const directory = dirname(fileName)
.replace(new RegExp(`^${join(cwd(), 'lib')}`), '');

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import * as Ajv from 'ajv';
import Ajv from 'ajv';
import {Schema as JSONSchema} from 'jsonschema';
import {join} from 'path';
import {DEFAULT_CONFIG, Definition, SchemaGenerator} from 'ts-json-schema-generator';

View File

@@ -102,7 +102,7 @@ export async function createDiagramFromString(
const url = `${plantUmlBaseURL}/svg/${plantUMLCode}`;
let response;
try {
response = await request(url);
response = await request.get(url);
const httpOK = 200;
if (response.statusCode !== httpOK) {
await Logger.error(`Plantuml Server responded with an error.\n${response.statusMessage}`);

View File

@@ -62,7 +62,7 @@ export class Validator {
Logger.log(`Adding schemas from ${schemaDir} to validator.`);
// tslint:disable-next-line:no-magic-numbers - iterate over schema files
await asyncPool(2, schemaFiles, async (file) => {
await asyncPool(2, schemaFiles, async (file: string) => {
// read schema file
const buffer = await readFilePromisified(file);
const schema = JSON.parse(buffer.toString());
@@ -139,7 +139,7 @@ export async function validateFiles(schemaDir: string, resourcesDir: string): Pr
const errors: ExpectableValidationErrors = {};
// tslint:disable-next-line:no-magic-numbers - iterate over files to test
await asyncPool(2, testFiles, async (testFile) => {
await asyncPool(2, testFiles, async (testFile: string) => {
const testFileName = basename(testFile);
const buffer = await readFilePromisified(join(resourcesDir, testFileName));
@@ -195,6 +195,7 @@ export async function validateFiles(schemaDir: string, resourcesDir: string): Pr
name: `expected ${error}`,
property: 'unknown',
schema: 'undefined',
stack: 'undefined',
});
}
} else if (unexpectedErrors === 0) {