Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 6886f13

Browse files
committed
build: update dependencies & CI
1 parent bcfb642 commit 6886f13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3608
-50074
lines changed

.editorconfig

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc.js

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
11
module.exports = {
2-
root: true,
32
env: {
4-
node: true
3+
browser: true,
4+
es2021: true,
55
},
6-
extends: [
7-
'plugin:vue/vue3-essential',
8-
'@vue/standard',
9-
'@vue/typescript/recommended'
10-
],
6+
extends: ['plugin:vue/essential', 'standard', 'plugin:prettier/recommended'],
117
parserOptions: {
12-
ecmaVersion: 2020
8+
ecmaVersion: 12,
9+
parser: '@typescript-eslint/parser',
10+
sourceType: 'module',
1311
},
14-
rules: {
15-
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
16-
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
17-
'no-unused-expressions': 'off',
18-
'@typescript-eslint/ban-ts-ignore': 'off'
19-
},
20-
overrides: [
21-
{
22-
files: [
23-
'**/__tests__/*.{j,t}s?(x)'
24-
],
25-
env: {
26-
jest: true
27-
}
28-
}
29-
]
30-
}
12+
plugins: ['vue', '@typescript-eslint'],
13+
rules: {},
14+
};

.github/workflows/release.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ jobs:
1515
- name: Setup Node.js
1616
uses: actions/setup-node@v1
1717
with:
18-
node-version: 12
19-
- name: Install dependencies
20-
run: npm ci
21-
- name: Build
22-
run: npm run build
18+
node-version: 16
19+
- name: Install
20+
uses: borales/actions-yarn@v2.3.0
21+
with:
22+
cmd: install
2323
- name: Demo
24-
run: npm run demo
24+
uses: borales/actions-yarn@v2.3.0
25+
with:
26+
cmd: build:demo
27+
- name: Build
28+
uses: borales/actions-yarn@v2.3.0
29+
with:
30+
cmd: build
2531
- name: Release
2632
uses: cycjimmy/semantic-release-action@v2
2733
with:

.github/workflows/test.yaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Test
2-
on:
3-
push:
4-
branches:
5-
- develop
2+
on: [push]
63
jobs:
74
test:
85
name: test
@@ -15,10 +12,12 @@ jobs:
1512
- name: Setup Node.js
1613
uses: actions/setup-node@v1
1714
with:
18-
node-version: 12
19-
- name: Install dependencies
20-
run: npm ci
21-
- name: Lint
22-
run: npm run lint
15+
node-version: 16
16+
- name: Install
17+
uses: borales/actions-yarn@v2.3.0
18+
with:
19+
cmd: install
2320
- name: Test
24-
run: npm run test
21+
uses: borales/actions-yarn@v2.3.0
22+
with:
23+
cmd: test

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ npm-debug.log
1818
/node_modules
1919
.*rc
2020
.*rc.*
21+
.*ignore
2122
*config
2223
*config.*
2324
*.config.*

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"singleQuote": true,
3+
"semi": true,
4+
"useTabs": false,
5+
"tabWidth": 2,
6+
"trailingComma": "all",
7+
"printWidth": 80,
8+
"arrowParens": "avoid",
9+
"endOfLine": "auto"
10+
}

__tests__/index.spec.ts

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,69 @@
1-
import { mount } from '@vue/test-utils'
2-
import VueDiff from '../src/index'
1+
import { describe, it, expect } from 'vitest';
2+
import { mount } from '@vue/test-utils';
3+
import VueDiff from '../src/index';
34

