Skip to content

Commit 6b8d14c

Browse files
authored
Merge pull request #128 from rtfpessoa/add-missing-diff2html-configs
feature: add missing diff2html configuration to cli
2 parents 45181ab + 572ac38 commit 6b8d14c

File tree

6 files changed

+92
-48
lines changed

6 files changed

+92
-48
lines changed

Diff for: .circleci/config.yml

+12-13
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,24 @@ jobs:
8989
paths:
9090
- '*'
9191

92-
build-node-10:
93-
<<: *common-build
94-
docker:
95-
- image: node:10
96-
9792
build-node-12:
9893
<<: *common-build
9994
docker:
10095
- image: node:12
10196

10297
build-node-14:
103-
<<: *latest-build
98+
<<: *common-build
10499
docker:
105100
- image: node:14
106101

102+
build-node-16:
103+
<<: *latest-build
104+
docker:
105+
- image: node:16
106+
107107
tag_version:
108108
docker:
109-
- image: node:14
109+
- image: node:16
110110
working_directory: ~/workdir
111111
steps:
112112
- attach_workspace:
@@ -124,7 +124,7 @@ jobs:
124124
125125
publish_cli:
126126
docker:
127-
- image: node:14
127+
- image: node:16
128128
working_directory: ~/workdir
129129
steps:
130130
- attach_workspace:
@@ -181,25 +181,24 @@ workflows:
181181
validate-and-publish:
182182
jobs:
183183
- checkout-and-version
184-
- build-node-10:
185-
requires:
186-
- checkout-and-version
187184
- build-node-12:
188185
requires:
189186
- checkout-and-version
190187
- build-node-14:
191188
requires:
192189
- checkout-and-version
190+
- build-node-16:
191+
requires:
192+
- checkout-and-version
193193
- publish_approval:
194194
type: approval
195195
requires:
196-
- build-node-10
197196
- build-node-12
198197
- build-node-14
198+
- build-node-16
199199
- tag_version:
200200
requires:
201201
- publish_approval
202202
- publish_cli:
203203
requires:
204204
- tag_version
205-

Diff for: README.md

+24-19
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,30 @@ npm install -g diff2html-cli
7070

7171
Usage: diff2html [ flags and/or options ] -- [git diff passthrough flags and options]
7272

73-
| flag | alias | description | choices | default |
74-
| ----- | ------------------------ | -------------------------------------------------------------------------- | ---------------------------- | --------- |
75-
| -s | --style | Output style | `line`, `side` | `line` |
76-
| --sc | --synchronisedScroll | Synchronised horizontal scroll | `true`, `false` | `true` |
77-
| --hc | --highlightCode | Highlight code | `true`, `false` | `true` |
78-
| --su | --summary | Show files summary | `closed`, `open`, `hidden` | `closed` |
79-
| -d | --diffStyle | Diff style | `word`, `char` | `word` |
80-
| --lm | --matching | Diff line matching type | `lines`, `words`, `none` | `none` |
81-
| --lmt | --matchWordsThreshold | Diff line matching word threshold | | `0.25` |
82-
| --lmm | --matchingMaxComparisons | Diff line matching maximum line comparisons of a block of changes | `2500` |
83-
| --hwt | --htmlWrapperTemplate | Path to custom template to be rendered when using the `html` output format | `[string]` |
84-
| -f | --format | Output format | `html`, `json` | `html` |
85-
| -i | --input | Diff input source | `file`, `command`, `stdin` | `command` |
86-
| -o | --output | Output destination | `preview`, `stdout` | `preview` |
87-
| -u | --diffy | Upload to diffy.org | `browser`, `pbcopy`, `print` | |
88-
| -F | --file | Send output to file (overrides output option) | `[string]` | |
89-
| --ig | --ignore | Ignore particular files from the diff | `[string]` | |
90-
| -v | --version | Show version number | | |
91-
| -h | --help | Show help | | |
73+
| flag | alias | description | choices | default |
74+
| ----- | --------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | --------- |
75+
| -s | --style | Output style | `line`, `side` | `line` |
76+
| --sc | --synchronisedScroll | Synchronised horizontal scroll | `true`, `false` | `true` |
77+
| --hc | --highlightCode | Highlight code | `true`, `false` | `true` |
78+
| --su | --summary | Show files summary | `closed`, `open`, `hidden` | `closed` |
79+
| -d | --diffStyle | Diff style | `word`, `char` | `word` |
80+
| --lm | --matching | Diff line matching type | `lines`, `words`, `none` | `none` |
81+
| --lmt | --matchWordsThreshold | Diff line matching word threshold | | `0.25` |
82+
| --lmm | --matchingMaxComparisons | Diff line matching maximum line comparisons of a block of changes | | `2500` |
83+
| | --diffMaxChanges | Number of changed lines after which a file diff is deemed as too big and not displayed | | |
84+
| | --diffMaxLineLength | Number of characters in a diff line after which a file diff is deemed as too big and not displayed | | |
85+
| | --renderNothingWhenEmpty | Render nothing if the diff shows no change in its comparison | | `false` |
86+
| | --maxLineSizeInBlockForComparison | Maximum number of characters of the bigger line in a block to apply comparison | | `200` |
87+
| | --maxLineLengthHighlight | Maximum number of characters in a line to apply highlight | | `10000` |
88+
| --hwt | --htmlWrapperTemplate | Path to custom template to be rendered when using the `html` output format | `[string]` |
89+
| -f | --format | Output format | `html`, `json` | `html` |
90+
| -i | --input | Diff input source | `file`, `command`, `stdin` | `command` |
91+
| -o | --output | Output destination | `preview`, `stdout` | `preview` |
92+
| -u | --diffy | Upload to diffy.org | `browser`, `pbcopy`, `print` | |
93+
| -F | --file | Send output to file (overrides output option) | `[string]` | |
94+
| --ig | --ignore | Ignore particular files from the diff | `[string]` | |
95+
| -v | --version | Show version number | | |
96+
| -h | --help | Show help | | |
9297

