Skip to content

Commit

Permalink
Merge pull request #90 from rtfpessoa/release-major-version
Browse files Browse the repository at this point in the history
release: New major refactor of diff2html to Typescript
  • Loading branch information
rtfpessoa authored Feb 5, 2020
2 parents 398363a + 2396ba4 commit 23b9bb0
Show file tree
Hide file tree
Showing 8 changed files with 1,163 additions and 1,327 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ jobs:
- run:
name: Get next version
command: |
# Hack: Set a unique fake name for the release branch to avoid releasing master as the new 3.x major release for now
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=FAKE-RELEASE-BRANCH-NAME)"
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=master)"
echo "Next version is ${NEXT_VERSION}"
echo "${NEXT_VERSION}" > .version
- run:
name: Get next npm tag name
command: |
if [ "${GITHUB_REF#refs/heads/}" = "master" ]; then
if [ "${CIRCLE_BRANCH}" = "master" ]; then
export PUBLISH_TAG="latest"
elif [ "${GITHUB_REF#refs/heads/}" = "next" ]; then
elif [ "${CIRCLE_BRANCH}" = "next" ]; then
export PUBLISH_TAG="next"
else
export PUBLISH_TAG="pr"
Expand Down Expand Up @@ -110,7 +109,7 @@ jobs:
docker:
- image: node:13

publish_library:
publish_cli:
docker:
- image: node:13
working_directory: ~/workdir
Expand All @@ -132,6 +131,7 @@ jobs:
command: |
# Update version in packages to publish
yarn version --non-interactive --new-version $(cat .version)
git push --tags "https://rtfpessoa:$GPR_AUTH_TOKEN@github.com/rtfpessoa/diff2html-cli"
- run:
name: Setup npm credentials
command: |
Expand Down Expand Up @@ -188,7 +188,7 @@ workflows:
- build-node-11
- build-node-12
- build-node-13
- publish_library:
- publish_cli:
requires:
- publish_approval

32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Diff to Html generates pretty HTML diffs from unified and git diff output in you
- [Setup](#setup)
- [Usage](#usage)
- [Custom HTML wrapper template](#custom-html-wrapper-template)
- [Examples:](#examples)
- [Contributions](#contributions)
- [Examples](#examples)
- [Contribute](#contribute)
- [Developing](#developing)
- [License](#license)
- [Thanks](#thanks)
Expand Down Expand Up @@ -61,29 +61,31 @@ Diff to Html generates pretty HTML diffs from unified and git diff output in you

## Setup

npm install -g diff2html-cli
```sh
npm install -g diff2html-cli
```

## Usage

Usage: diff2html [options] -- [diff args]
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` |
| -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]_ |
| --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]_ | |
| -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 | | |

Expand All @@ -97,13 +99,13 @@ they are here:

- Inside the `<head>` tag

```
```html
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css" />
<!--diff2html-css-->
<!--diff2html-js-ui-->
<script>
document.addEventListener("DOMContentLoaded", () => {
const targetElement = document.getElementById("diff");
document.addEventListener('DOMContentLoaded', () => {
const targetElement = document.getElementById('diff');
const diff2htmlUi = new Diff2HtmlUI(targetElement);
//diff2html-fileListToggle
//diff2html-synchronisedScroll
Expand All @@ -114,13 +116,13 @@ they are here:

- Inside the `<body>` tag

```
```html
<div id="diff">
<!--diff2html-diff-->
</div>
```

### Examples:
### Examples

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

Expand Down Expand Up @@ -153,7 +155,7 @@ they are here:

_NOTE_: notice the `--` in the examples

## Contributions
## Contribute

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

## License

Copyright 2014-2019 Rodrigo Fernandes. Released under the terms of the MIT license.
Copyright 2014-present Rodrigo Fernandes. Released under the terms of the MIT license.

## Thanks

Expand Down
46 changes: 32 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
"format:fix": "yarn run prettier --write",
"build": "yarn run build:es5",
"build:es5": "rm -rf lib; tsc -p tsconfig.json --outDir lib",
"build:toc-base": "markdown-toc --maxdepth 3 --bullets='-' -i",
"build:toc": "yarn run build:toc-base README.md",
"gen": "yarn run gen:toc",
"gen:toc-base": "markdown-toc --maxdepth 3 --bullets='-' -i",
"gen:toc": "yarn run gen:toc-base README.md",
"test": "is-ci 'test:coverage' 'test:watch'",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
Expand All @@ -62,37 +63,54 @@
},
"main": "./lib/diff2html.js",
"types": "./lib/diff2html.d.ts",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"**/*.+(js|jsx|ts|tsx|json)": [
"prettier --write",
"eslint --fix"
],
"**/*.+(css|html|md|mdx)": [
"prettier --write"
],
"README.md": [
"yarn run gen:toc-base"
]
},
"dependencies": {
"clipboardy": "^2.1.0",
"diff2html": "3.0.0-master.df4481f",
"open": "^7.0.0",
"diff2html": "3.0.0",
"open": "^7.0.2",
"request": "^2.88.0",
"yargs": "^15.0.2"
},
"devDependencies": {
"@types/hogan.js": "^3.0.0",
"@types/jest": "24.9.0",
"@types/node": "13.1.8",
"@types/jest": "25.1.1",
"@types/node": "13.7.0",
"@types/request": "2.48.4",
"@typescript-eslint/eslint-plugin": "2.16.0",
"@typescript-eslint/parser": "2.16.0",
"@typescript-eslint/eslint-plugin": "2.19.0",
"@typescript-eslint/parser": "2.19.0",
"codacy-coverage": "3.4.0",
"eslint": "6.8.0",
"eslint-config-prettier": "6.9.0",
"eslint-plugin-import": "2.20.0",
"eslint-config-prettier": "6.10.0",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-jest": "23.6.0",
"eslint-plugin-json": "2.0.1",
"eslint-plugin-node": "11.0.0",
"eslint-plugin-optimize-regex": "1.1.7",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-sonarjs": "0.5.0",
"husky": "4.0.10",
"husky": "4.2.1",
"is-ci-cli": "2.0.0",
"jest": "24.9.0",
"lint-staged": "9.5.0",
"jest": "25.1.0",
"lint-staged": "10.0.7",
"markdown-toc": "^1.2.0",
"prettier": "1.19.1",
"ts-jest": "24.3.0",
"ts-jest": "25.2.0",
"typescript": "3.7.5"
},
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import fs from 'fs';
import os from 'os';
import path from 'path';

import * as clipboardy from 'clipboardy';
import open = require('open');
Expand Down
2 changes: 1 addition & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from 'path';
import path from 'path';

import { Configuration } from './types';
import { Argv } from './yargs';
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as childProcess from 'child_process';
import * as fs from 'fs';
import childProcess from 'child_process';
import fs from 'fs';

export function exists(filePath: string): boolean {
try {
Expand Down
Loading

0 comments on commit 23b9bb0

Please sign in to comment.