Skip to content

Commit

Permalink
Merge pull request #128 from rtfpessoa/add-missing-diff2html-configs
Browse files Browse the repository at this point in the history
feature: add missing diff2html configuration to cli
  • Loading branch information
rtfpessoa authored Jan 18, 2022
2 parents 45181ab + 572ac38 commit 6b8d14c
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 48 deletions.
25 changes: 12 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,24 @@ jobs:
paths:
- '*'

build-node-10:
<<: *common-build
docker:
- image: node:10

build-node-12:
<<: *common-build
docker:
- image: node:12

build-node-14:
<<: *latest-build
<<: *common-build
docker:
- image: node:14

build-node-16:
<<: *latest-build
docker:
- image: node:16

tag_version:
docker:
- image: node:14
- image: node:16
working_directory: ~/workdir
steps:
- attach_workspace:
Expand All @@ -124,7 +124,7 @@ jobs:
publish_cli:
docker:
- image: node:14
- image: node:16
working_directory: ~/workdir
steps:
- attach_workspace:
Expand Down Expand Up @@ -181,25 +181,24 @@ workflows:
validate-and-publish:
jobs:
- checkout-and-version
- build-node-10:
requires:
- checkout-and-version
- build-node-12:
requires:
- checkout-and-version
- build-node-14:
requires:
- checkout-and-version
- build-node-16:
requires:
- checkout-and-version
- publish_approval:
type: approval
requires:
- build-node-10
- build-node-12
- build-node-14
- build-node-16
- tag_version:
requires:
- publish_approval
- publish_cli:
requires:
- tag_version

43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,30 @@ npm install -g diff2html-cli

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

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

### Exit Status Codes

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"url": "https://github.com/rtfpessoa/diff2html-cli/issues"
},
"engines": {
"node": ">=10.13"
"node": ">=12"
},
"preferGlobal": true,
"scripts": {
Expand Down Expand Up @@ -86,7 +86,7 @@
},
"dependencies": {
"clipboardy": "^2.3.0",
"diff2html": "^3.1.9",
"diff2html": "^3.4.14",
"node-fetch": "^2.6.0",
"open": "^7.0.3",
"yargs": "^16.1.0"
Expand Down
5 changes: 5 additions & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export function parseArgv(argv: Argv): [Diff2HtmlConfig, Configuration] {
drawFileList: argv.summary !== 'hidden',
matchWordsThreshold: argv.matchWordsThreshold,
matchingMaxComparisons: argv.matchingMaxComparisons,
diffMaxChanges: argv.diffMaxChanges,
diffMaxLineLength: argv.diffMaxLineLength,
renderNothingWhenEmpty: argv.renderNothingWhenEmpty,
maxLineSizeInBlockForComparison: argv.maxLineSizeInBlockForComparison,
maxLineLengthHighlight: argv.maxLineLengthHighlight,
};

const defaultWrapperTemplate = path.resolve(__dirname, '..', 'template.html');
Expand Down
35 changes: 35 additions & 0 deletions src/yargs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export type Argv = {
matching: LineMatchingType;
matchWordsThreshold: number;
matchingMaxComparisons: number;
diffMaxChanges?: number;
diffMaxLineLength?: number;
renderNothingWhenEmpty: boolean;
maxLineSizeInBlockForComparison: number;
maxLineLengthHighlight: number;
format: FormatType;
input: InputType;
output: OutputType;
Expand All @@ -39,6 +44,9 @@ const defaults: Argv = {
matching: 'none',
matchWordsThreshold: 0.25,
matchingMaxComparisons: 1000,
renderNothingWhenEmpty: false,
maxLineSizeInBlockForComparison: 200,
maxLineLengthHighlight: 10000,
format: 'html',
input: 'command',
output: 'preview',
Expand Down Expand Up @@ -129,6 +137,33 @@ export function setup(): Argv {
type: 'number',
default: defaults.matchingMaxComparisons,
})
.option('diffMaxChanges', {
describe: 'Number of changed lines after which a file diff is deemed as too big and not displayed',
nargs: 1,
type: 'number',
})
.option('diffMaxLineLength', {
describe: 'Number of characters in a diff line after which a file diff is deemed as too big and not displayed',
nargs: 1,
type: 'number',
})
.option('renderNothingWhenEmpty', {
describe: 'Render nothing if the diff shows no change in its comparison',
type: 'boolean',
default: defaults.renderNothingWhenEmpty,
})
.option('maxLineSizeInBlockForComparison', {
describe: 'Maximum number of characters of the bigger line in a block to apply comparison',
nargs: 1,
type: 'number',
default: defaults.maxLineSizeInBlockForComparison,
})
.option('maxLineLengthHighlight', {
describe: 'Maximum number of characters in a line to apply highlight',
nargs: 1,
type: 'number',
default: defaults.maxLineLengthHighlight,
})
.option('format', {
alias: 'f',
describe: 'Output format',
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1517,20 +1517,20 @@ diff-sequences@^26.5.0:
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.5.0.tgz#ef766cf09d43ed40406611f11c6d8d9dd8b2fefd"
integrity sha512-ZXx86srb/iYy6jG71k++wBN9P9J05UNQ5hQHQd9MtMPvcqXPx/vKU69jfHV637D00Q2gSgPk2D+jSx3l1lDW/Q==

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

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

dir-glob@^3.0.1:
version "3.0.1"
Expand Down Expand Up @@ -2368,10 +2368,10 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"

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

hogan.js@3.0.2:
version "3.0.2"
Expand Down

0 comments on commit 6b8d14c

Please sign in to comment.