9398
### Exit Status Codes
9499

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"url": "https://github.com/rtfpessoa/diff2html-cli/issues"
3737
},
3838
"engines": {
39-
"node": ">=10.13"
39+
"node": ">=12"
4040
},
4141
"preferGlobal": true,
4242
"scripts": {
@@ -86,7 +86,7 @@
8686
},
8787
"dependencies": {
8888
"clipboardy": "^2.3.0",
89-
"diff2html": "^3.1.9",
89+
"diff2html": "^3.4.14",
9090
"node-fetch": "^2.6.0",
9191
"open": "^7.0.3",
9292
"yargs": "^16.1.0"

Diff for: src/configuration.ts

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export function parseArgv(argv: Argv): [Diff2HtmlConfig, Configuration] {
2626
drawFileList: argv.summary !== 'hidden',
2727
matchWordsThreshold: argv.matchWordsThreshold,
2828
matchingMaxComparisons: argv.matchingMaxComparisons,
29+
diffMaxChanges: argv.diffMaxChanges,
30+
diffMaxLineLength: argv.diffMaxLineLength,
31+
renderNothingWhenEmpty: argv.renderNothingWhenEmpty,
32+
maxLineSizeInBlockForComparison: argv.maxLineSizeInBlockForComparison,
33+
maxLineLengthHighlight: argv.maxLineLengthHighlight,
2934
};
3035

3136
const defaultWrapperTemplate = path.resolve(__dirname, '..', 'template.html');

Diff for: src/yargs.ts

+35
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export type Argv = {
2020
matching: LineMatchingType;
2121
matchWordsThreshold: number;
2222
matchingMaxComparisons: number;
23+
diffMaxChanges?: number;
24+
diffMaxLineLength?: number;
25+
renderNothingWhenEmpty: boolean;
26+
maxLineSizeInBlockForComparison: number;
27+
maxLineLengthHighlight: number;
2328
format: FormatType;
2429
input: InputType;
2530
output: OutputType;
@@ -39,6 +44,9 @@ const defaults: Argv = {
3944
matching: 'none',
4045
matchWordsThreshold: 0.25,
4146
matchingMaxComparisons: 1000,
47+
renderNothingWhenEmpty: false,
48+
maxLineSizeInBlockForComparison: 200,
49+
maxLineLengthHighlight: 10000,
4250
format: 'html',
4351
input: 'command',
4452
output: 'preview',
@@ -129,6 +137,33 @@ export function setup(): Argv {
129137
type: 'number',
130138
default: defaults.matchingMaxComparisons,
131139
})
140+
.option('diffMaxChanges', {
141+
describe: 'Number of changed lines after which a file diff is deemed as too big and not displayed',
142+
nargs: 1,
143+
type: 'number',
144+
})
145+
.option('diffMaxLineLength', {
146+
describe: 'Number of characters in a diff line after which a file diff is deemed as too big and not displayed',
147+
nargs: 1,
148+
type: 'number',
149+
})
150+
.option('renderNothingWhenEmpty', {
151+
describe: 'Render nothing if the diff shows no change in its comparison',
152+
type: 'boolean',
153+
default: defaults.renderNothingWhenEmpty,
154+
})
155+
.option('maxLineSizeInBlockForComparison', {
156+
describe: 'Maximum number of characters of the bigger line in a block to apply comparison',
157+
nargs: 1,
158+
type: 'number',
159+
default: defaults.maxLineSizeInBlockForComparison,
160+
})
161+
.option('maxLineLengthHighlight', {
162+
describe: 'Maximum number of characters in a line to apply highlight',
163+
nargs: 1,
164+
type: 'number',
165+
default: defaults.maxLineLengthHighlight,
166+
})
132167
.option('format', {
133168
alias: 'f',
134169
describe: 'Output format',

Diff for: yarn.lock

+14-14
Original file line numberDiff line numberDiff line change
@@ -1517,20 +1517,20 @@ diff-sequences@^26.5.0:
15171517
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.5.0.tgz#ef766cf09d43ed40406611f11c6d8d9dd8b2fefd"
15181518
integrity sha512-ZXx86srb/iYy6jG71k++wBN9P9J05UNQ5hQHQd9MtMPvcqXPx/vKU69jfHV637D00Q2gSgPk2D+jSx3l1lDW/Q==
15191519

1520-
diff2html@^3.1.9:
1521-
version "3.1.14"
1522-
resolved "https://registry.yarnpkg.com/diff2html/-/diff2html-3.1.14.tgz#af5792136b2328a23e17ebaf81320149c9f0639f"
1523-
integrity sha512-Qot+l+v+aqGcuvJe1C8ZPev17deSyg+DOwICF3m8Ka/C3af1K2Wh2WENYulxv9CQyVhy2VarluR5fMfN5BEHIg==
1520+
diff2html@^3.4.14:
1521+
version "3.4.14"
1522+
resolved "https://registry.yarnpkg.com/diff2html/-/diff2html-3.4.14.tgz#222ce0f909a1582fd0cf559423586a82a768733d"
1523+
integrity sha512-cMS7WYOELzSMuAmRMR0+vNwF8PjcFXOyutYEdXkcAXeA7l2AVEi3XdNnC1lk4bh2xSFKkoQ6Lhy+iqtcRonkww==
15241524
dependencies:
1525-
diff "4.0.2"
1525+
diff "5.0.0"
15261526
hogan.js "3.0.2"
15271527
optionalDependencies:
1528-
highlight.js "10.2.1"
1528+
highlight.js "11.2.0"
15291529

1530-
diff@4.0.2:
1531-
version "4.0.2"
1532-
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
1533-
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
1530+
diff@5.0.0:
1531+
version "5.0.0"
1532+
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
1533+
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==
15341534

15351535
dir-glob@^3.0.1:
15361536
version "3.0.1"
@@ -2368,10 +2368,10 @@ has@^1.0.3:
23682368
dependencies:
23692369
function-bind "^1.1.1"
23702370

2371-
highlight.js@10.2.1:
2372-
version "10.2.1"
2373-
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.2.1.tgz#09784fe2e95612abbefd510948945d4fe6fa9668"
2374-
integrity sha512-A+sckVPIb9zQTUydC9lpRX1qRFO/N0OKEh0NwIr65ckvWA/oMY8v9P3+kGRK3w2ULSh9E8v5MszXafodQ6039g==
2371+
highlight.js@11.2.0:
2372+
version "11.2.0"
2373+
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.2.0.tgz#a7e3b8c1fdc4f0538b93b2dc2ddd53a40c6ab0f0"
2374+
integrity sha512-JOySjtOEcyG8s4MLR2MNbLUyaXqUunmSnL2kdV/KuGJOmHZuAR5xC54Ko7goAXBWNhf09Vy3B+U7vR62UZ/0iw==
23752375

23762376
23772377
version "3.0.2"

0 commit comments

Comments
 (0)