From bbd18f0afe70ff5a67f0d1e402e8b3e467f315f8 Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Tue, 18 Jan 2022 22:45:24 +0000 Subject: [PATCH 1/2] feature: add missing diff2html configuration to cli --- README.md | 43 ++++++++++++++++++++++++------------------- package.json | 2 +- src/configuration.ts | 5 +++++ src/yargs.ts | 35 +++++++++++++++++++++++++++++++++++ yarn.lock | 28 ++++++++++++++-------------- 5 files changed, 79 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index da02fe8..cc7f89b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.json b/package.json index a4ea338..e4db769 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/configuration.ts b/src/configuration.ts index 9f34963..9356377 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -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'); diff --git a/src/yargs.ts b/src/yargs.ts index 74ce4ab..bb182d3 100644 --- a/src/yargs.ts +++ b/src/yargs.ts @@ -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; @@ -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', @@ -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', diff --git a/yarn.lock b/yarn.lock index a338681..cdd1cd6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" From 572ac38cb7d6c2e31f57be989d503f223ecabf76 Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Tue, 18 Jan 2022 22:51:19 +0000 Subject: [PATCH 2/2] bump: update node versions --- .circleci/config.yml | 25 ++++++++++++------------- package.json | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2c32ab1..4e72818 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -124,7 +124,7 @@ jobs: publish_cli: docker: - - image: node:14 + - image: node:16 working_directory: ~/workdir steps: - attach_workspace: @@ -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 - \ No newline at end of file diff --git a/package.json b/package.json index e4db769..35873c7 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "url": "https://github.com/rtfpessoa/diff2html-cli/issues" }, "engines": { - "node": ">=10.13" + "node": ">=12" }, "preferGlobal": true, "scripts": {