Compare commits
2 commits
master
...
3.4.48-344
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acd5fedc68 | ||
|
|
135913d4bb |
21 changed files with 4251 additions and 4658 deletions
58
.eslintrc.js
Normal file
58
.eslintrc.js
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
module.exports = {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2018,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es6: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
globals: {
|
||||||
|
Atomics: 'readonly',
|
||||||
|
SharedArrayBuffer: 'readonly',
|
||||||
|
document: 'readonly',
|
||||||
|
navigator: 'readonly',
|
||||||
|
window: 'readonly',
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:@typescript-eslint/eslint-recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:json/recommended',
|
||||||
|
'plugin:promise/recommended',
|
||||||
|
'plugin:import/errors',
|
||||||
|
'plugin:import/warnings',
|
||||||
|
'plugin:import/typescript',
|
||||||
|
'plugin:node/recommended',
|
||||||
|
'plugin:sonarjs/recommended',
|
||||||
|
'plugin:jest/recommended',
|
||||||
|
'plugin:jest/style',
|
||||||
|
'prettier',
|
||||||
|
],
|
||||||
|
plugins: ['@typescript-eslint', 'json', 'promise', 'import', 'node', 'sonarjs', 'jest', 'optimize-regex'],
|
||||||
|
rules: {
|
||||||
|
// Enable
|
||||||
|
'optimize-regex/optimize-regex': 'error',
|
||||||
|
// Hack: For some reason we need pass again the extensions
|
||||||
|
'node/no-missing-import': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
tryExtensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// Disable
|
||||||
|
// https://github.com/benmosher/eslint-plugin-import/issues/1446
|
||||||
|
'import/named': 'off',
|
||||||
|
// We don't need this since we are using transpilation
|
||||||
|
'node/no-unsupported-features/es-syntax': 'off',
|
||||||
|
'no-process-exit': 'off',
|
||||||
|
// Too verbose
|
||||||
|
'sonarjs/no-duplicate-string': 'off',
|
||||||
|
// Too verbose
|
||||||
|
'sonarjs/cognitive-complexity': 'off',
|
||||||
|
// Too verbose
|
||||||
|
'sonarjs/no-nested-template-literals': 'off',
|
||||||
|
},
|
||||||
|
};
|
||||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
|
@ -19,7 +19,7 @@ jobs:
|
||||||
environment: 'production'
|
environment: 'production'
|
||||||
steps:
|
steps:
|
||||||
- name: Download docs
|
- name: Download docs
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: docs
|
name: docs
|
||||||
path: docs/
|
path: docs/
|
||||||
|
|
|
||||||
80
.github/workflows/test-and-publish.yml
vendored
80
.github/workflows/test-and-publish.yml
vendored
|
|
@ -25,7 +25,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=master)"
|
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=master)"
|
||||||
echo "Next version is ${NEXT_VERSION}"
|
echo "Next version is ${NEXT_VERSION}"
|
||||||
echo "${NEXT_VERSION}" > next-version.txt
|
echo "${NEXT_VERSION}" > .version
|
||||||
echo "version=${NEXT_VERSION}" >> $GITHUB_ENV
|
echo "version=${NEXT_VERSION}" >> $GITHUB_ENV
|
||||||
- name: Get next npm tag name
|
- name: Get next npm tag name
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -37,22 +37,22 @@ jobs:
|
||||||
export PUBLISH_TAG="pr"
|
export PUBLISH_TAG="pr"
|
||||||
fi
|
fi
|
||||||
echo "Next tag is ${PUBLISH_TAG}"
|
echo "Next tag is ${PUBLISH_TAG}"
|
||||||
echo "${PUBLISH_TAG}" > publish-tag.txt
|
echo "${PUBLISH_TAG}" > .tag
|
||||||
- name: Upload versions
|
- name: Upload versions
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: versions
|
name: versions
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
path: |
|
path: |
|
||||||
next-version.txt
|
.version
|
||||||
publish-tag.txt
|
.tag
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [version]
|
needs: [version]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [16.x, 18.x, 20.x, 22.x]
|
node-version: [16.x, 18.x, 20.x]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
|
@ -64,8 +64,8 @@ jobs:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
- name: Log environment setup
|
- name: Log environment setup
|
||||||
run: |
|
run: |
|
||||||
node -v
|
node -v
|
||||||
npm -v
|
npm -v
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Build templates
|
- name: Build templates
|
||||||
|
|
@ -82,66 +82,70 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Download versions
|
- name: Download versions
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: versions
|
name: versions
|
||||||
- name: Store version
|
- name: Store version
|
||||||
run: echo "version=$(cat next-version.txt)" >> $GITHUB_ENV
|
run: echo "version=$(cat .version)" >> $GITHUB_ENV
|
||||||
- name: Configure Git
|
- name: Configure Git
|
||||||
run: |
|
run: |
|
||||||
git config user.email "gh-actions@users.noreply.github.com"
|
git config user.email "gh-actions@users.noreply.github.com"
|
||||||
git config user.name "GitHub Actions"
|
git config user.name "GitHub Actions"
|
||||||
- name: Tag commit
|
- name: Tag commit
|
||||||
uses: tvdias/github-tagger@v0.0.1
|
uses: tvdias/github-tagger@v0.0.1
|
||||||
with:
|
with:
|
||||||
repo-token: '${{ secrets.GITHUB_TOKEN }}'
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
tag: '${{ env.version }}'
|
tag: "${{ env.version }}"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm install
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
node-version: '22.x'
|
node-version: '18.x'
|
||||||
- name: Configure NPM version
|
- name: Configure NPM version
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
rm -f .npmrc
|
rm -f .npmrc
|
||||||
touch .npmrc
|
touch .npmrc
|
||||||
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
|
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
|
||||||
echo "registry=https://registry.npmjs.org/" >> .npmrc
|
echo "registry=https://registry.npmjs.org/" >> .npmrc
|
||||||
echo "access=public" >> .npmrc
|
echo "access=public" >> .npmrc
|
||||||
echo "save-exact=true" >> .npmrc
|
echo "save-exact=true" >> .npmrc
|
||||||
- name: Version package
|
- name: Version package
|
||||||
run: |
|
run: |
|
||||||
# Update version in packages to publish
|
# Update version in packages to publish
|
||||||
npm version $(cat next-version.txt) -m "Release version %s"
|
npm version $(cat .version) -m "Release version %s"
|
||||||
- name: Publish to NPM
|
- name: Publish to NPM
|
||||||
run: npm publish --tag $(cat publish-tag.txt)
|
run: npm publish --tag $(cat .tag)
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '22.x'
|
node-version: '18.x'
|
||||||
registry-url: 'https://npm.pkg.github.com'
|
registry-url: 'https://npm.pkg.github.com'
|
||||||
- name: Configure NPM version
|
- name: Configure NPM version
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
rm -f .npmrc
|
rm -f .npmrc
|
||||||
touch .npmrc
|
touch .npmrc
|
||||||
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
|
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
|
||||||
echo "@rtfpessoa:registry=https://npm.pkg.github.com/" >> .npmrc
|
echo "@rtfpessoa:registry=https://npm.pkg.github.com/" >> .npmrc
|
||||||
echo "access=public" >> .npmrc
|
echo "access=public" >> .npmrc
|
||||||
echo "save-exact=true" >> .npmrc
|
echo "save-exact=true" >> .npmrc
|
||||||
|
- name: Version package
|
||||||
|
run: |
|
||||||
|
# Update version in packages to publish
|
||||||
|
npm version $(cat .version) -m "Release version %s"
|
||||||
- name: Publish to GPR
|
- name: Publish to GPR
|
||||||
run: |
|
run: |
|
||||||
# HACK: Override npm package name to be able to publish in GitHub
|
# HACK: Override npm package name to be able to publish in GitHub
|
||||||
sed -i 's/^ "name":.*/ "name": "@rtfpessoa\/diff2html",/g' package.json
|
sed -i 's/^ "name":.*/ "name": "@rtfpessoa\/diff2html",/g' package.json
|
||||||
echo "Going to publish version $(cat next-version.txt) to GitHub"
|
echo "Going to publish version $(cat .version) to GitHub"
|
||||||
npm publish --tag $(cat publish-tag.txt)
|
npm publish --tag $(cat .tag)
|
||||||
# HACK: Restore npm package name
|
# HACK: Restore npm package name
|
||||||
sed -i 's/^ "name":.*/ "name": "diff2html",/g' package.json
|
sed -i 's/^ "name":.*/ "name": "diff2html",/g' package.json
|
||||||
- name: Upload docs
|
- name: Upload docs
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: docs
|
name: docs
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
|
||||||
10
.gitignore
vendored
10
.gitignore
vendored
|
|
@ -29,18 +29,8 @@ bower_components/
|
||||||
# Terraform
|
# Terraform
|
||||||
/terraform/.terraform
|
/terraform/.terraform
|
||||||
|
|
||||||
# Compiled templates
|
|
||||||
/src/diff2html-templates.*
|
/src/diff2html-templates.*
|
||||||
|
|
||||||
# Compiled website
|
|
||||||
/docs/
|
/docs/
|
||||||
|
|
||||||
# Bundles temporary typescript files compiled by webpack
|
|
||||||
/bundles-out/
|
|
||||||
|
|
||||||
# Web bundles
|
|
||||||
/bundles/
|
/bundles/
|
||||||
# CommonJS library
|
|
||||||
/lib/
|
/lib/
|
||||||
# ESNext library
|
|
||||||
/lib-esm/
|
/lib-esm/
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
npm run lint:staged
|
npm run lint:staged
|
||||||
|
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
import globals from 'globals';
|
|
||||||
import eslint from '@eslint/js';
|
|
||||||
import tseslint from 'typescript-eslint';
|
|
||||||
import pluginJest from 'eslint-plugin-jest';
|
|
||||||
import json from '@eslint/json';
|
|
||||||
import pluginPromise from 'eslint-plugin-promise';
|
|
||||||
|
|
||||||
export default [
|
|
||||||
{ ...eslint.configs.recommended, files: ['src/**/*.{js,mjs,cjs,ts}'] },
|
|
||||||
...tseslint.configs.recommended,
|
|
||||||
// ...tseslint.configs.recommendedTypeChecked,
|
|
||||||
// ...tseslint.configs.strict,
|
|
||||||
// ...tseslint.configs.stylistic,
|
|
||||||
// ...tseslint.configs.strictTypeChecked,
|
|
||||||
// ...tseslint.configs.stylisticTypeChecked,
|
|
||||||
{
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/no-unused-vars': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
args: 'all',
|
|
||||||
argsIgnorePattern: '^_',
|
|
||||||
caughtErrors: 'all',
|
|
||||||
caughtErrorsIgnorePattern: '^_',
|
|
||||||
destructuredArrayIgnorePattern: '^_',
|
|
||||||
varsIgnorePattern: '^_',
|
|
||||||
ignoreRestSiblings: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
pluginPromise.configs['flat/recommended'],
|
|
||||||
{
|
|
||||||
plugins: {
|
|
||||||
json,
|
|
||||||
},
|
|
||||||
files: ['**/*.json'],
|
|
||||||
language: 'json/json',
|
|
||||||
rules: {
|
|
||||||
'json/no-duplicate-keys': 'error',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...pluginJest.configs['flat/recommended'],
|
|
||||||
...pluginJest.configs['flat/style'],
|
|
||||||
files: ['src/__tests__/**/*tests.ts'],
|
|
||||||
plugins: { jest: pluginJest },
|
|
||||||
languageOptions: {
|
|
||||||
globals: pluginJest.environments.globals.globals,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
...globals.browser,
|
|
||||||
...globals.node,
|
|
||||||
...globals.es2025,
|
|
||||||
Atomics: 'readonly',
|
|
||||||
SharedArrayBuffer: 'readonly',
|
|
||||||
document: 'readonly',
|
|
||||||
navigator: 'readonly',
|
|
||||||
window: 'readonly',
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
project: './tsconfig.eslint.json',
|
|
||||||
tsconfigRootDir: './',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ignores: ['src/diff2html-templates.*', 'coverage/', 'docs/', 'bundles-out/', 'bundles/', 'lib/', 'lib-esm/'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...tseslint.configs.disableTypeChecked,
|
|
||||||
files: ['**/*.{js,mjs,cjs}'],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
@ -19,5 +19,4 @@ module.exports = {
|
||||||
lines: 93,
|
lines: 93,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
prettierPath: require.resolve('prettier-2'),
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
8262
package-lock.json
generated
8262
package-lock.json
generated
File diff suppressed because it is too large
Load diff
72
package.json
72
package.json
|
|
@ -35,6 +35,7 @@
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"eslint": "eslint --ignore-path .gitignore \"**/*.{js,jsx,ts,tsx,json}\"",
|
||||||
"lint:staged": "lint-staged",
|
"lint:staged": "lint-staged",
|
||||||
"lint:check": "eslint",
|
"lint:check": "eslint",
|
||||||
"lint:fix": "eslint --fix",
|
"lint:fix": "eslint --fix",
|
||||||
|
|
@ -42,7 +43,7 @@
|
||||||
"format:check": "npm run prettier --check",
|
"format:check": "npm run prettier --check",
|
||||||
"format:fix": "npm run prettier --write",
|
"format:fix": "npm run prettier --write",
|
||||||
"build": "npm run build:css && npm run build:templates && npm run build:commonjs && npm run build:esm && npm run build:bundles && npm run build:website",
|
"build": "npm run build:css && npm run build:templates && npm run build:commonjs && npm run build:esm && npm run build:bundles && npm run build:website",
|
||||||
"build:commonjs": "rm -rf lib; tsc -p tsconfig.json -m CommonJS --outDir lib",
|
"build:commonjs": "rm -rf lib; tsc -p tsconfig.json --outDir lib",
|
||||||
"build:esm": "rm -rf lib-esm; tsc -p tsconfig.json -m ESNext --outDir lib-esm",
|
"build:esm": "rm -rf lib-esm; tsc -p tsconfig.json -m ESNext --outDir lib-esm",
|
||||||
"build:bundles": "rm -rf ./bundles/js; webpack --mode production --config webpack.bundles.ts",
|
"build:bundles": "rm -rf ./bundles/js; webpack --mode production --config webpack.bundles.ts",
|
||||||
"build:css": "rm -rf ./bundles/css; postcss --config ./postcss.config.js --no-map -o ./bundles/css/diff2html.min.css ./src/ui/css/diff2html.css",
|
"build:css": "rm -rf ./bundles/css; postcss --config ./postcss.config.js --no-map -o ./bundles/css/diff2html.min.css ./src/ui/css/diff2html.css",
|
||||||
|
|
@ -63,7 +64,7 @@
|
||||||
"start:website": "webpack serve --mode development --config webpack.website.ts",
|
"start:website": "webpack serve --mode development --config webpack.website.ts",
|
||||||
"preversion": "npm run validate",
|
"preversion": "npm run validate",
|
||||||
"version": "git add -A package.json",
|
"version": "git add -A package.json",
|
||||||
"prepare": "husky"
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
"main": "./lib/diff2html.js",
|
"main": "./lib/diff2html.js",
|
||||||
"module": "./lib-esm/diff2html.js",
|
"module": "./lib-esm/diff2html.js",
|
||||||
|
|
@ -81,60 +82,63 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"diff": "^7.0.0",
|
"diff": "5.1.0",
|
||||||
"hogan.js": "3.0.2"
|
"hogan.js": "3.0.2"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"highlight.js": "11.9.0"
|
"highlight.js": "11.9.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier-2": "npm:prettier@^2",
|
"@types/diff": "5.0.9",
|
||||||
"@eslint/js": "^9.17.0",
|
|
||||||
"@eslint/json": "^0.9.0",
|
|
||||||
"@types/diff": "^6.0.0",
|
|
||||||
"@types/hogan.js": "3.0.5",
|
"@types/hogan.js": "3.0.5",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "29.5.11",
|
||||||
"@types/node": "^22.10.2",
|
"@types/node": "20.11.0",
|
||||||
"@types/nopt": "3.0.32",
|
"@types/nopt": "3.0.32",
|
||||||
|
"@typescript-eslint/eslint-plugin": "6.18.1",
|
||||||
|
"@typescript-eslint/parser": "6.18.1",
|
||||||
"all-contributors-cli": "^6.24.0",
|
"all-contributors-cli": "^6.24.0",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "10.4.16",
|
||||||
"bulma": "^1.0.2",
|
"bulma": "^0.9.4",
|
||||||
"clipboard": "2.0.11",
|
"clipboard": "2.0.11",
|
||||||
"copy-webpack-plugin": "^12.0.2",
|
"copy-webpack-plugin": "12.0.1",
|
||||||
"css-loader": "^7.1.2",
|
"css-loader": "6.9.0",
|
||||||
"cssnano": "^7.0.6",
|
"cssnano": "6.0.3",
|
||||||
"eslint": "^9.17.0",
|
"eslint": "8.56.0",
|
||||||
"eslint-plugin-jest": "28.10.0",
|
"eslint-config-prettier": "9.1.0",
|
||||||
"eslint-plugin-promise": "^7.2.1",
|
"eslint-plugin-import": "2.29.1",
|
||||||
|
"eslint-plugin-jest": "27.6.3",
|
||||||
|
"eslint-plugin-json": "3.1.0",
|
||||||
|
"eslint-plugin-node": "11.1.0",
|
||||||
|
"eslint-plugin-optimize-regex": "1.2.1",
|
||||||
|
"eslint-plugin-promise": "6.1.1",
|
||||||
|
"eslint-plugin-sonarjs": "0.23.0",
|
||||||
"file-loader": "6.2.0",
|
"file-loader": "6.2.0",
|
||||||
"globals": "^15.14.0",
|
|
||||||
"handlebars": "4.7.8",
|
"handlebars": "4.7.8",
|
||||||
"handlebars-loader": "1.7.3",
|
"handlebars-loader": "1.7.3",
|
||||||
"html-webpack-plugin": "^5.6.3",
|
"html-webpack-plugin": "5.6.0",
|
||||||
"husky": "^9.1.7",
|
"husky": "^8.0.1",
|
||||||
"image-webpack-loader": "8.1.0",
|
"image-webpack-loader": "8.1.0",
|
||||||
"is-ci-cli": "2.2.0",
|
"is-ci-cli": "2.2.0",
|
||||||
"jest": "29.7.0",
|
"jest": "29.7.0",
|
||||||
"lint-staged": "^15.2.11",
|
"lint-staged": "15.2.0",
|
||||||
"markdown-toc": "^1.2.0",
|
"markdown-toc": "^1.2.0",
|
||||||
"mini-css-extract-plugin": "^2.9.2",
|
"mini-css-extract-plugin": "2.7.7",
|
||||||
"mkdirp": "3.0.1",
|
"mkdirp": "3.0.1",
|
||||||
"nopt": "^8.0.0",
|
"nopt": "7.2.0",
|
||||||
"postcss": "^8.4.49",
|
"postcss": "8.4.33",
|
||||||
"postcss-cli": "11.0.0",
|
"postcss-cli": "11.0.0",
|
||||||
"postcss-import": "^16.1.0",
|
"postcss-import": "16.0.0",
|
||||||
"postcss-loader": "^8.1.1",
|
"postcss-loader": "7.3.4",
|
||||||
"postcss-preset-env": "^10.1.2",
|
"postcss-preset-env": "9.3.0",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "3.2.1",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "29.1.1",
|
||||||
"ts-loader": "9.5.1",
|
"ts-loader": "9.5.1",
|
||||||
"ts-node": "10.9.2",
|
"ts-node": "10.9.2",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "5.3.3",
|
||||||
"typescript-eslint": "^8.18.2",
|
|
||||||
"url-loader": "4.1.1",
|
"url-loader": "4.1.1",
|
||||||
"webpack": "^5.97.1",
|
"webpack": "5.89.0",
|
||||||
"webpack-cli": "^6.0.1",
|
"webpack-cli": "5.1.4",
|
||||||
"webpack-dev-server": "^5.2.0",
|
"webpack-dev-server": "4.15.1",
|
||||||
"whatwg-fetch": "3.6.20"
|
"whatwg-fetch": "3.6.20"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ function extractFiles(files: string[]): string[] {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
if (options.version) {
|
if (options.version) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
console.log(require('../package.json').version);
|
console.log(require('../package.json').version);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { parse } from '../diff-parser';
|
||||||
|
|
||||||
describe('DiffParser', () => {
|
describe('DiffParser', () => {
|
||||||
describe('generateDiffJson', () => {
|
describe('generateDiffJson', () => {
|
||||||
|
// eslint-disable-next-line jest/expect-expect
|
||||||
it('should parse unix with \n diff', () => {
|
it('should parse unix with \n diff', () => {
|
||||||
const diff =
|
const diff =
|
||||||
'diff --git a/sample b/sample\n' +
|
'diff --git a/sample b/sample\n' +
|
||||||
|
|
@ -51,6 +52,7 @@ describe('DiffParser', () => {
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/expect-expect
|
||||||
it('should parse windows with \r\n diff', () => {
|
it('should parse windows with \r\n diff', () => {
|
||||||
const diff =
|
const diff =
|
||||||
'diff --git a/sample b/sample\r\n' +
|
'diff --git a/sample b/sample\r\n' +
|
||||||
|
|
@ -100,6 +102,7 @@ describe('DiffParser', () => {
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/expect-expect
|
||||||
it('should parse old os x with \r diff', () => {
|
it('should parse old os x with \r diff', () => {
|
||||||
const diff =
|
const diff =
|
||||||
'diff --git a/sample b/sample\r' +
|
'diff --git a/sample b/sample\r' +
|
||||||
|
|
@ -149,6 +152,7 @@ describe('DiffParser', () => {
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/expect-expect
|
||||||
it('should parse mixed eols diff', () => {
|
it('should parse mixed eols diff', () => {
|
||||||
const diff =
|
const diff =
|
||||||
'diff --git a/sample b/sample\n' +
|
'diff --git a/sample b/sample\n' +
|
||||||
|
|
|
||||||
|
|
@ -928,7 +928,7 @@ describe('Diff2Html', () => {
|
||||||
<td class="d2h-del d2h-change">
|
<td class="d2h-del d2h-change">
|
||||||
<div class="d2h-code-line">
|
<div class="d2h-code-line">
|
||||||
<span class="d2h-code-line-prefix">-</span>
|
<span class="d2h-code-line-prefix">-</span>
|
||||||
<span class="d2h-code-line-ctn"><<del>!-- commented code --</del>></span>
|
<span class="d2h-code-line-ctn"><del><!-- commented code --></del></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
|
|
@ -939,7 +939,7 @@ describe('Diff2Html', () => {
|
||||||
<td class="d2h-del d2h-change">
|
<td class="d2h-del d2h-change">
|
||||||
<div class="d2h-code-line">
|
<div class="d2h-code-line">
|
||||||
<span class="d2h-code-line-prefix">-</span>
|
<span class="d2h-code-line-prefix">-</span>
|
||||||
<span class="d2h-code-line-ctn"><<del>/div</del>></span>
|
<span class="d2h-code-line-ctn"><del></div</del>></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
|
|
@ -950,7 +950,7 @@ describe('Diff2Html', () => {
|
||||||
<td class="d2h-ins d2h-change">
|
<td class="d2h-ins d2h-change">
|
||||||
<div class="d2h-code-line">
|
<div class="d2h-code-line">
|
||||||
<span class="d2h-code-line-prefix">+</span>
|
<span class="d2h-code-line-prefix">+</span>
|
||||||
<span class="d2h-code-line-ctn"><<ins>html</ins>></span>
|
<span class="d2h-code-line-ctn"><ins><html></ins></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
|
|
@ -961,7 +961,7 @@ describe('Diff2Html', () => {
|
||||||
<td class="d2h-ins d2h-change">
|
<td class="d2h-ins d2h-change">
|
||||||
<div class="d2h-code-line">
|
<div class="d2h-code-line">
|
||||||
<span class="d2h-code-line-prefix">+</span>
|
<span class="d2h-code-line-prefix">+</span>
|
||||||
<span class="d2h-code-line-ctn"><<ins>body</ins>></span>
|
<span class="d2h-code-line-ctn"><ins><body</ins>></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -1326,78 +1326,78 @@ describe('Diff2Html', () => {
|
||||||
colorScheme: ColorSchemeType.AUTO,
|
colorScheme: ColorSchemeType.AUTO,
|
||||||
});
|
});
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
"<div class="d2h-file-list-wrapper d2h-auto-color-scheme">
|
"<div class="d2h-file-list-wrapper d2h-auto-color-scheme">
|
||||||
<div class="d2h-file-list-header">
|
<div class="d2h-file-list-header">
|
||||||
<span class="d2h-file-list-title">Files changed (1)</span>
|
<span class="d2h-file-list-title">Files changed (1)</span>
|
||||||
<a class="d2h-file-switch d2h-hide">hide</a>
|
<a class="d2h-file-switch d2h-hide">hide</a>
|
||||||
<a class="d2h-file-switch d2h-show">show</a>
|
<a class="d2h-file-switch d2h-show">show</a>
|
||||||
</div>
|
</div>
|
||||||
<ol class="d2h-file-list">
|
<ol class="d2h-file-list">
|
||||||
<li class="d2h-file-list-line">
|
<li class="d2h-file-list-line">
|
||||||
<span class="d2h-file-name-wrapper">
|
<span class="d2h-file-name-wrapper">
|
||||||
<svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"
|
<svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"
|
||||||
viewBox="0 0 14 16" width="14">
|
viewBox="0 0 14 16" width="14">
|
||||||
<path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>
|
<path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>
|
||||||
</svg> <a href="#d2h-675094" class="d2h-file-name">sample</a>
|
</svg> <a href="#d2h-675094" class="d2h-file-name">sample</a>
|
||||||
<span class="d2h-file-stats">
|
<span class="d2h-file-stats">
|
||||||
<span class="d2h-lines-added">+1</span>
|
<span class="d2h-lines-added">+1</span>
|
||||||
<span class="d2h-lines-deleted">-1</span>
|
<span class="d2h-lines-deleted">-1</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div><div class="d2h-wrapper d2h-auto-color-scheme">
|
</div><div class="d2h-wrapper d2h-auto-color-scheme">
|
||||||
<div id="d2h-675094" class="d2h-file-wrapper" data-lang="">
|
<div id="d2h-675094" class="d2h-file-wrapper" data-lang="">
|
||||||
<div class="d2h-file-header">
|
<div class="d2h-file-header">
|
||||||
<span class="d2h-file-name-wrapper">
|
<span class="d2h-file-name-wrapper">
|
||||||
<svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">
|
<svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">
|
||||||
<path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>
|
<path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>
|
||||||
</svg> <span class="d2h-file-name">sample</span>
|
</svg> <span class="d2h-file-name">sample</span>
|
||||||
<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>
|
<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>
|
||||||
<label class="d2h-file-collapse">
|
<label class="d2h-file-collapse">
|
||||||
<input class="d2h-file-collapse-input" type="checkbox" name="viewed" value="viewed">
|
<input class="d2h-file-collapse-input" type="checkbox" name="viewed" value="viewed">
|
||||||
Viewed
|
Viewed
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="d2h-file-diff">
|
<div class="d2h-file-diff">
|
||||||
<div class="d2h-code-wrapper">
|
<div class="d2h-code-wrapper">
|
||||||
<table class="d2h-diff-table">
|
<table class="d2h-diff-table">
|
||||||
<tbody class="d2h-diff-tbody">
|
<tbody class="d2h-diff-tbody">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="d2h-code-linenumber d2h-info"></td>
|
<td class="d2h-code-linenumber d2h-info"></td>
|
||||||
<td class="d2h-info">
|
<td class="d2h-info">
|
||||||
<div class="d2h-code-line">@@ -1 +1 @@</div>
|
<div class="d2h-code-line">@@ -1 +1 @@</div>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td class="d2h-code-linenumber d2h-del d2h-change">
|
<td class="d2h-code-linenumber d2h-del d2h-change">
|
||||||
<div class="line-num1">1</div>
|
<div class="line-num1">1</div>
|
||||||
<div class="line-num2"></div>
|
<div class="line-num2"></div>
|
||||||
</td>
|
</td>
|
||||||
<td class="d2h-del d2h-change">
|
<td class="d2h-del d2h-change">
|
||||||
<div class="d2h-code-line">
|
<div class="d2h-code-line">
|
||||||
<span class="d2h-code-line-prefix">-</span>
|
<span class="d2h-code-line-prefix">-</span>
|
||||||
<span class="d2h-code-line-ctn"><del>test</del></span>
|
<span class="d2h-code-line-ctn"><del>test</del></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td class="d2h-code-linenumber d2h-ins d2h-change">
|
<td class="d2h-code-linenumber d2h-ins d2h-change">
|
||||||
<div class="line-num1"></div>
|
<div class="line-num1"></div>
|
||||||
<div class="line-num2">1</div>
|
<div class="line-num2">1</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="d2h-ins d2h-change">
|
<td class="d2h-ins d2h-change">
|
||||||
<div class="d2h-code-line">
|
<div class="d2h-code-line">
|
||||||
<span class="d2h-code-line-prefix">+</span>
|
<span class="d2h-code-line-prefix">+</span>
|
||||||
<span class="d2h-code-line-ctn"><ins>test1</ins></span>
|
<span class="d2h-code-line-ctn"><ins>test1</ins></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>"
|
</div>"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1468,78 +1468,78 @@ describe('Diff2Html', () => {
|
||||||
colorScheme: ColorSchemeType.DARK,
|
colorScheme: ColorSchemeType.DARK,
|
||||||
});
|
});
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
"<div class="d2h-file-list-wrapper d2h-dark-color-scheme">
|
"<div class="d2h-file-list-wrapper d2h-dark-color-scheme">
|
||||||
<div class="d2h-file-list-header">
|
<div class="d2h-file-list-header">
|
||||||
<span class="d2h-file-list-title">Files changed (1)</span>
|
<span class="d2h-file-list-title">Files changed (1)</span>
|
||||||
<a class="d2h-file-switch d2h-hide">hide</a>
|
<a class="d2h-file-switch d2h-hide">hide</a>
|
||||||
<a class="d2h-file-switch d2h-show">show</a>
|
<a class="d2h-file-switch d2h-show">show</a>
|
||||||
</div>
|
</div>
|
||||||
<ol class="d2h-file-list">
|
<ol class="d2h-file-list">
|
||||||
<li class="d2h-file-list-line">
|
<li class="d2h-file-list-line">
|
||||||
<span class="d2h-file-name-wrapper">
|
<span class="d2h-file-name-wrapper">
|
||||||
<svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"
|
<svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"
|
||||||
viewBox="0 0 14 16" width="14">
|
viewBox="0 0 14 16" width="14">
|
||||||
<path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>
|
<path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>
|
||||||
</svg> <a href="#d2h-675094" class="d2h-file-name">sample</a>
|
</svg> <a href="#d2h-675094" class="d2h-file-name">sample</a>
|
||||||
<span class="d2h-file-stats">
|
<span class="d2h-file-stats">
|
||||||
<span class="d2h-lines-added">+1</span>
|
<span class="d2h-lines-added">+1</span>
|
||||||
<span class="d2h-lines-deleted">-1</span>
|
<span class="d2h-lines-deleted">-1</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div><div class="d2h-wrapper d2h-dark-color-scheme">
|
</div><div class="d2h-wrapper d2h-dark-color-scheme">
|
||||||
<div id="d2h-675094" class="d2h-file-wrapper" data-lang="">
|
<div id="d2h-675094" class="d2h-file-wrapper" data-lang="">
|
||||||
<div class="d2h-file-header">
|
<div class="d2h-file-header">
|
||||||
<span class="d2h-file-name-wrapper">
|
<span class="d2h-file-name-wrapper">
|
||||||
<svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">
|
<svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">
|
||||||
<path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>
|
<path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>
|
||||||
</svg> <span class="d2h-file-name">sample</span>
|
</svg> <span class="d2h-file-name">sample</span>
|
||||||
<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>
|
<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>
|
||||||
<label class="d2h-file-collapse">
|
<label class="d2h-file-collapse">
|
||||||
<input class="d2h-file-collapse-input" type="checkbox" name="viewed" value="viewed">
|
<input class="d2h-file-collapse-input" type="checkbox" name="viewed" value="viewed">
|
||||||
Viewed
|
Viewed
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="d2h-file-diff">
|
<div class="d2h-file-diff">
|
||||||
<div class="d2h-code-wrapper">
|
<div class="d2h-code-wrapper">
|
||||||
<table class="d2h-diff-table">
|
<table class="d2h-diff-table">
|
||||||
<tbody class="d2h-diff-tbody">
|
<tbody class="d2h-diff-tbody">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="d2h-code-linenumber d2h-info"></td>
|
<td class="d2h-code-linenumber d2h-info"></td>
|
||||||
<td class="d2h-info">
|
<td class="d2h-info">
|
||||||
<div class="d2h-code-line">@@ -1 +1 @@</div>
|
<div class="d2h-code-line">@@ -1 +1 @@</div>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td class="d2h-code-linenumber d2h-del d2h-change">
|
<td class="d2h-code-linenumber d2h-del d2h-change">
|
||||||
<div class="line-num1">1</div>
|
<div class="line-num1">1</div>
|
||||||
<div class="line-num2"></div>
|
<div class="line-num2"></div>
|
||||||
</td>
|
</td>
|
||||||
<td class="d2h-del d2h-change">
|
<td class="d2h-del d2h-change">
|
||||||
<div class="d2h-code-line">
|
<div class="d2h-code-line">
|
||||||
<span class="d2h-code-line-prefix">-</span>
|
<span class="d2h-code-line-prefix">-</span>
|
||||||
<span class="d2h-code-line-ctn"><del>test</del></span>
|
<span class="d2h-code-line-ctn"><del>test</del></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td class="d2h-code-linenumber d2h-ins d2h-change">
|
<td class="d2h-code-linenumber d2h-ins d2h-change">
|
||||||
<div class="line-num1"></div>
|
<div class="line-num1"></div>
|
||||||
<div class="line-num2">1</div>
|
<div class="line-num2">1</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="d2h-ins d2h-change">
|
<td class="d2h-ins d2h-change">
|
||||||
<div class="d2h-code-line">
|
<div class="d2h-code-line">
|
||||||
<span class="d2h-code-line-prefix">+</span>
|
<span class="d2h-code-line-prefix">+</span>
|
||||||
<span class="d2h-code-line-ctn"><ins>test1</ins></span>
|
<span class="d2h-code-line-ctn"><ins>test1</ins></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>"
|
</div>"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -458,16 +458,18 @@ export function parse(diffInput: string, config: DiffParserConfig = {}): DiffFil
|
||||||
} else if ((values = index.exec(line))) {
|
} else if ((values = index.exec(line))) {
|
||||||
currentFile.checksumBefore = values[1];
|
currentFile.checksumBefore = values[1];
|
||||||
currentFile.checksumAfter = values[2];
|
currentFile.checksumAfter = values[2];
|
||||||
if (values[3]) currentFile.mode = values[3];
|
values[3] && (currentFile.mode = values[3]);
|
||||||
} else if ((values = combinedIndex.exec(line))) {
|
} else if ((values = combinedIndex.exec(line))) {
|
||||||
currentFile.checksumBefore = [values[2], values[3]];
|
currentFile.checksumBefore = [values[2], values[3]];
|
||||||
currentFile.checksumAfter = values[1];
|
currentFile.checksumAfter = values[1];
|
||||||
} else if ((values = combinedMode.exec(line))) {
|
} else if ((values = combinedMode.exec(line))) {
|
||||||
currentFile.oldMode = [values[2], values[3]];
|
currentFile.oldMode = [values[2], values[3]];
|
||||||
currentFile.newMode = values[1];
|
currentFile.newMode = values[1];
|
||||||
|
// eslint-disable-next-line sonarjs/no-duplicated-branches
|
||||||
} else if ((values = combinedNewFile.exec(line))) {
|
} else if ((values = combinedNewFile.exec(line))) {
|
||||||
currentFile.newFileMode = values[1];
|
currentFile.newFileMode = values[1];
|
||||||
currentFile.isNew = true;
|
currentFile.isNew = true;
|
||||||
|
// eslint-disable-next-line sonarjs/no-duplicated-branches
|
||||||
} else if ((values = combinedDeletedFile.exec(line))) {
|
} else if ((values = combinedDeletedFile.exec(line))) {
|
||||||
currentFile.deletedFileMode = values[1];
|
currentFile.deletedFileMode = values[1];
|
||||||
currentFile.isDeleted = true;
|
currentFile.isDeleted = true;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export default class HoganJsUtils {
|
||||||
try {
|
try {
|
||||||
const template = this.preCompiledTemplates[templateKey];
|
const template = this.preCompiledTemplates[templateKey];
|
||||||
return template.render(params, partials, indent);
|
return template.render(params, partials, indent);
|
||||||
} catch (_e) {
|
} catch (e) {
|
||||||
throw new Error(`Could not find template to render '${templateKey}'`);
|
throw new Error(`Could not find template to render '${templateKey}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,8 @@ export class Diff2HtmlUI {
|
||||||
|
|
||||||
let hljsLanguage =
|
let hljsLanguage =
|
||||||
language && this.config.highlightLanguages.has(language)
|
language && this.config.highlightLanguages.has(language)
|
||||||
? this.config.highlightLanguages.get(language)!
|
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
this.config.highlightLanguages.get(language)!
|
||||||
: language
|
: language
|
||||||
? getLanguage(language)
|
? getLanguage(language)
|
||||||
: 'plaintext';
|
: 'plaintext';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "./tsconfig.json",
|
|
||||||
"exclude": ["node_modules"],
|
|
||||||
"include": ["./**/*"]
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"include": ["src/**/*", "typings/**/*"],
|
"include": ["*env.d.ts", "src/**/*", "./typings/**/*"],
|
||||||
"exclude": ["node_modules", "src/__tests__/**"],
|
"exclude": ["node_modules", "src/__tests__/**"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "bundles-out",
|
"outDir": "lib",
|
||||||
"module": "CommonJS",
|
"module": "CommonJS",
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"target": "ES6",
|
"target": "ES6",
|
||||||
|
|
|
||||||
1
typings/merge.d.ts
vendored
1
typings/merge.d.ts
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
declare module 'merge' {
|
declare module 'merge' {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export function recursive(clone: boolean, ...items: object[]): object;
|
export function recursive(clone: boolean, ...items: object[]): object;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import path from 'path';
|
||||||
import webpack from 'webpack';
|
import webpack from 'webpack';
|
||||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
||||||
|
// eslint-disable-next-line import/default
|
||||||
import CopyPlugin from 'copy-webpack-plugin';
|
import CopyPlugin from 'copy-webpack-plugin';
|
||||||
|
|
||||||
const pages = ['index', 'demo'];
|
const pages = ['index', 'demo'];
|
||||||
|
|
|
||||||
|
|
@ -123,16 +123,10 @@ function prepareRequest(url: string): Request {
|
||||||
|
|
||||||
function getConfiguration(urlParams: URLParams): Diff2HtmlUIConfig {
|
function getConfiguration(urlParams: URLParams): Diff2HtmlUIConfig {
|
||||||
// Removing `diff` and `diffTooBigMessage` form `urlParams` to avoid being inserted
|
// Removing `diff` and `diffTooBigMessage` form `urlParams` to avoid being inserted
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const { diff, diffTooBigMessage, ...urlParamsRest } = urlParams;
|
const { diff, diffTooBigMessage, ...urlParamsRest } = urlParams;
|
||||||
|
|
||||||
const defaultColorScheme: ColorSchemeType =
|
|
||||||
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
||||||
? ColorSchemeType.DARK
|
|
||||||
: ColorSchemeType.LIGHT;
|
|
||||||
|
|
||||||
const config: URLParams = {
|
const config: URLParams = {
|
||||||
...defaultDiff2HtmlUIConfig,
|
...defaultDiff2HtmlUIConfig,
|
||||||
colorScheme: defaultColorScheme,
|
|
||||||
...urlParamsRest,
|
...urlParamsRest,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -251,7 +245,6 @@ function getHTMLElementById(id: string): HTMLElement {
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
// Improves browser compatibility
|
// Improves browser compatibility
|
||||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
||||||
require('whatwg-fetch');
|
require('whatwg-fetch');
|
||||||
|
|
||||||
const drawAndUpdateUrl = async (
|
const drawAndUpdateUrl = async (
|
||||||
|
|
@ -289,13 +282,13 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
let [config, diffString] = await prepareInitialState(elements);
|
let [config, diffString] = await prepareInitialState(elements);
|
||||||
|
|
||||||
// Update HTML inputs from any changes in URL
|
// Update HTML inputs from any changes in URL
|
||||||
if (config.outputFormat) elements.options.outputFormat.value = config.outputFormat;
|
config.outputFormat && (elements.options.outputFormat.value = config.outputFormat);
|
||||||
if (config.colorScheme) elements.options.colorScheme.value = config.colorScheme;
|
config.colorScheme && (elements.options.colorScheme.value = config.colorScheme);
|
||||||
if (config.drawFileList) elements.checkboxes.drawFileList.checked = config.drawFileList;
|
config.drawFileList && (elements.checkboxes.drawFileList.checked = config.drawFileList);
|
||||||
if (config.matching) elements.options.matching.value = config.matching;
|
config.matching && (elements.options.matching.value = config.matching);
|
||||||
if (config.matchWordsThreshold) elements.options.wordsThreshold.value = config.matchWordsThreshold.toString();
|
config.matchWordsThreshold && (elements.options.wordsThreshold.value = config.matchWordsThreshold.toString());
|
||||||
if (config.matchingMaxComparisons)
|
config.matchingMaxComparisons &&
|
||||||
elements.options.matchingMaxComparisons.value = config.matchingMaxComparisons.toString();
|
(elements.options.matchingMaxComparisons.value = config.matchingMaxComparisons.toString());
|
||||||
|
|
||||||
Object.entries(elements.options).forEach(([option, element]) =>
|
Object.entries(elements.options).forEach(([option, element]) =>
|
||||||
element.addEventListener('change', () => {
|
element.addEventListener('change', () => {
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,5 @@ import '../../../main.ts';
|
||||||
import '../../../main.css';
|
import '../../../main.css';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-new
|
||||||
new Clipboard(document.getElementsByClassName('clipboard')[0]);
|
new Clipboard(document.getElementsByClassName('clipboard')[0]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue