zen-gitsync 1.2.7 → 1.2.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-gitsync",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "控制台输入g,回车,输入提交内容,自动执行git add+commit+push",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -31,7 +31,9 @@
31
31
  },
32
32
  "homepage": "https://github.com/xz333221/zen-gitsync#readme",
33
33
  "dependencies": {
34
+ "boxen": "^8.0.1",
34
35
  "chalk": "^5.4.1",
36
+ "cli-table3": "^0.6.5",
35
37
  "ora": "^8.1.1",
36
38
  "string-width": "^7.2.0"
37
39
  }
package/src/gitCommit.js CHANGED
@@ -6,6 +6,7 @@ import {coloredLog} from './utils/index.js';
6
6
  import readline from 'readline'
7
7
  import ora from 'ora';
8
8
  import chalk from 'chalk';
9
+ import boxen from 'boxen';
9
10
 
10
11
  let timer = null
11
12
 
@@ -109,7 +110,16 @@ class GitCommit {
109
110
  this.execGitCommand('git push', {
110
111
  spinner
111
112
  }, (error, stdout, stderr) => {
112
- console.log(chalk.green.bold('✔ SUCCESS: 提交完成。')); // 使用绿色对勾图标
113
+
114
+ // 使用 boxen 绘制带边框的消息
115
+ const message = chalk.green.bold(' SUCCESS: 提交完成 ');
116
+ const box = boxen(message, {
117
+ // borderStyle: 'round', // 方框的样式
118
+ // borderColor: 'whiteBright', // 边框颜色
119
+ // backgroundColor: 'black', // 背景颜色
120
+ });
121
+
122
+ console.log(box); // 打印带有边框的消息
113
123
  this.execSyncGitCommand(`git log -n 1 --pretty=format:"%B%n%h %d%n%ad" --date=iso`)
114
124
  this.exec_exit();
115
125
  })
@@ -15,6 +15,40 @@
15
15
  // const boxedMessage = boxen(message, options);
16
16
  // console.log(boxedMessage);
17
17
  import stringWidth from 'string-width';
18
+ import Table from 'cli-table3';
19
+ import chalk from 'chalk';
20
+
21
+ const printTableWithHeaderUnderline = () => {
22
+ // 获取终端的列数(宽度)
23
+ const terminalWidth = process.stdout.columns;
24
+
25
+ // 计算表格的宽度,保证至少有 2 个字符留给边框
26
+ const tableWidth = terminalWidth - 4; // 4 是左右边框和分隔符的宽度
27
+
28
+ // 计算每列的宽度
29
+ const colWidths = [tableWidth]; // 只有一列,因此宽度设置为终端宽度
30
+
31
+ const table = new Table({
32
+ head: ['Name'], // 只有一个表头
33
+ colWidths, // 使用动态计算的列宽
34
+ style: {
35
+ head: ['cyan'], // 表头文字颜色为cyan
36
+ border: ['yellow'], // 边框颜色为黄色
37
+ compact: true, // 启用紧凑模式,去掉不必要的空白
38
+ },
39
+ wordWrap: true, // 启用自动换行
40
+ });
41
+
42
+ // 向表格中添加不同颜色的行
43
+ table.push(
44
+ [chalk.red('张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三')],
45
+ [chalk.green('李四')],
46
+ );
47
+
48
+ console.log(table.toString()); // 输出表格
49
+ };
50
+
51
+ // printTableWithHeaderUnderline();
18
52
 
19
53
  const colors = [
20
54
  '\x1b[31m', // 红色