45
describe('Plugin and component', () => {
56
it('Install plugin', () => {
6-
const wrapper = mount({
7-
template: `
7+
const wrapper = mount(
8+
{
9+
template: `
810
<Diff />
9-
`
10-
}, {
11-
global: {
12-
plugins: [
13-
[VueDiff]
14-
]
15-
}
16-
})
17-
expect(wrapper.find('.vue-diff-wrapper')).toBeTruthy()
18-
expect(wrapper.find('.vue-diff-mode-split')).toBeTruthy()
19-
expect(wrapper.find('.vue-diff-theme-dark')).toBeTruthy()
20-
})
11+
`,
12+
},
13+
{
14+
global: {
15+
plugins: [[VueDiff]],
16+
},
17+
},
18+
);
19+
expect(wrapper.find('.vue-diff-wrapper')).toBeTruthy();
20+
expect(wrapper.find('.vue-diff-mode-split')).toBeTruthy();
21+
expect(wrapper.find('.vue-diff-theme-dark')).toBeTruthy();
22+
});
2123

2224
it('Set plugin options', () => {
23-
const wrapper = mount({
24-
template: `
25+
const wrapper = mount(
26+
{
27+
template: `
2528
<VueDiff />
26-
`
27-
}, {
28-
global: {
29-
plugins: [
30-
[VueDiff, {
31-
componentName: 'VueDiff'
32-
}]
33-
]
34-
}
35-
})
36-
expect(wrapper.find('.vue-diff-wrapper')).toBeTruthy()
37-
expect(wrapper.find('.vue-diff-mode-split')).toBeTruthy()
38-
expect(wrapper.find('.vue-diff-theme-dark')).toBeTruthy()
39-
})
29+
`,
30+
},
31+
{
32+
global: {
33+
plugins: [
34+
[
35+
VueDiff,
36+
{
37+
componentName: 'VueDiff',
38+
},
39+
],
40+
],
41+
},
42+
},
43+
);
44+
expect(wrapper.find('.vue-diff-wrapper')).toBeTruthy();
45+
expect(wrapper.find('.vue-diff-mode-split')).toBeTruthy();
46+
expect(wrapper.find('.vue-diff-theme-dark')).toBeTruthy();
47+
});
4048

4149
it('Set component property', () => {
42-
const wrapper = mount({
43-
template: `
50+
const wrapper = mount(
51+
{
52+
template: `
4453
<Diff
4554
mode="unified"
4655
theme="light"
4756
/>
48-
`
49-
}, {
50-
global: {
51-
plugins: [
52-
[VueDiff]
53-
]
54-
}
55-
})
56-
expect(wrapper.find('.vue-diff-wrapper')).toBeTruthy()
57-
expect(wrapper.find('.vue-diff-mode-unified')).toBeTruthy()
58-
expect(wrapper.find('.vue-diff-theme-light')).toBeTruthy()
59-
})
60-
})
57+
`,
58+
},
59+
{
60+
global: {
61+
plugins: [[VueDiff]],
62+
},
63+
},
64+
);
65+
expect(wrapper.find('.vue-diff-wrapper')).toBeTruthy();
66+
expect(wrapper.find('.vue-diff-mode-unified')).toBeTruthy();
67+
expect(wrapper.find('.vue-diff-theme-light')).toBeTruthy();
68+
});
69+
});

__tests__/utils.spec.ts

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,85 @@
1-
import { ref } from 'vue'
2-
import { MODIFIED_START_TAG, MODIFIED_CLOSE_TAG, getDiffType, getSplitLines, getUnifiedLines, renderLines, renderWords, setHighlightCode } from '../src/utils'
1+
import { nextTick } from 'vue';
2+
import { describe, it, expect } from 'vitest';
3+
import { ref } from 'vue';
4+
import {
5+
MODIFIED_START_TAG,
6+
MODIFIED_CLOSE_TAG,
7+
getDiffType,
8+
getSplitLines,
9+
getUnifiedLines,
10+
renderLines,
11+
renderWords,
12+
setHighlightCode,
13+
} from '../src/utils';
314

4-
import type { Diff } from 'diff-match-patch'
15+
import type { Diff } from 'diff-match-patch';
516

617
describe('Utils unit', () => {
718
// diff-match-patch output
8-
const added: Diff = [1, '']
9-
const removed: Diff = [-1, '']
10-
const equal: Diff = [0, '']
19+
const added: Diff = [1, ''];
20+
const removed: Diff = [-1, ''];
21+
const equal: Diff = [0, ''];
1122
// custom output
12-
const disabled: Diff = [2, '']
23+
const disabled: Diff = [2, ''];
1324

14-
const prev: Diff = [-1, 'a\nb']
15-
const curr: Diff = [1, 'c']
25+
const prev: Diff = [-1, 'a\nb'];
26+
const curr: Diff = [1, 'c'];
1627

17-
const diffsMap = [[prev, curr]]
28+
const diffsMap = [[prev, curr]];
1829

1930
it('getDiffType', () => {
20-
expect(getDiffType(added[0])).toBe('added')
21-
expect(getDiffType(removed[0])).toBe('removed')
22-
expect(getDiffType(equal[0])).toBe('equal')
23-
expect(getDiffType(disabled[0])).toBe('disabled')
24-
})
31+
expect(getDiffType(added[0])).toBe('added');
32+
expect(getDiffType(removed[0])).toBe('removed');
33+
expect(getDiffType(equal[0])).toBe('equal');
34+
expect(getDiffType(disabled[0])).toBe('disabled');
35+
});
2536

