8000 bump: Update dependencies by rtfpessoa · Pull Request #334 · rtfpessoa/diff2html · GitHub
[go: up one dir, main page]

Skip to content

bump: Update dependencies #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 28 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,32 @@
"hogan.js": "3.0.2"
},
"optionalDependencies": {
"highlight.js": "10.0.2"
"highlight.js": "10.1.2"
},
"devDependencies": {
"@types/clipboard": "2.0.1",
"@types/copy-webpack-plugin": "5.0.0",
"@types/copy-webpack-plugin": "6.0.0",
"@types/diff": "4.0.2",
"@types/highlight.js": "9.12.3",
"@types/hogan.js": "3.0.0",
"@types/html-webpack-plugin": "3.2.2",
"@types/jest": "25.2.1",
"@types/html-webpack-plugin": "3.2.3",
"@types/jest": "26.0.10",
"@types/mini-css-extract-plugin": "0.9.1",
"@types/mkdirp": "1.0.0",
"@types/node": "13.13.5",
"@types/mkdirp": "1.0.1",
"@types/node": "14.0.27",
"@types/nopt": "3.0.29",
"@types/webpack": "4.41.12",
"@typescript-eslint/eslint-plugin": "2.31.0",
"@typescript-eslint/parser": "2.31.0",
"autoprefixer": "9.7.6",
"bulma": "^0.8.0",
"@typescript-eslint/eslint-plugin": "3.9.0",
"@typescript-eslint/parser": "3.9.0",
"autoprefixer": "9.8.6",
"bulma": "^0.9.0",
"clipboard": "2.0.6",
"copy-webpack-plugin": "5.1.1",
"css-loader": "3.5.3",
"copy-webpack-plugin": "6.0.3",
"css-loader": "4.2.1",
"cssnano": "4.1.10",
"eslint": "7.0.0",
"eslint": "7.7.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-jest": "23.10.0",
"eslint-plugin-json": "2.1.1",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jest": "23.20.0",
"eslint-plugin-json": "2.1.2",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-optimize-regex": "1.2.0",
"eslint-plugin-promise": "4.2.1",
Expand All @@ -127,28 +125,28 @@
"html-webpack-plugin": "4.3.0",
"husky": "4.2.5",
"image-webpack-loader": "6.0.0",
"is-ci-cli": "2.0.0",
"jest": "26.0.1",
"lint-staged": "10.2.2",
"is-ci-cli": "2.1.2",
"jest": "26.4.0",
"lint-staged": "10.2.11",
"markdown-toc": "^1.2.0",
"mini-css-extract-plugin": "0.9.0",
"mini-css-extract-plugin": "0.10.0",
"mkdirp": "1.0.4",
"nopt": "4.0.3",
"postcss": "7.0.29",
"postcss": "7.0.32",
"postcss-cli": "7.1.1",
"postcss-import": "12.0.1",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.7.0",
"prettier": "2.0.5",
"ts-jest": "25.5.1",
"ts-loader": "7.0.3",
"ts-node": "8.10.1",
"typescript": "3.8.3",
"ts-jest": "26.2.0",
"ts-loader": "8.0.2",
"ts-node": "8.10.2",
"typescript": "3.9.7",
"url-loader": "4.1.0",
"webpack": "4.43.0",
"webpack-cli": "3.3.11",
"webpack": "4.44.1",
"webpack-cli": "3.3.12",
"webpack-dev-server": "3.11.0",
"whatwg-fetch": "3.0.0"
"whatwg-fetch": "3.4.0"
},
"resolutions": {
"lodash": ">=4.17.15",
Expand Down
1 change: 1 addition & 0 deletions scripts/hulk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function extractFiles(files: string[]): string[] {
`;

if (options.version) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
console.log(require('../package.json').version);
process.exit(0);
}
Expand Down
16 changes: 9 additions & 7 deletions src/ui/js/diff2html-ui-base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as HighlightJS from 'highlight.js/lib/core';
import { ICompiledMode, IHighlightResult, IAutoHighlightResult } from 'highlight.js';
// import { CompiledMode, HighlightResult, AutoHighlightResult } from 'highlight.js/lib/core.js';
import { nodeStream, mergeStreams } from './highlight.js-helpers';

import { html, Diff2HtmlConfig, defaultDiff2HtmlConfig } from '../../diff2html';
Expand Down Expand Up @@ -116,8 +116,8 @@ export class Diff2HtmlUI {
// Collect all the diff files and execute the highlight on their lines
const files = this.targetElement.querySelectorAll('.d2h-file-wrapper');
files.forEach(file => {
let oldLinesState: ICompiledMode;
let newLinesState: ICompiledMode;
let oldLinesState: CompiledMode | Language | undefined;
let newLinesState: CompiledMode | Language | undefined;

// Collect all the code lines and execute the highlight on them
const codeLines = file.querySelectorAll('.d2h-code-line-ctn');
Expand All @@ -133,12 +133,12 @@ export class Diff2HtmlUI {
const lineState = lineParent.classList.contains('d2h-del') ? oldLinesState : newLinesState;

const language = file.getAttribute('data-lang');
const result =
const result: HighlightResult =
language && this.hljs.getLanguage(language)
? this.hljs.highlight(language, text, true, lineState)
: this.hljs.highlightAuto(text);

if (this.instanceOfIHighlightResult(result)) {
if (this.instanceOfHighlightResult(result)) {
if (lineParent.classList.contains('d2h-del')) {
oldLinesState = result.top;
} else if (lineParent.classList.contains('d2h-ins')) {
Expand All @@ -157,7 +157,9 @@ export class Diff2HtmlUI {
}

line.classList.add('hljs');
line.classList.add(result.language);
if (result.language) {
line.classList.add(result.language);
}
line.innerHTML = result.value;
});
});
Expand All @@ -170,7 +172,7 @@ export class Diff2HtmlUI {
console.warn('Smart selection is now enabled by default with CSS. No need to call this method anymore.');
}

private instanceOfIHighlightResult(object: IHighlightResult | IAutoHighlightResult): object is IHighlightResult {
private instanceOfHighlightResult(object: HighlightResult | AutoHighlightResult): object is HighlightResult {
return 'top' in object;
}

Expand Down
5 changes: 0 additions & 5 deletions typings/highlight.js/highlight.js.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions typings/highlight.js/languages.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions typings/merge.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
declare module 'merge' {
// eslint-disable-next-line @typescript-eslint/ban-types
export function recursive(clone: boolean, ...items: object[]): object;
}
72 changes: 39 additions & 33 deletions webpack.website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,44 @@ import CopyWebpackPlugin from 'copy-webpack-plugin';

const pages = ['index', 'demo'];

function plugins(page: string): webpack.Plugin[] {
return [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new HtmlWebpackPlugin({
hash: true,
inject: true,
title: `${page} page`,
filename: `${page}.html`,
template: `./website/templates/pages/${page}/${page}.handlebars`,
minify: {
html5: true,
collapseWhitespace: true,
caseSensitive: true,
removeEmptyElements: false,
removeComments: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
}),
new CopyWebpackPlugin({
patterns: [
{ from: 'website/favicon.ico', to: 'favicon.ico' },
{ from: 'website/robots.txt', to: 'robots.txt' },
{ from: 'website/sitemap.xml', to: 'sitemap.xml' },
],
}),
];
}

const config: webpack.Configuration[] = pages.map(page => {
return {
devServer: {
Expand Down Expand Up @@ -108,39 +146,7 @@ const config: webpack.Configuration[] = pages.map(page => {
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new HtmlWebpackPlugin({
hash: true,
inject: true,
title: `${page} page`,
filename: `${page}.html`,
template: `./website/templates/pages/${page}/${page}.handlebars`,
minify: {
html5: true,
collapseWhitespace: true,
caseSensitive: true,
removeEmptyElements: false,
removeComments: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
}),
new CopyWebpackPlugin([
{ from: 'website/favicon.ico', to: 'favicon.ico' },
{ from: 'website/robots.txt', to: 'robots.txt' },
{ from: 'website/sitemap.xml', to: 'sitemap.xml' },
]),
],
plugins: plugins(page),
};
});

Expand Down
32 changes: 15 additions & 17 deletions website/templates/pages/demo/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,21 @@ async function prepareInitialState(elements: Elements): Promise<[Diff2HtmlUIConf
}

function updateBrowserUrl(config: Diff2HtmlUIConfig, newDiffUrl: string): void {
if (history.pushState) {
const paramString = Object.entries(config)
.map(([k, v]) => k + '=' + v)
.join('&');
const newPageUrl =
window.location.protocol +
'//' +
window.location.host +
window.location.pathname +
'?' +
paramString +
'&' +
searchParam +
'=' +
newDiffUrl;
window.history.pushState({ path: newPageUrl }, '', newPageUrl);
}
const paramString = Object.entries(config)
.map(([k, v]) => k + '=' + v)
.join('&');
const newPageUrl =
window.location.protocol +
'//' +
window.location.host +
window.location.pathname +
'?' +
paramString +
'&' +
searchParam +
'=' +
newDiffUrl;
window.history.pushState({ path: newPageUrl }, '', newPageUrl);
}

type Elements = {
Expand Down
Loading
0