youmna-git-glance 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +49 -0
  2. package/package.json +8 -0
package/index.js ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { simpleGit } from 'simple-git';
4
+ import chalk from 'chalk';
5
+ import boxen from 'boxen';
6
+ import ora from 'ora';
7
+
8
+ const git = simpleGit();
9
+
10
+ async function showGitStats() {
11
+ const spinner = ora('Fetching Git Info...').start();
12
+
13
+ try {
14
+ const isRepo = await git.checkIsRepo();
15
+ if (!isRepo) {
16
+ spinner.fail(chalk.red('Error: Not a git repository!'));
17
+ return;
18
+ }
19
+
20
+ const status = await git.status();
21
+ const log = await git.log({ n: 1 });
22
+ const remote = await git.getRemotes(true);
23
+
24
+ spinner.stop();
25
+
26
+ const stats = `
27
+ ${chalk.cyan.bold('Branch:')} ${chalk.white(status.current)}
28
+ ${chalk.green.bold('Latest:')} ${chalk.white(log.latest.message)}
29
+ ${chalk.yellow.bold('Author:')} ${chalk.white(log.latest.author_name)}
30
+ ${chalk.magenta.bold('Changes:')} ${chalk.white(status.files.length + ' files modified')}
31
+ ${chalk.blue.bold('Remote:')} ${chalk.white(remote[0]?.refs.fetch || 'None')}
32
+ `;
33
+
34
+ console.log(boxen(stats, {
35
+ padding: 1,
36
+ margin: 1,
37
+ borderStyle: 'round',
38
+ title: 'Git Glance Dashboard',
39
+ titleAlignment: 'center',
40
+ borderColor: 'cyan'
41
+ }));
42
+
43
+ } catch (error) {
44
+ spinner.fail(chalk.red('Something went wrong!'));
45
+ console.error(error);
46
+ }
47
+ }
48
+
49
+ showGitStats();
package/package.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "youmna-git-glance",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "bin": {
6
+ "git-glance": "./index.js"
7
+ }
8
+ }