Skip to content

Commit 23b9bb0

Browse files
authored
Merge pull request #90 from rtfpessoa/release-major-version
release: New major refactor of diff2html to Typescript
2 parents 398363a + 2396ba4 commit 23b9bb0

File tree

8 files changed

+1163
-1327
lines changed

8 files changed

+1163
-1327
lines changed

Diff for: .circleci/config.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ jobs:
1010
- run:
1111
name: Get next version
1212
command: |
13-
# Hack: Set a unique fake name for the release branch to avoid releasing master as the new 3.x major release for now
14-
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=FAKE-RELEASE-BRANCH-NAME)"
13+
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=master)"
1514
echo "Next version is ${NEXT_VERSION}"
1615
echo "${NEXT_VERSION}" > .version
1716
- run:
1817
name: Get next npm tag name
1918
command: |
20-
if [ "${GITHUB_REF#refs/heads/}" = "master" ]; then
19+
if [ "${CIRCLE_BRANCH}" = "master" ]; then
2120
export PUBLISH_TAG="latest"
22-
elif [ "${GITHUB_REF#refs/heads/}" = "next" ]; then
21+
elif [ "${CIRCLE_BRANCH}" = "next" ]; then
2322
export PUBLISH_TAG="next"
2423
else
2524
export PUBLISH_TAG="pr"
@@ -110,7 +109,7 @@ jobs:
110109
docker:
111110
- image: node:13
112111

113-
publish_library:
112+
publish_cli:
114113
docker:
115114
- image: node:13
116115
working_directory: ~/workdir
@@ -132,6 +131,7 @@ jobs:
132131
command: |
133132
# Update version in packages to publish
134133
yarn version --non-interactive --new-version $(cat .version)
134+
git push --tags "https://rtfpessoa:[email protected]/rtfpessoa/diff2html-cli"
135135
- run:
136136
name: Setup npm credentials
137137
command: |
@@ -188,7 +188,7 @@ workflows:
188188
- build-node-11
189189
- build-node-12
190190
- build-node-13
191-
- publish_library:
191+
- publish_cli:
192192
requires:
193193
- publish_approval
194194

Diff for: README.md

