diff --git a/cli/src/index.ts b/cli/src/index.ts index 2e9e3f39..ddd79651 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -64,7 +64,7 @@ program .option(OUTPUT_OPTION, 'Path location at which to output the generated file.') .option(VERBOSE_OPTION, 'Enable verbose logging.', false) .action(async (options) => { - const outcome = await validate(options.instantiation, options.pattern, options.metaSchemasLocation, options.verbose); + const outcome = await validate(options.instantiation, options.pattern, options.schemaDirectory, options.verbose); const content = getFormattedOutput(outcome, options.format, options.instantiation, options.pattern); writeOutputFile(options.output, content); exitBasedOffOfValidationOutcome(outcome, options.strict); diff --git a/shared/package.json b/shared/package.json index 75d8816f..f2eea80c 100644 --- a/shared/package.json +++ b/shared/package.json @@ -15,8 +15,8 @@ "test": "jest --verbose", "lint": "eslint src --config ./.eslintrc.json", "lint-fix": "eslint src -- --fix", - "copy-calm-schema": "copyfiles ../calm/draft/2024-04/meta/* dist/calm/", - "copy-spectral-rules": "copyfiles ../spectral/**/* dist/spectral/", + "copy-calm-schema": "copyfiles \"../calm/draft/2024-04/meta/*\" dist/calm/", + "copy-spectral-rules": "copyfiles \"../spectral/**/*\" dist/spectral/", "copy-calm-schema-old": "mkdir -p dist/calm && cp -r ../calm/draft/2024-04/meta dist/calm/", "dependency-check": "dependency-check --project 'calm-shared' --scan . --out ./dependency-check-report --format ALL --suppression ../.github/node-cve-ignore-list.xml" }, diff --git a/shared/src/commands/generate/schema-directory.ts b/shared/src/commands/generate/schema-directory.ts index 5172bf7a..6956ec08 100644 --- a/shared/src/commands/generate/schema-directory.ts +++ b/shared/src/commands/generate/schema-directory.ts @@ -50,7 +50,7 @@ export class SchemaDirectory { this.logger.info(`Loaded ${this.schemas.size} schemas.`); } catch (err) { if (err.code === 'ENOENT') { - this.logger.error('Schema Path not found!'); + this.logger.error('Schema Path not found: ', dir, ', error: ', err); } else { this.logger.error(err); } diff --git a/shared/src/commands/helper.ts b/shared/src/commands/helper.ts index 42147fec..de59197d 100644 --- a/shared/src/commands/helper.ts +++ b/shared/src/commands/helper.ts @@ -7,6 +7,15 @@ export function initLogger(debug: boolean): winston.Logger { new winston.transports.Console() ], level: level, - format: winston.format.cli(), + format: winston.format.combine( + winston.format.cli(), + winston.format.errors({ stack: true }), + winston.format.printf(({ level, message, stack }) => { + if (stack) { + return `${level}: ${message} - ${stack}`; + } + return `${level}: ${message}`; + }), + ) }); } \ No newline at end of file diff --git a/shared/src/commands/validate/validate.ts b/shared/src/commands/validate/validate.ts index 40d066d6..1236d370 100644 --- a/shared/src/commands/validate/validate.ts +++ b/shared/src/commands/validate/validate.ts @@ -331,7 +331,7 @@ export async function validate( return new ValidationOutcome(jsonSchemaValidations, spectralResult.spectralIssues, errors, warnings); } catch (error) { - logger.error(`An error occured: ${error}`); + logger.error('An error occured:', error); process.exit(1); } } diff --git a/shared/src/consts.ts b/shared/src/consts.ts index 6a60eb5a..1cd9f1da 100644 --- a/shared/src/consts.ts +++ b/shared/src/consts.ts @@ -1,2 +1,2 @@ -export const CALM_META_SCHEMA_DIRECTORY = __dirname + '/calm/meta'; +export const CALM_META_SCHEMA_DIRECTORY = __dirname + '/calm/draft'; export const CALM_SPECTRAL_RULES_DIRECTORY = __dirname + '/spectral'; \ No newline at end of file