Skip to content

Commit

Permalink
make console outputs error
Browse files Browse the repository at this point in the history
  • Loading branch information
FroggyPanda committed Mar 18, 2024
1 parent d7d074d commit 0fae1ff
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ module.exports = {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {},
rules: {
'no-console': 'error',
},
};
1 change: 1 addition & 0 deletions src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export async function generate(
const sourceFile = project.addSourceFileAtPath(input);

if (!exists) {
// eslint-disable-next-line no-console
console.error(`${chalk.red.bold('error')} Input file not found`);
return;
}
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ if (configExists) {
// Check if config is correct
const result = schema.safeParse(json);
if (!result.success) {
// eslint-disable-next-line no-console
console.log('Invalid config file');
} else {
if (!result.data.output && !result.data.force) {
// eslint-disable-next-line no-console
console.log(
'It looks like you want to overwrite your input file. Add the force property to do that in your config file.'
);
Expand All @@ -52,9 +54,11 @@ if (configExists) {
// Check if config is correct
const result = schema.safeParse(packageJsonFile['betterConfig']);
if (!result.success) {
// eslint-disable-next-line no-console
console.log('Invalid config in package.json');
} else {
if (!result.data.output && !result.data.force) {
// eslint-disable-next-line no-console
console.log(
'It looks like you want to overwrite your input file. Add the force property to do that in your config file.'
);
Expand Down Expand Up @@ -127,6 +131,7 @@ if (configExists) {
},
(argv) => {
if (!argv.output && !argv.force) {
// eslint-disable-next-line no-console
console.error(
'It looks like you want to overwrite your input file. Add the force flag to do that.'
);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/getEnumsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function getEnumsProperties(project, sourceFile, schema) {
.find((property) => property.getName() === 'Enums');

if (!enumsProperty) {
// eslint-disable-next-line no-console
console.log(
`${chalk.yellow.bold(
'warn'
Expand All @@ -35,6 +36,7 @@ export function getEnumsProperties(project, sourceFile, schema) {
const enumsProperties = enumsType.getProperties();

if (enumsProperties.length < 1) {
// eslint-disable-next-line no-console
console.log(
`${chalk.yellow.bold(
'warn'
Expand Down
2 changes: 2 additions & 0 deletions src/utils/getFunctionProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function getFunctionReturnTypes(project, sourceFile, schema) {
.find((property) => property.getName() === 'Functions');

if (!functionProperty) {
// eslint-disable-next-line no-console
console.log(
`${chalk.yellow.bold(
'warn'
Expand All @@ -32,6 +33,7 @@ export function getFunctionReturnTypes(project, sourceFile, schema) {
const functionProperties = functionType.getProperties();

if (functionProperties.length < 1) {
// eslint-disable-next-line no-console
console.log(
`${chalk.yellow.bold(
'warn'
Expand Down
2 changes: 2 additions & 0 deletions src/utils/getTablesProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function getTablesProperties(project, sourceFile, schema) {
.find((property) => property.getName() === 'Tables');

if (!tablesProperty) {
// eslint-disable-next-line no-console
console.log(
`${chalk.yellow.bold(
'warn'
Expand All @@ -32,6 +33,7 @@ export function getTablesProperties(project, sourceFile, schema) {
const tablesProperties = tablesType.getProperties();

if (tablesProperties.length < 1) {
// eslint-disable-next-line no-console
console.log(
`${chalk.yellow.bold(
'warn'
Expand Down
2 changes: 2 additions & 0 deletions src/utils/getViewsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function getViewsProperties(project, sourceFile, schema) {
.find((property) => property.getName() === 'Views');

if (!viewsProperty) {
// eslint-disable-next-line no-console
console.log(
`${chalk.yellow.bold(
'warn'
Expand All @@ -32,6 +33,7 @@ export function getViewsProperties(project, sourceFile, schema) {
const viewsProperties = viewsType.getProperties();

if (viewsProperties.length < 1) {
// eslint-disable-next-line no-console
console.log(
`No views found within the Views property for schema ${schema}.`
);
Expand Down

0 comments on commit 0fae1ff

Please sign in to comment.