+17-15
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Diff to Html generates pretty HTML diffs from unified and git diff output in you
2424
- [Setup](#setup)
2525
- [Usage](#usage)
2626
- [Custom HTML wrapper template](#custom-html-wrapper-template)
27-
- [Examples:](#examples)
28-
- [Contributions](#contributions)
27+
- [Examples](#examples)
28+
- [Contribute](#contribute)
2929
- [Developing](#developing)
3030
- [License](#license)
3131
- [Thanks](#thanks)
@@ -61,29 +61,31 @@ Diff to Html generates pretty HTML diffs from unified and git diff output in you
6161

6262
## Setup
6363

64-
npm install -g diff2html-cli
64+
```sh
65+
npm install -g diff2html-cli
66+
```
6567

6668
## Usage
6769

68-
Usage: diff2html [options] -- [diff args]
70+
Usage: diff2html [ flags and/or options ] -- [git diff passthrough flags and options]
6971

7072
| flag | alias | description | choices | default |
7173
| ----- | ------------------------ | -------------------------------------------------------------------------- | ---------------------------- | --------- |
7274
| -s | --style | Output style | `line`, `side` | `line` |
7375
| --sc | --synchronisedScroll | Synchronised horizontal scroll | `true`, `false` | `true` |
7476
| --hc | --highlightCode | Highlight code | `true`, `false` | `true` |
7577
| --su | --summary | Show files summary | `closed`, `open`, `hidden` | `closed` |
76-
| --d | --diffStyle | Diff style | `word`, `char` | `word` |
78+
| -d | --diffStyle | Diff style | `word`, `char` | `word` |
7779
| --lm | --matching | Diff line matching type | `lines`, `words`, `none` | `none` |
7880
| --lmt | --matchWordsThreshold | Diff line matching word threshold | | `0.25` |
7981
| --lmm | --matchingMaxComparisons | Diff line matching maximum line comparisons of a block of changes | `2500` |
80-
| --hwt | --htmlWrapperTemplate | Path to custom template to be rendered when using the `html` output format | _[string]_ |
82+
| --hwt | --htmlWrapperTemplate | Path to custom template to be rendered when using the `html` output format | `[string]` |
8183
| -f | --format | Output format | `html`, `json` | `html` |
8284
| -i | --input | Diff input source | `file`, `command`, `stdin` | `command` |
8385
| -o | --output | Output destination | `preview`, `stdout` | `preview` |
8486
| -u | --diffy | Upload to diffy.org | `browser`, `pbcopy`, `print` | |
85-
| -F | --file | Send output to file (overrides output option) | _[string]_ | |
86-
| --ig | --ignore | Ignore particular files from the diff | _[string]_ | |
87+
| -F | --file | Send output to file (overrides output option) | `[string]` | |
88+
| --ig | --ignore | Ignore particular files from the diff | `[string]` | |
8789
| -v | --version | Show version number | | |
8890
| -h | --help | Show help | | |
8991

@@ -97,13 +99,13 @@ they are here:
9799

98100
- Inside the `<head>` tag
99101

100-
```
102+
```html
101103
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css" />
102104
<!--diff2html-css-->
103105
<!--diff2html-js-ui-->
104106
<script>
105-
document.addEventListener("DOMContentLoaded", () => {
106-
const targetElement = document.getElementById("diff");
107+
document.addEventListener('DOMContentLoaded', () => {
108+
const targetElement = document.getElementById('diff');
107109
const diff2htmlUi = new Diff2HtmlUI(targetElement);
108110
//diff2html-fileListToggle
109111
//diff2html-synchronisedScroll
@@ -114,13 +116,13 @@ they are here:
114116

115117
- Inside the `<body>` tag
116118

117-
```
119+
```html
118120
<div id="diff">
119121
<!--diff2html-diff-->
120122
</div>
121123
```
122124

123-
### Examples:
125+
### Examples
124126

125127
`diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1`
126128

@@ -153,7 +155,7 @@ they are here:
153155

154156
_NOTE_: notice the `--` in the examples
155157

156-
## Contributions
158+
## Contribute
157159

158160
This is a developer friendly project, all the contributions are welcome. To contribute just send a pull request with
159161
your changes following the guidelines described in `CONTRIBUTING.md`. I will try to review them as soon as possible.
@@ -164,7 +166,7 @@ Make some changes, `yarn build` and then `./bin/diff2html` 😉
164166

165167
## License
166168

167-
Copyright 2014-2019 Rodrigo Fernandes. Released under the terms of the MIT license.
169+
Copyright 2014-present Rodrigo Fernandes. Released under the terms of the MIT license.
168170

169171
## Thanks
170172

Diff for: package.json

+32-14
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
"format:fix": "yarn run prettier --write",
4545
"build": "yarn run build:es5",
4646
"build:es5": "rm -rf lib; tsc -p tsconfig.json --outDir lib",
47-
"build:toc-base": "markdown-toc --maxdepth 3 --bullets='-' -i",
48-
"build:toc": "yarn run build:toc-base README.md",
47+
"gen": "yarn run gen:toc",
48+
"gen:toc-base": "markdown-toc --maxdepth 3 --bullets='-' -i",
49+
"gen:toc": "yarn run gen:toc-base README.md",
4950
"test": "is-ci 'test:coverage' 'test:watch'",
5051
"test:coverage": "jest --coverage",
5152
"test:watch": "jest --watch",
@@ -62,37 +63,54 @@
6263
},
6364
"main": "./lib/diff2html.js",
6465
"types": "./lib/diff2html.d.ts",
66+
"husky": {
67+
"hooks": {
68+
"pre-commit": "lint-staged"
69+
}
70+
},
71+
"lint-staged": {
72+
"**/*.+(js|jsx|ts|tsx|json)": [
73+
"prettier --write",
74+
"eslint --fix"
75+
],
76+
"**/*.+(css|html|md|mdx)": [
77+
"prettier --write"
78+
],
79+
"README.md": [
80+
"yarn run gen:toc-base"
81+
]
82+
},
6583
"dependencies": {
6684
"clipboardy": "^2.1.0",
67-
"diff2html": "3.0.0-master.df4481f",
68-
"open": "^7.0.0",
85+
"diff2html": "3.0.0",
86+
"open": "^7.0.2",
6987
"request": "^2.88.0",
7088
"yargs": "^15.0.2"
7189
},
7290
"devDependencies": {
7391
"@types/hogan.js": "^3.0.0",
74-
"@types/jest": "24.9.0",
75-
"@types/node": "13.1.8",
92+
"@types/jest": "25.1.1",
93+
"@types/node": "13.7.0",
7694
"@types/request": "2.48.4",
77-
"@typescript-eslint/eslint-plugin": "2.16.0",
78-
"@typescript-eslint/parser": "2.16.0",
95+
"@typescript-eslint/eslint-plugin": "2.19.0",
96+
"@typescript-eslint/parser": "2.19.0",
7997
"codacy-coverage": "3.4.0",
8098
"eslint": "6.8.0",
81-
"eslint-config-prettier": "6.9.0",
82-
"eslint-plugin-import": "2.20.0",
99+
"eslint-config-prettier": "6.10.0",
100+
"eslint-plugin-import": "2.20.1",
83101
"eslint-plugin-jest": "23.6.0",
84102
"eslint-plugin-json": "2.0.1",
85103
"eslint-plugin-node": "11.0.0",
86104
"eslint-plugin-optimize-regex": "1.1.7",
87105
"eslint-plugin-promise": "4.2.1",
88106
"eslint-plugin-sonarjs": "0.5.0",
89-
"husky": "4.0.10",
107+
"husky": "4.2.1",
90108
"is-ci-cli": "2.0.0",
91-
"jest": "24.9.0",
92-
"lint-staged": "9.5.0",
109+
"jest": "25.1.0",
110+
"lint-staged": "10.0.7",
93111
"markdown-toc": "^1.2.0",
94112
"prettier": "1.19.1",
95-
"ts-jest": "24.3.0",
113+
"ts-jest": "25.2.0",
96114
"typescript": "3.7.5"
97115
},
98116
"license": "MIT",

Diff for: src/cli.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as fs from 'fs';
2-
import * as os from 'os';
3-
import * as path from 'path';
1+
import fs from 'fs';
2+
import os from 'os';
3+
import path from 'path';
44

55
import * as clipboardy from 'clipboardy';
66
import open = require('open');

Diff for: src/configuration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as path from 'path';
1+
import path from 'path';
22

33
import { Configuration } from './types';
44
import { Argv } from './yargs';

Diff for: src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as childProcess from 'child_process';
2-
import * as fs from 'fs';
1+
import childProcess from 'child_process';
2+
import fs from 'fs';
33

44
export function exists(filePath: string): boolean {
55
try {

0 commit comments

Comments
 (0)