git-er-done 0.1.20 → 0.1.23
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": "git-er-done",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "Utility for dealing with modified, created, deleted files since a git commit",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"README.md"
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
|
+
"@davidwells/git-split-diffs": "^2.2.5",
|
|
80
81
|
"debug": "^4.1.1",
|
|
81
82
|
"json5": "^2.1.1",
|
|
82
83
|
"jsonpointer": "^5.0.1",
|
|
@@ -95,7 +96,6 @@
|
|
|
95
96
|
},
|
|
96
97
|
"devDependencies": {
|
|
97
98
|
"@davidwells/extract-deps": "^0.0.6",
|
|
98
|
-
"@davidwells/git-split-diffs": "^2.2.1",
|
|
99
99
|
"@types/node": "^22.10.1",
|
|
100
100
|
"configorama": "^0.7.1",
|
|
101
101
|
"minimatch": "^10.0.1",
|
|
@@ -51,6 +51,12 @@ function getLongestLineLength(diff) {
|
|
|
51
51
|
return maxLength
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {Object} FormattedDiffResult
|
|
56
|
+
* @property {string} formatted - Terminal-formatted diff with colors
|
|
57
|
+
* @property {string} raw - Raw unified diff from git
|
|
58
|
+
*/
|
|
59
|
+
|
|
54
60
|
/**
|
|
55
61
|
* Get formatted diff for a specific file
|
|
56
62
|
* @param {Object} options - Options for getting formatted diff
|
|
@@ -62,7 +68,11 @@ function getLongestLineLength(diff) {
|
|
|
62
68
|
* @param {number} [options.leftMargin=0] - Number of spaces to add to the left of each line
|
|
63
69
|
* @param {number} [options.width=140] - Width of the diff output (ignored if shrinkToLongestLine is true)
|
|
64
70
|
* @param {boolean} [options.hideHeader=false] - Remove the file path header from the diff
|
|
65
|
-
* @
|
|
71
|
+
* @param {boolean} [options.hideFileHeader=false] - Hide file header (passed to formatDiff)
|
|
72
|
+
* @param {boolean} [options.hideHeaderTopLine=false] - Hide header top line (passed to formatDiff)
|
|
73
|
+
* @param {boolean} [options.disableDefaultBackground=false] - Disable default background colors (passed to formatDiff)
|
|
74
|
+
* @param {boolean} [options.returnRaw=false] - Return both formatted and raw diff
|
|
75
|
+
* @returns {Promise<string | FormattedDiffResult | null>} Formatted diff string, or {formatted, raw} if returnRaw, or null if no diff
|
|
66
76
|
*/
|
|
67
77
|
async function getFormattedDiff({
|
|
68
78
|
filePath,
|
|
@@ -72,7 +82,11 @@ async function getFormattedDiff({
|
|
|
72
82
|
shrinkToLongestLine = false,
|
|
73
83
|
leftMargin = 0,
|
|
74
84
|
width = 140,
|
|
75
|
-
hideHeader = false
|
|
85
|
+
hideHeader = false,
|
|
86
|
+
hideFileHeader = false,
|
|
87
|
+
hideHeaderTopLine = false,
|
|
88
|
+
disableDefaultBackground = false,
|
|
89
|
+
returnRaw = false
|
|
76
90
|
}) {
|
|
77
91
|
try {
|
|
78
92
|
const { formatDiff } = await import('@davidwells/git-split-diffs')
|
|
@@ -107,10 +121,6 @@ async function getFormattedDiff({
|
|
|
107
121
|
|
|
108
122
|
// Format the diff with git-split-diffs
|
|
109
123
|
let formatted = await formatDiff(diff, {
|
|
110
|
-
// hyperlinkFileNames: false,
|
|
111
|
-
// hyperlinkLineNumbers: false,
|
|
112
|
-
// hideFileHeader: true,
|
|
113
|
-
// omitHunkHeaders: true,
|
|
114
124
|
trimLastEmptyLine: true,
|
|
115
125
|
width: maxWidth,
|
|
116
126
|
minLineWidth: 80,
|
|
@@ -118,6 +128,9 @@ async function getFormattedDiff({
|
|
|
118
128
|
highlightLineChanges: true,
|
|
119
129
|
themeName: 'dark',
|
|
120
130
|
gitRootDir,
|
|
131
|
+
hideFileHeader,
|
|
132
|
+
hideHeaderTopLine,
|
|
133
|
+
disableDefaultBackground,
|
|
121
134
|
})
|
|
122
135
|
|
|
123
136
|
// Remove header if hideHeader is true
|
|
@@ -130,9 +143,12 @@ async function getFormattedDiff({
|
|
|
130
143
|
// Add left margin if specified
|
|
131
144
|
if (leftMargin > 0) {
|
|
132
145
|
const margin = ' '.repeat(leftMargin)
|
|
133
|
-
|
|
146
|
+
formatted = formatted.split('\n').map(line => margin + line).join('\n')
|
|
134
147
|
}
|
|
135
148
|
|
|
149
|
+
if (returnRaw) {
|
|
150
|
+
return { formatted, raw: diff }
|
|
151
|
+
}
|
|
136
152
|
return formatted
|
|
137
153
|
} catch (err) {
|
|
138
154
|
console.error(`Error formatting diff for ${filePath}:`, err.message)
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
export type FormattedDiffResult = {
|
|
2
|
+
/**
|
|
3
|
+
* - Terminal-formatted diff with colors
|
|
4
|
+
*/
|
|
5
|
+
formatted: string;
|
|
6
|
+
/**
|
|
7
|
+
* - Raw unified diff from git
|
|
8
|
+
*/
|
|
9
|
+
raw: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} FormattedDiffResult
|
|
13
|
+
* @property {string} formatted - Terminal-formatted diff with colors
|
|
14
|
+
* @property {string} raw - Raw unified diff from git
|
|
15
|
+
*/
|
|
1
16
|
/**
|
|
2
17
|
* Get formatted diff for a specific file
|
|
3
18
|
* @param {Object} options - Options for getting formatted diff
|
|
@@ -9,9 +24,13 @@
|
|
|
9
24
|
* @param {number} [options.leftMargin=0] - Number of spaces to add to the left of each line
|
|
10
25
|
* @param {number} [options.width=140] - Width of the diff output (ignored if shrinkToLongestLine is true)
|
|
11
26
|
* @param {boolean} [options.hideHeader=false] - Remove the file path header from the diff
|
|
12
|
-
* @
|
|
27
|
+
* @param {boolean} [options.hideFileHeader=false] - Hide file header (passed to formatDiff)
|
|
28
|
+
* @param {boolean} [options.hideHeaderTopLine=false] - Hide header top line (passed to formatDiff)
|
|
29
|
+
* @param {boolean} [options.disableDefaultBackground=false] - Disable default background colors (passed to formatDiff)
|
|
30
|
+
* @param {boolean} [options.returnRaw=false] - Return both formatted and raw diff
|
|
31
|
+
* @returns {Promise<string | FormattedDiffResult | null>} Formatted diff string, or {formatted, raw} if returnRaw, or null if no diff
|
|
13
32
|
*/
|
|
14
|
-
export function getFormattedDiff({ filePath, gitRootDir, cwd, baseBranch, shrinkToLongestLine, leftMargin, width, hideHeader }: {
|
|
33
|
+
export function getFormattedDiff({ filePath, gitRootDir, cwd, baseBranch, shrinkToLongestLine, leftMargin, width, hideHeader, hideFileHeader, hideHeaderTopLine, disableDefaultBackground, returnRaw }: {
|
|
15
34
|
filePath: string;
|
|
16
35
|
gitRootDir?: string;
|
|
17
36
|
cwd?: string;
|
|
@@ -20,4 +39,8 @@ export function getFormattedDiff({ filePath, gitRootDir, cwd, baseBranch, shrink
|
|
|
20
39
|
leftMargin?: number;
|
|
21
40
|
width?: number;
|
|
22
41
|
hideHeader?: boolean;
|
|
23
|
-
|
|
42
|
+
hideFileHeader?: boolean;
|
|
43
|
+
hideHeaderTopLine?: boolean;
|
|
44
|
+
disableDefaultBackground?: boolean;
|
|
45
|
+
returnRaw?: boolean;
|
|
46
|
+
}): Promise<string | FormattedDiffResult | null>;
|