Skip to content

Commit

Permalink
update to monorepo for react/vue support
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWangJustToDo committed Jan 18, 2024
1 parent 97f9c3d commit 0d8ada9
Show file tree
Hide file tree
Showing 77 changed files with 3,942 additions and 951 deletions.
21 changes: 6 additions & 15 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
env: {
node: true,
},
}
// eslint will auto add `eslint-config` for a no scope package(which not start with '@' chart), so here use absolute file path
extends: [require.resolve("project-tool/baseLint")],
ignorePatterns: ["dist", "dev"],
};
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build
run: pnpm run build:packages && pnpm run build:react
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload dist repository
path: './dist'
path: './ui/react-example/dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/node_modules
**/dist
**/dev
pnpm-lock.yaml
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": false,
"tabWidth": 2,
"useTabs": false,
"printWidth": 160
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 MrWangJustToDo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
48 changes: 21 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
{
"name": "git-diff-view",
"private": true,
"version": "0.0.0",
"type": "module",
"license": "MIT",
"author": "MrWangJustToDo",
"version": "0.0.1",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"build:packages": "ts-node ./scripts/build.ts",
"dev:react": "cd ui/react-example && pnpm run dev",
"build:react": "cd ui/react-example && pnpm run build",
"lint": "eslint --cache --ext ts,tsx .",
"lint:fix": "pnpm run lint --fix",
"prettier": "prettier --ignore-path .prettierignore --write .",
"clean": "pnpm -p -r -c exec rm -rf dist dev .cache",
"purge": "pnpm -p -r -c exec rm -rf node_modules"
},
"packageManager": "[email protected]",
"dependencies": {
"@my-react/react": "0.3.0",
"@my-react/react-dom": "0.3.0",
"highlight.js": "^11.9.0",
"lodash": "^4.17.21",
"lowlight": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"reactivity-store": "^0.3.1"
},
"devDependencies": {
"@my-react/react-refresh": "0.3.0",
"@my-react/react-vite": "0.0.3",
"@swc/core": "^1.3.100",
"@types/lodash": "^4.14.202",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"@types/node": "^20.11.5",
"@types/react": "^18.2.45",
"autoprefixer": "^10.4.16",
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"husky": "^8.0.2",
"postcss": "^8.4.33",
"prettier": "^3.2.4",
"project-tool": "https://github.com/MrWangJustToDo/project-tool.git",
"rollup-plugin-postcss": "^4.0.2",
"tailwindcss": "^3.4.1",
"typescript": "^5.2.2",
"vite": "^5.0.8"
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typescript": "^5.3.3"
}
}
21 changes: 21 additions & 0 deletions packages/core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 MrWangJustToDo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions packages/core/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./dist/types";
7 changes: 7 additions & 0 deletions packages/core/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

if (process.env.NODE_ENV === "production") {
module.exports = require("./dist/cjs/index.production");
} else {
module.exports = require("./dist/cjs/index.development");
}
56 changes: 56 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@git-diff-view/core",
"description": "@git-diff-view/core",
"author": "MrWangJustToDo",
"license": "MIT",
"version": "0.0.1",
"main": "index.js",
"types": "index.d.ts",
"unpkg": "./dist/umd/index.development.js",
"jsdelivr": "./dist/umd/index.development.js",
"files": [
"dist",
"index.js",
"index.d.ts"
],
"repository": {
"type": "git",
"url": "https://github.com/MrWangJustToDo/git-diff-view",
"directory": "packages/core"
},
"homepage": "https://github.com/MrWangJustToDo/git-diff-view",
"exports": {
".": {
"require": "./index.js",
"types": "./index.d.ts",
"import": "./dist/esm/index.mjs"
},
"./package.json": "./package.json"
},
"buildOptions": {
"input": "./src/index.ts",
"output": [
{
"dir": "./dist",
"entryFileNames": "cjs/index.js",
"format": "cjs",
"type": true,
"multiple": true,
"sourcemap": true
},
{
"dir": "./dist",
"entryFileNames": "esm/index.mjs",
"format": "esm",
"sourcemap": true
}
]
},
"keywords": [
"diff",
"diff parse"
],
"dependencies": {
"lowlight": "^3.1.0"
}
}
1 change: 1 addition & 0 deletions packages/core/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## TODO
13 changes: 2 additions & 11 deletions src/diff/change-range.ts → packages/core/src/change-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ function rangeMax(range: IRange): number {
}

/** Get the length of the common substring between the two strings. */
function commonLength(
stringA: string,
rangeA: IRange,
stringB: string,
rangeB: IRange,
reverse: boolean
): number {
function commonLength(stringA: string, rangeA: IRange, stringB: string, rangeB: IRange, reverse: boolean): number {
const max = Math.min(rangeA.length, rangeB.length);
const startA = reverse ? rangeMax(rangeA) - 1 : rangeA.location;
const startB = reverse ? rangeMax(rangeB) - 1 : rangeB.location;
Expand All @@ -43,10 +37,7 @@ function isInValidString(s: string) {
}

/** Get the changed ranges in the strings, relative to each other. */
export function relativeChanges(
stringA: string,
stringB: string
): { stringARange: IRange; stringBRange: IRange } {
export function relativeChanges(stringA: string, stringB: string): { stringARange: IRange; stringBRange: IRange } {
let bRange = { location: 0, length: stringB.length };
let aRange = { location: 0, length: stringA.length };

Expand Down
Loading

0 comments on commit 0d8ada9

Please sign in to comment.