Skip to content

Commit

Permalink
style(commit.ts): update color scheme for better visibility
Browse files Browse the repository at this point in the history
- Changed INFO background color from blue to hex `#1640D6` for consistency.
- Updated SUCCESS background color to hex `#3EC70B` for better visibility.
- WARNING background color changed to hex `#FF6000` for a clearer warning indication.
- ERROR messages now have a background color of hex `#FF0303` for a more standard error color.
- Developer credit background color updated to hex `#12486B` for aesthetic improvement.

These changes enhance the readability and visual appeal of the CLI output by using a consistent and more accessible color scheme.
  • Loading branch information
SHSharkar committed Nov 25, 2023
1 parent f1c339f commit a4ddf0f
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions src/commands/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const checkMessageTemplate = (extraArgs: string[]): string | false => {
const generateCommitMessageFromGitDiff = async (diff: string, extraArgs: string[]): Promise<void> => {
await assertGitRepo();
const commitSpinner = spinner();
commitSpinner.start(`${chalk.black.bold.bgBlue(` INFO `)} Generating the commit message...`);
commitSpinner.start(`${chalk.hex('#ffffff').bold.bgHex('#1640D6')(` INFO `)} Generating the commit message...`);

const startTime = new Date();

Expand Down Expand Up @@ -66,7 +66,7 @@ ${chalk.grey('——————————————————————
if (isCommitConfirmedByUser && !isCancel(isCommitConfirmedByUser)) {
const { stdout } = await execa('git', ['commit', '-m', commitMessage, ...extraArgs]);

outro(`${chalk.bold.hex('#ffffff').bgGreen(` SUCCESS `)} Successfully committed changes.`);
outro(`${chalk.bold.hex('#ffffff').bgHex('#3EC70B')(` SUCCESS `)} Successfully committed changes.`);

outro(stdout);

Expand All @@ -87,26 +87,26 @@ ${chalk.grey('——————————————————————
const pushSpinner = spinner();

pushSpinner.start(
`${chalk.black.bold.bgBlue(` INFO `)} Running ${chalk.black.bold.bgBlue(
`${chalk.hex('#ffffff').bold.bgHex('#1640D6')(` INFO `)} Running ${chalk.black.bold.bgBlue(
` git push ${remotes[0]} `,
)}`,
);

const { stdout } = await execa('git', ['push', '--verbose', remotes[0]]);

pushSpinner.stop(
`${chalk
.hex('#ffffff')
.bold.bgGreen(` SUCCESS `)} Successfully pushed all commits to ${chalk.bold
.hex('#ffffff')
.bgGreen(` ${remotes[0]} `)}.`,
`${chalk.hex('#ffffff').bold.bgHex('#3EC70B')(
` SUCCESS `,
)} Successfully pushed all commits to ${chalk.bold.hex('#ffffff').bgHex('#3EC70B')(
` ${remotes[0]} `,
)}.`,
);

// eslint-disable-next-line max-depth
if (stdout) outro(stdout);
} else {
outro(
`${chalk.bold.inverse.hex('#FFA500')(` WARNING `)} 'git push' aborted - Operation cancelled.`,
`${chalk.bold.inverse.hex('#FF6000')(` WARNING `)} 'git push' aborted - Operation cancelled.`,
);
process.exit(0);
}
Expand All @@ -120,38 +120,38 @@ ${chalk.grey('——————————————————————
const pushSpinner = spinner();

pushSpinner.start(
`${chalk.black.bold.bgBlue(` INFO `)} Running ${chalk.black.bold.bgBlue(
`${chalk.hex('#ffffff').bold.bgHex('#1640D6')(` INFO `)} Running ${chalk.black.bold.bgBlue(
` git push ${selectedRemote} `,
)}`,
);

const { stdout } = await execa('git', ['push', selectedRemote]);

pushSpinner.stop(
`${chalk
.hex('#ffffff')
.bold.bgGreen(` SUCCESS `)} Successfully pushed all commits to ${chalk.bold
.hex('#ffffff')
.bgGreen(` ${selectedRemote} `)}.`,
`${chalk.hex('#ffffff').bold.bgHex('#3EC70B')(
` SUCCESS `,
)} Successfully pushed all commits to ${chalk.bold.hex('#ffffff').bgHex('#3EC70B')(
` ${selectedRemote} `,
)}.`,
);

// eslint-disable-next-line max-depth
if (stdout) outro(stdout);
} else outro(`${chalk.bold.inverse.hex('#FFA500')(` WARNING `)} process cancelled`);
} else outro(`${chalk.bold.inverse.hex('#FF6000')(` WARNING `)} process cancelled`);
}
} else {
outro(
`${chalk.bold.inverse.hex('#FFA500')(
`${chalk.bold.inverse.hex('#FF6000')(
` WARNING `,
)} Commit Aborted - The commit message was not confirmed. Operation cancelled.`,
);
process.exit(0);
}
} catch (error) {
commitSpinner.stop(`${chalk.black.bold.bgBlue(` INFO `)} Commit message generated.`);
commitSpinner.stop(`${chalk.hex('#ffffff').bold.bgHex('#1640D6')(` INFO `)} Commit message generated.`);

const err = error as Error;
outro(`${chalk.hex('#ffffff').bold.bgRed(` ERROR `)} ${err?.message || err}`);
outro(`${chalk.hex('#ffffff').bold.bgHex('#FF0303')(` ERROR `)} ${err?.message || err}`);
process.exit(1);
}
};
Expand All @@ -164,8 +164,8 @@ export async function commit(extraArgs: string[] = [], isStageAllFlag: boolean =
if (changedFiles) await gitAdd({ files: changedFiles });
else {
outro(
chalk.hex('#FFA500')(
`${chalk.bold.inverse.hex('#FFA500')(
chalk.hex('#FF6000')(
`${chalk.bold.inverse.hex('#FF6000')(
` WARNING `,
)} No changes detected, write some code and run 'gw' again`,
),
Expand All @@ -179,8 +179,8 @@ export async function commit(extraArgs: string[] = [], isStageAllFlag: boolean =

if (!changedFiles?.length && !stagedFiles?.length) {
outro(
chalk.hex('#FFA500')(
`${chalk.bold.inverse.hex('#FFA500')(
chalk.hex('#FF6000')(
`${chalk.bold.inverse.hex('#FF6000')(
` WARNING `,
)} No changes detected, write some code and run 'gw' again`,
),
Expand All @@ -189,17 +189,18 @@ export async function commit(extraArgs: string[] = [], isStageAllFlag: boolean =
}

intro(`
${chalk.bold.inverse.hex('#FFA500')(` GitWiz ${pkgJson.version} `)}${chalk.italic.dim(
${chalk.bold.inverse.hex('#FF6000')(` GitWiz ${pkgJson.version} `)}${chalk.italic.dim(
` Use AI to Enhance Your Git Commits `,
)}
${chalk.inverse.bold.hex('#45CFDD')(` Developed By `)} ${chalk.bold('Md. Sazzad Hossain Sharkar')} (${chalk.underline(
'https://github.com/SHSharkar',
)})
${chalk.hex('#ffffff').bold.bgHex('#12486B')(` Developed By `)} ${chalk.bold(
'Md. Sazzad Hossain Sharkar',
)} (${chalk.underline('https://github.com/SHSharkar')})
${chalk.yellow('Preparing to commit changes...')}`);

if (errorChangedFiles ?? errorStagedFiles) {
outro(`${chalk.hex('#ffffff').bold.bgRed(` ERROR `)} ${errorChangedFiles ?? errorStagedFiles}`);
outro(`${chalk.hex('#ffffff').bold.bgHex('#FF0303')(` ERROR `)} ${errorChangedFiles ?? errorStagedFiles}`);
process.exit(1);
}

Expand All @@ -208,7 +209,7 @@ ${chalk.yellow('Preparing to commit changes...')}`);
stagedFilesSpinner.start('Counting staged files...');

if (!stagedFiles.length) {
stagedFilesSpinner.stop(`${chalk.bold.black.bgBlue(` INFO `)} No staged files found.`);
stagedFilesSpinner.stop(`${chalk.bold.hex('#ffffff').bgHex('#1640D6')(` INFO `)} No staged files found.`);
const isStageAllAndCommitConfirmedByUser = await confirm({
message: 'Do you want to stage all files and generate commit message?',
});
Expand Down Expand Up @@ -249,7 +250,7 @@ ${chalk.yellow('Preparing to commit changes...')}`);
);

if (generateCommitError) {
outro(`${chalk.hex('#ffffff').bold.bgRed(` ERROR `)} ${generateCommitError}`);
outro(`${chalk.hex('#ffffff').bold.bgHex('#FF0303')(` ERROR `)} ${generateCommitError}`);
process.exit(1);
}

Expand Down

0 comments on commit a4ddf0f

Please sign in to comment.