Skip to content

Commit

Permalink
removed @colours
Browse files Browse the repository at this point in the history
  • Loading branch information
John Carmichael committed Dec 30, 2023
1 parent ba7706f commit 1f00845
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 32 deletions.
13 changes: 2 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "boats",
"version": "4.9.4",
"version": "4.10.0",
"description": "Beautiful Open / Async Template System - Write less yaml with BOATS and Nunjucks.",
"keywords": [
"asyncapi",
Expand Down Expand Up @@ -65,7 +65,6 @@
"@apidevtools/json-schema-ref-parser": "11.1.0",
"@apidevtools/swagger-parser": "10.1.0",
"@asyncapi/parser": "3.0.2",
"@colors/colors": "1.6.0",
"commander": "11.1.0",
"deepmerge": "4.3.1",
"dotenv": "16.3.1",
Expand Down
36 changes: 17 additions & 19 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import '@colors/colors'
import fs from 'fs-extra';
import upath from 'upath';
import bundlerSwaggerParse from '@/bundlerSwaggerParse';
Expand All @@ -12,6 +11,7 @@ import { BoatsRC } from '@/interfaces/BoatsRc';
import Snippets from '@/Snippets';
import { init } from './init';
import tmpFolderRemove from '@/tmpFolderRemove';
import { LOG_GREEN, LOG_GREEN_BOLD, LOG_RED, LOG_RED_BOLD } from '@/constants';

const dotenvFilePath = upath.join(process.cwd(), '.env');

Expand Down Expand Up @@ -76,54 +76,52 @@ const parseCli = async () => {

tmpFolderRemove(upath.dirname(pathWrittenTo));

console.log('Completed, the files were rendered, validated and bundled to: '.green + pathWrittenTo.green.bold);
console.log(LOG_GREEN, 'Completed, the files were rendered, validated and bundled to: ');
console.log(LOG_GREEN_BOLD, pathWrittenTo);
}
};

const catchHandle = (error: any) => {
const line = '----------------------'.red;
const printed = error.stack || error.details || error.name;
const line = '----------------------';
const printed = error.stack || error.details || error.name || undefined;
if (error.stack) {
console.error('');
console.error(line);
console.error('ERROR.STACK: '.red.bold);
console.error(line);
console.error(error.stack.red);
console.error(LOG_RED, line);
console.error(LOG_RED_BOLD, 'ERROR.STACK: ');
console.error(LOG_RED, line);
console.error(LOG_RED, error.stack);
console.error('');
if (
String(error.stack).includes('Cannot read property \'stack\' of undefined') ||
String(error.stack).includes('There were errors validating the AsyncAPI document')
) {
console.log('TIP: An non-helpful error message from SwaggerParser or @asyncapi/parser is typically caused by invalid openapi or async api syntax not handled by them; it can often be invalid use of the combine keywords such as "allOf".'.red);
console.log(LOG_RED, 'TIP: An non-helpful error message from SwaggerParser or @asyncapi/parser is typically caused by invalid openapi or async api syntax not handled by them; it can often be invalid use of the combine keywords such as "allOf".');
}
console.error('');
console.error('');
}

if (error.details) {
console.error(LOG_RED, line);
console.error(LOG_RED_BOLD, 'ERROR.DETAILS: ');
console.error(line);
console.error('ERROR.DETAILS: '.red.bold);
console.error(line);
console.error(JSON.stringify(error.details, null, 2).red);
console.error(LOG_RED, JSON.stringify(error.details, null, 2));
console.error('');
console.error('');
console.error('');
}

if (error.name) {
console.error('ERROR.NAME: '.red.bold, JSON.stringify(error.name).red);
console.error(LOG_RED_BOLD, 'ERROR.NAME: ');
console.log(LOG_RED, JSON.stringify(error.name));
}

console.error('Tip: '.red.bold, 'Scroll up in this terminal window for more errors and hints'.red);
console.error(LOG_RED, 'Tip: Scroll up in this terminal window for more errors and hints');

if (!printed) {
if (printed === undefined) {
console.trace(error);
}

if (error.name) {

}

process.exit(1);
};

Expand Down
5 changes: 5 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export const METHODS = ['get', 'post', 'put', 'update', 'patch', 'delete'];
export const TMP_COMPILED_DIR_NAME = '.boats_tmp_dir'
export const GIT_DIRECTORY_SNIPPET_CACHE = '.boats-snippet-cache';

export const LOG_GREEN = '\'\u001b[32m%s\u001b[0m\''
export const LOG_GREEN_BOLD = '\u001b[32m\u001b[1m%s\u001b[0m'
export const LOG_RED = '\u001b[31m%s\u001b[0m'
export const LOG_RED_BOLD = '\u001b[31m\u001b[1m%s\u001b[0m'

0 comments on commit 1f00845

Please sign in to comment.