-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Enhanced error messages for better clarity and understanding.
- Loading branch information
1 parent
c9770d4
commit aa5f419
Showing
14 changed files
with
177 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import { ISSUES } from './github' | ||
|
||
export enum ErrorMessages { | ||
NotFound = "The package.json file wasn't found in the current directory.", | ||
export const ERROR_MESSAGES = { | ||
NotFound: "The package.json file wasn't found in the current directory.", | ||
|
||
Default = `Something went wrong, try again later, please try again later, if the error persists please report it on ${ISSUES}.`, | ||
Default: `Something went wrong, please try again later, if the error persists please report it on ${ISSUES}.`, | ||
|
||
Dependencies = `An error occurred while installing dependencies, please try again later, if the error persists please report it on ${ISSUES}.`, | ||
Dependencies: `An error occurred while installing dependencies, please try again later, if the error persists please report it on ${ISSUES}.`, | ||
|
||
Commitlint = `An error has occurred during the Commitlint configuration process, please try again later, if the error persists please report it on ${ISSUES}.`, | ||
Commitlint: `An error has occurred during the Commitlint configuration process, please try again later, if the error persists please report it on ${ISSUES}.`, | ||
Husky: `An error has occurred during the Husky configuration process, please try again later, if the error persists please report it on ${ISSUES}.`, | ||
|
||
Husky = `An error has occurred during the Husky configuration process, please try again later, if the error persists please report it on ${ISSUES}.` | ||
} | ||
PackageManagerSelection: `An error occurred while selecting the package manager, please try again later, if the error persists, please report it on ${ISSUES}.`, | ||
|
||
CommitlintSelection: `An error occurred while determining your choice for Commitlint, please try again later, if the error persists, please report it on ${ISSUES}.`, | ||
|
||
AddScript: `An error occurred while adding a script to the package.json file, please try again later, if the error persists, please report it on ${ISSUES}.`, | ||
|
||
CreateFolder: `An error occurred while creating the folder: {folderName}, please try again later, if the error persists, please report it on ${ISSUES}.`, | ||
|
||
CheckFileExists: `An error occurred while checking if the file/folder exists, please try again later, if the error persists, please report it on ${ISSUES}.` | ||
} as const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type MessageType = 'success' | 'error' | 'info' | 'config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Third-Party libraries | ||
import chalk from 'chalk' | ||
|
||
// Constants | ||
import type { ERROR_MESSAGES } from '@/constants/errors' | ||
|
||
// Types | ||
import type { MessageType } from '@/types/message' | ||
|
||
interface Props { | ||
type: MessageType | ||
message: typeof ERROR_MESSAGES | string | ||
} | ||
|
||
export function writeMessage({ type, message }: Props) { | ||
if (type === 'success') console.log(chalk.green(message)) | ||
if (type === 'info') console.log(chalk.blue(message)) | ||
if (type === 'error') console.log(chalk.red(message)) | ||
if (type === 'config') console.log(chalk.white(message)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ERROR_MESSAGES } from '@/constants/errors' | ||
|
||
export function getErrorMessage(error: keyof typeof ERROR_MESSAGES) { | ||
return ERROR_MESSAGES[error] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.