difit 3.1.10 → 3.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +11 -3
- package/README.ko.md +9 -1
- package/README.md +10 -2
- package/README.zh.md +9 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.test.js +29 -0
- package/dist/cli/utils.d.ts +3 -3
- package/dist/cli/utils.js +10 -4
- package/dist/client/assets/index-AQuNl5mW.js +92 -0
- package/dist/client/assets/{prism-csharp-omuTcU4j.js → prism-csharp-C7x4qFLG.js} +1 -1
- package/dist/client/assets/{prism-hcl-BVGrHlPv.js → prism-hcl-CBjfvIjf.js} +1 -1
- package/dist/client/assets/{prism-java-BjHLe7qM.js → prism-java-Ca4SeKTf.js} +1 -1
- package/dist/client/assets/{prism-perl-Cl4F-f2r.js → prism-perl-B_RTNjmx.js} +1 -1
- package/dist/client/assets/{prism-php-BbsdsICU.js → prism-php-Y4QWW5YT.js} +1 -1
- package/dist/client/assets/{prism-ruby-CSLiFfIy.js → prism-ruby-CQyeYrqM.js} +1 -1
- package/dist/client/assets/{prism-solidity-C3yStBME.js → prism-solidity-DNiu86MI.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/generated-file-check.d.ts +2 -1
- package/dist/server/git-diff.d.ts +9 -1
- package/dist/server/git-diff.js +56 -88
- package/dist/server/git-diff.test.js +19 -28
- package/dist/server/server.js +59 -14
- package/dist/server/server.test.js +67 -0
- package/dist/types/diff.d.ts +7 -0
- package/dist/utils/suggestionUtils.d.ts +2 -1
- package/package.json +35 -34
- package/dist/client/assets/index-CH5h4Jfu.js +0 -92
|
@@ -42,7 +42,28 @@ vi.mock('./git-diff.js', () => {
|
|
|
42
42
|
stats: { additions: 10, deletions: 5 },
|
|
43
43
|
isEmpty: false,
|
|
44
44
|
});
|
|
45
|
+
parseStdinDiff = vi.fn().mockReturnValue({
|
|
46
|
+
targetCommit: 'stdin-target',
|
|
47
|
+
baseCommit: 'stdin-base',
|
|
48
|
+
targetMessage: 'stdin target',
|
|
49
|
+
baseMessage: 'stdin base',
|
|
50
|
+
files: [
|
|
51
|
+
{
|
|
52
|
+
path: 'stdin-test.js',
|
|
53
|
+
additions: 1,
|
|
54
|
+
deletions: 0,
|
|
55
|
+
chunks: [],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
stats: { additions: 1, deletions: 0 },
|
|
59
|
+
isEmpty: false,
|
|
60
|
+
});
|
|
45
61
|
getBlobContent = vi.fn().mockResolvedValue(Buffer.from('mock image data'));
|
|
62
|
+
getGeneratedStatus = vi.fn().mockResolvedValue({
|
|
63
|
+
isGenerated: true,
|
|
64
|
+
source: 'content',
|
|
65
|
+
});
|
|
66
|
+
clearResolvedCommitCache = vi.fn();
|
|
46
67
|
getRevisionOptions = vi.fn().mockResolvedValue({
|
|
47
68
|
branches: [{ name: 'main', current: true }],
|
|
48
69
|
commits: [{ hash: 'abc1234', shortHash: 'abc1234', message: 'Test commit' }],
|
|
@@ -226,6 +247,7 @@ describe('Server Integration Tests', () => {
|
|
|
226
247
|
expect(data.files).toHaveLength(1);
|
|
227
248
|
expect(data.files[0]).toHaveProperty('path', 'test.js');
|
|
228
249
|
expect(data).toHaveProperty('ignoreWhitespace', false);
|
|
250
|
+
expect(data).toHaveProperty('openInEditorAvailable', true);
|
|
229
251
|
});
|
|
230
252
|
it('GET /api/diff?ignoreWhitespace=true handles whitespace ignore', async () => {
|
|
231
253
|
const response = await fetch(`http://localhost:${port}/api/diff?ignoreWhitespace=true`);
|
|
@@ -233,6 +255,29 @@ describe('Server Integration Tests', () => {
|
|
|
233
255
|
expect(response.ok).toBe(true);
|
|
234
256
|
expect(data).toHaveProperty('ignoreWhitespace', true);
|
|
235
257
|
});
|
|
258
|
+
it('GET /api/generated-status/* returns generated status', async () => {
|
|
259
|
+
const response = await fetch(`http://localhost:${port}/api/generated-status/src/query.ts?ref=HEAD`);
|
|
260
|
+
const data = (await response.json());
|
|
261
|
+
expect(response.ok).toBe(true);
|
|
262
|
+
expect(data).toEqual({
|
|
263
|
+
path: 'src/query.ts',
|
|
264
|
+
ref: 'HEAD',
|
|
265
|
+
isGenerated: true,
|
|
266
|
+
source: 'content',
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
it('GET /api/generated-status/* rejects paths outside repository', async () => {
|
|
270
|
+
const response = await fetch(`http://localhost:${port}/api/generated-status/%2Ftmp%2Foutside.txt?ref=HEAD`);
|
|
271
|
+
const data = (await response.json());
|
|
272
|
+
expect(response.status).toBe(400);
|
|
273
|
+
expect(data).toHaveProperty('error', 'File path outside repository');
|
|
274
|
+
});
|
|
275
|
+
it('GET /api/generated-status/* rejects parent traversal paths', async () => {
|
|
276
|
+
const response = await fetch(`http://localhost:${port}/api/generated-status/..%2Foutside.txt?ref=HEAD`);
|
|
277
|
+
const data = (await response.json());
|
|
278
|
+
expect(response.status).toBe(400);
|
|
279
|
+
expect(data).toHaveProperty('error', 'File path outside repository');
|
|
280
|
+
});
|
|
236
281
|
it('POST /api/comments accepts comment data', async () => {
|
|
237
282
|
const comments = [{ file: 'test.js', line: 10, body: 'This is a test comment' }];
|
|
238
283
|
const response = await fetch(`http://localhost:${port}/api/comments`, {
|
|
@@ -317,6 +362,28 @@ describe('Server Integration Tests', () => {
|
|
|
317
362
|
// SSE endpoint functionality is verified through manual testing
|
|
318
363
|
expect(true).toBe(true);
|
|
319
364
|
});
|
|
365
|
+
it('GET /api/diff sets openInEditorAvailable=false for stdin diff', async () => {
|
|
366
|
+
const stdinServer = await startServer({
|
|
367
|
+
stdinDiff: 'diff --git a/stdin-test.js b/stdin-test.js',
|
|
368
|
+
preferredPort: 9035,
|
|
369
|
+
});
|
|
370
|
+
servers.push(stdinServer.server);
|
|
371
|
+
const response = await fetch(`http://localhost:${stdinServer.port}/api/diff`);
|
|
372
|
+
const data = (await response.json());
|
|
373
|
+
expect(response.ok).toBe(true);
|
|
374
|
+
expect(data).toHaveProperty('openInEditorAvailable', false);
|
|
375
|
+
});
|
|
376
|
+
it('GET /api/generated-status/* returns 400 for stdin diff', async () => {
|
|
377
|
+
const stdinServer = await startServer({
|
|
378
|
+
stdinDiff: 'diff --git a/stdin-test.js b/stdin-test.js',
|
|
379
|
+
preferredPort: 9036,
|
|
380
|
+
});
|
|
381
|
+
servers.push(stdinServer.server);
|
|
382
|
+
const response = await fetch(`http://localhost:${stdinServer.port}/api/generated-status/stdin-test.js?ref=HEAD`);
|
|
383
|
+
const data = (await response.json());
|
|
384
|
+
expect(response.status).toBe(400);
|
|
385
|
+
expect(data).toHaveProperty('error', 'Generated status is not available for stdin diff');
|
|
386
|
+
});
|
|
320
387
|
});
|
|
321
388
|
describe('Static file serving', () => {
|
|
322
389
|
let originalNodeEnv;
|
package/dist/types/diff.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface DiffResponse {
|
|
|
40
40
|
ignoreWhitespace?: boolean;
|
|
41
41
|
isEmpty?: boolean;
|
|
42
42
|
mode?: DiffViewMode | LegacyDiffViewMode;
|
|
43
|
+
openInEditorAvailable?: boolean;
|
|
43
44
|
baseCommitish?: string;
|
|
44
45
|
targetCommitish?: string;
|
|
45
46
|
requestedBaseCommitish?: string;
|
|
@@ -47,6 +48,12 @@ export interface DiffResponse {
|
|
|
47
48
|
clearComments?: boolean;
|
|
48
49
|
repositoryId?: string;
|
|
49
50
|
}
|
|
51
|
+
export interface GeneratedStatusResponse {
|
|
52
|
+
path: string;
|
|
53
|
+
ref: string;
|
|
54
|
+
isGenerated: boolean;
|
|
55
|
+
source: 'path' | 'content';
|
|
56
|
+
}
|
|
50
57
|
export type LineNumber = number | [number, number];
|
|
51
58
|
export interface Comment {
|
|
52
59
|
id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
interface SuggestionBlock {
|
|
2
2
|
suggestedCode: string;
|
|
3
3
|
startIndex: number;
|
|
4
4
|
endIndex: number;
|
|
@@ -16,3 +16,4 @@ export declare function parseSuggestionBlocks(body: string): SuggestionBlock[];
|
|
|
16
16
|
* Create a suggestion template with the given code
|
|
17
17
|
*/
|
|
18
18
|
export declare function createSuggestionTemplate(code: string): string;
|
|
19
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,33 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "difit",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.12",
|
|
4
4
|
"description": "A lightweight command-line tool that spins up a local web server to display Git commit diffs in a GitHub-like Files changed view",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"code-review",
|
|
8
|
+
"diff",
|
|
9
|
+
"diff-viewer",
|
|
10
|
+
"git",
|
|
11
|
+
"github",
|
|
12
|
+
"react",
|
|
13
|
+
"review",
|
|
14
|
+
"tailwind"
|
|
15
|
+
],
|
|
13
16
|
"homepage": "https://github.com/yoshiko-pg/difit",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/yoshiko-pg/difit/issues"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "yoshiko-pg",
|
|
14
22
|
"repository": {
|
|
15
23
|
"type": "git",
|
|
16
24
|
"url": "https://github.com/yoshiko-pg/difit.git"
|
|
17
25
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
26
|
+
"bin": {
|
|
27
|
+
"difit": "./dist/cli/index.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"type": "module",
|
|
34
|
+
"main": "./dist/cli/index.js",
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
20
37
|
},
|
|
21
38
|
"scripts": {
|
|
22
39
|
"dev": "node scripts/dev.js",
|
|
23
40
|
"dev:cli": "tsc --project tsconfig.cli.json && NODE_ENV=development node dist/cli/index.js",
|
|
24
41
|
"build": "tsc -b && vite build",
|
|
25
42
|
"build:cli": "tsc --project tsconfig.cli.json",
|
|
43
|
+
"package:vscode": "pnpm -C packages/vscode run package",
|
|
26
44
|
"start": "pnpm run build && node dist/cli/index.js",
|
|
27
45
|
"check": "oxlint . --type-aware --type-check --deny-warnings --report-unused-disable-directives",
|
|
28
46
|
"check:fix": "oxlint . --type-aware --type-check --deny-warnings --report-unused-disable-directives --fix",
|
|
29
|
-
"format": "
|
|
30
|
-
"format:fix": "
|
|
47
|
+
"format": "oxfmt --check .",
|
|
48
|
+
"format:fix": "oxfmt --write .",
|
|
31
49
|
"knip": "knip --use-tsconfig-files",
|
|
32
50
|
"test": "vitest run",
|
|
33
51
|
"test:watch": "vitest",
|
|
@@ -59,7 +77,6 @@
|
|
|
59
77
|
"simple-git": "^3.28.0"
|
|
60
78
|
},
|
|
61
79
|
"devDependencies": {
|
|
62
|
-
"@biomejs/biome": "^2.4.3",
|
|
63
80
|
"@tailwindcss/postcss": "^4.1.11",
|
|
64
81
|
"@testing-library/jest-dom": "^6.6.3",
|
|
65
82
|
"@testing-library/react": "^16.3.0",
|
|
@@ -75,6 +92,7 @@
|
|
|
75
92
|
"happy-dom": "^20.0.0",
|
|
76
93
|
"knip": "^5.83.0",
|
|
77
94
|
"lefthook": "^2.0.0",
|
|
95
|
+
"oxfmt": "^0.34.0",
|
|
78
96
|
"oxlint": "^1.49.0",
|
|
79
97
|
"oxlint-tsgolint": "^0.14.1",
|
|
80
98
|
"playwright": "^1.54.1",
|
|
@@ -85,25 +103,8 @@
|
|
|
85
103
|
"vite": "^7.0.0",
|
|
86
104
|
"vitest": "^4.0.6"
|
|
87
105
|
},
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"README.md"
|
|
91
|
-
],
|
|
92
|
-
"keywords": [
|
|
93
|
-
"git",
|
|
94
|
-
"diff",
|
|
95
|
-
"cli",
|
|
96
|
-
"review",
|
|
97
|
-
"github",
|
|
98
|
-
"code-review",
|
|
99
|
-
"tailwind",
|
|
100
|
-
"react",
|
|
101
|
-
"diff-viewer"
|
|
102
|
-
],
|
|
103
|
-
"author": "yoshiko-pg",
|
|
104
|
-
"license": "MIT",
|
|
105
|
-
"publishConfig": {
|
|
106
|
-
"access": "public"
|
|
106
|
+
"engines": {
|
|
107
|
+
"node": ">=21.0.0"
|
|
107
108
|
},
|
|
108
|
-
"packageManager": "pnpm@10.
|
|
109
|
+
"packageManager": "pnpm@10.29.3"
|
|
109
110
|
}
|