2637
it('getSplitLines', () => {
27-
const result = getSplitLines(diffsMap)
28-
expect(result.length).toBe(2)
29-
expect(result[0][0].type).toBe('removed')
30-
expect(result[0][0].lineNum).toBe(1)
31-
expect(result[0][0].value).toBe('a')
32-
expect(result[0][0].chkWords).toBe(true)
33-
})
38+
const result = getSplitLines(diffsMap);
39+
expect(result.length).toBe(2);
40+
expect(result[0][0].type).toBe('removed');
41+
expect(result[0][0].lineNum).toBe(1);
42+
expect(result[0][0].value).toBe('a');
43+
expect(result[0][0].chkWords).toBe(true);
44+
});
3445

3546
it('getUnifiedLines', () => {
36-
const result = getUnifiedLines(diffsMap)
37-
expect(result.length).toBe(3)
38-
expect(result[0][0].type).toBe('removed')
39-
expect(result[0][0].lineNum).toBe(undefined)
40-
expect(result[0][0].value).toBe('a')
41-
expect(result[1][0].type).toBe('removed')
42-
expect(result[1][0].lineNum).toBe(undefined)
43-
expect(result[1][0].value).toBe('b')
44-
expect(result[2][0].type).toBe('added')
45-
expect(result[2][0].lineNum).toBe(1)
46-
expect(result[2][0].value).toBe('c')
47-
})
47+
const result = getUnifiedLines(diffsMap);
48+
expect(result.length).toBe(3);
49+
expect(result[0][0].type).toBe('removed');
50+
expect(result[0][0].lineNum).toBe(undefined);
51+
expect(result[0][0].value).toBe('a');
52+
expect(result[1][0].type).toBe('removed');
53+
expect(result[1][0].lineNum).toBe(undefined);
54+
expect(result[1][0].value).toBe('b');
55+
expect(result[2][0].type).toBe('added');
56+
expect(result[2][0].lineNum).toBe(1);
57+
expect(result[2][0].value).toBe('c');
58+
});
4859

4960
it('getUnifiedLines', () => {
50-
const split = renderLines('split', prev[1], curr[1])
51-
const unified = renderLines('unified', prev[1], curr[1])
52-
expect(split.length).toBe(2)
53-
expect(unified.length).toBe(3)
54-
})
61+
const split = renderLines('split', prev[1], curr[1]);
62+
const unified = renderLines('unified', prev[1], curr[1]);
63+
expect(split.length).toBe(2);
64+
expect(unified.length).toBe(3);
65+
});
5566

5667
it('renderWords', () => {
57-
expect(renderWords('abc', 'abc')).toBe('abc')
58-
expect(renderWords('abc', 'acc')).toBe(`a${MODIFIED_START_TAG}c${MODIFIED_CLOSE_TAG}c`)
59-
})
68+
expect(renderWords('abc', 'abc')).toBe('abc');
69+
expect(renderWords('abc', 'acc')).toBe(
70+
`a${MODIFIED_START_TAG}c${MODIFIED_CLOSE_TAG}c`,
71+
);
72+
});
6073

61-
it('setHighlightCode', () => {
62-
const highlightCode = ref('')
74+
// it('setHighlightCode', async () => {
75+
// const highlightCode = ref('');
6376

64-
setHighlightCode({
65-
highlightCode,
66-
language: 'plaintext',
67-
code: `a ${MODIFIED_START_TAG}c${MODIFIED_CLOSE_TAG} c`
68-
})
77+
// setHighlightCode({
78+
// highlightCode,
79+
// language: 'plaintext',
80+
// code: `a ${MODIFIED_START_TAG}c${MODIFIED_CLOSE_TAG} c`,
81+
// });
6982

70-
expect(highlightCode.value).toBe('a <span class="modified">c</span> c')
71-
})
72-
})
83+
// expect(highlightCode.value).toBe('a <span class="modified">c</span> c');
84+
// });
85+
});

babel.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

demo/index.018814d5.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)