@riebeckite/plugin-diff 0.0.12 → 0.0.13
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.md +90 -90
- package/README_ja.md +41 -41
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
# @riebeckite/plugin-diff
|
|
2
|
-
|
|
3
|
-
Git-backed diff and revision history for Markdown notes: read commit history,
|
|
4
|
-
retrieve past revisions, and compute line-level diffs between them.
|
|
5
|
-
|
|
6
|
-
[日本語](./README_ja.md)
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
`createPostDiffApi()` wraps a local Git repository and exposes revision
|
|
11
|
-
history plus line diffs for any Markdown file, even when the note was renamed
|
|
12
|
-
or moved (`git log --follow`). `createLineDiff()` is the pure diff engine used
|
|
13
|
-
by the API and is also exported for standalone use.
|
|
14
|
-
|
|
15
|
-
The `diff()` plugin registers a `diff` entry in the plugin list; the
|
|
16
|
-
programmatic API is the primary interface.
|
|
17
|
-
|
|
18
|
-
## Usage (plugin)
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
import { defineConfig } from "@riebeckite/core";
|
|
22
|
-
import { diff } from "@riebeckite/plugin-diff";
|
|
23
|
-
|
|
24
|
-
export default defineConfig({
|
|
25
|
-
// ...
|
|
26
|
-
plugins: [diff({ cwd: "./content" })],
|
|
27
|
-
});
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
`diff(options?)` accepts the same `GitHistoryReaderOptions` as the API.
|
|
31
|
-
|
|
32
|
-
## Programmatic API
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
import { createPostDiffApi } from "@riebeckite/plugin-diff";
|
|
36
|
-
|
|
37
|
-
const api = createPostDiffApi({ cwd: "./content" });
|
|
38
|
-
|
|
39
|
-
const history = await api.getHistory("notes/hello.md");
|
|
40
|
-
const previous = await api.getRevisionMarkdown("notes/hello.md", history[1].hash);
|
|
41
|
-
const current = await api.getCurrentDiff("notes/hello.md");
|
|
42
|
-
const compare = await api.compareRevisions({
|
|
43
|
-
filePath: "notes/hello.md",
|
|
44
|
-
fromHash: history[1].hash,
|
|
45
|
-
toHash: history[0].hash,
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
- `getHistory(filePath)` — commit history for the file (newest first) as
|
|
50
|
-
`DiffRevision[]`
|
|
51
|
-
- `getRevisionMarkdown(filePath, hash)` — Markdown source at a given revision,
|
|
52
|
-
or `null`
|
|
53
|
-
- `getCurrentDiff(filePath)` — line diff between the latest revision and its
|
|
54
|
-
predecessor (or from an empty source when there is no predecessor)
|
|
55
|
-
- `compareRevisions({ filePath, fromHash, toHash })` — line diff between two
|
|
56
|
-
revisions; `fromHash: null` diffs from an empty source
|
|
57
|
-
|
|
58
|
-
## Options
|
|
59
|
-
|
|
60
|
-
`createPostDiffApi(options?)` accepts `GitHistoryReaderOptions`:
|
|
61
|
-
|
|
62
|
-
| Option | Type | Default | Description |
|
|
63
|
-
| ------ | ---- | ------- | ----------- |
|
|
64
|
-
| `cwd` | `string` | `process.cwd()` | Working directory for Git commands |
|
|
65
|
-
|
|
66
|
-
When `cwd` is not inside a Git repository, API calls resolve to empty results
|
|
67
|
-
(`[]` / `null`) instead of throwing.
|
|
68
|
-
|
|
69
|
-
## Types
|
|
70
|
-
|
|
71
|
-
| Type | Description |
|
|
72
|
-
| ---- | ----------- |
|
|
73
|
-
| `DiffRevision` | Commit metadata: `hash`, `shortHash`, `date`, `message`, `author` |
|
|
74
|
-
| `MarkdownRevision` | `DiffRevision` with the Markdown source |
|
|
75
|
-
| `PostDiff` | `from`, `to`, and `lines` |
|
|
76
|
-
| `DiffLine` | A single diff line: `{ type, content }` |
|
|
77
|
-
| `DiffLineType` | `"context" \| "added" \| "removed"` |
|
|
78
|
-
| `RevisionComparisonInput` | `{ filePath, fromHash: string \| null, toHash }` |
|
|
79
|
-
|
|
80
|
-
## Exports
|
|
81
|
-
|
|
82
|
-
- `diff(options?)` — plugin factory
|
|
83
|
-
- `createPostDiffApi(options?)` — programmatic API factory
|
|
84
|
-
- `createLineDiff(from, to)` — LCS-based line diff
|
|
85
|
-
- `GitMarkdownHistoryReader` — Git-backed history reader class
|
|
86
|
-
- Types listed above
|
|
87
|
-
|
|
88
|
-
## See also
|
|
89
|
-
|
|
90
|
-
- [Plugin guide](../../../docs/en/plugin-
|
|
1
|
+
# @riebeckite/plugin-diff
|
|
2
|
+
|
|
3
|
+
Git-backed diff and revision history for Markdown notes: read commit history,
|
|
4
|
+
retrieve past revisions, and compute line-level diffs between them.
|
|
5
|
+
|
|
6
|
+
[日本語](./README_ja.md)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
`createPostDiffApi()` wraps a local Git repository and exposes revision
|
|
11
|
+
history plus line diffs for any Markdown file, even when the note was renamed
|
|
12
|
+
or moved (`git log --follow`). `createLineDiff()` is the pure diff engine used
|
|
13
|
+
by the API and is also exported for standalone use.
|
|
14
|
+
|
|
15
|
+
The `diff()` plugin registers a `diff` entry in the plugin list; the
|
|
16
|
+
programmatic API is the primary interface.
|
|
17
|
+
|
|
18
|
+
## Usage (plugin)
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { defineConfig } from "@riebeckite/core";
|
|
22
|
+
import { diff } from "@riebeckite/plugin-diff";
|
|
23
|
+
|
|
24
|
+
export default defineConfig({
|
|
25
|
+
// ...
|
|
26
|
+
plugins: [diff({ cwd: "./content" })],
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`diff(options?)` accepts the same `GitHistoryReaderOptions` as the API.
|
|
31
|
+
|
|
32
|
+
## Programmatic API
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { createPostDiffApi } from "@riebeckite/plugin-diff";
|
|
36
|
+
|
|
37
|
+
const api = createPostDiffApi({ cwd: "./content" });
|
|
38
|
+
|
|
39
|
+
const history = await api.getHistory("notes/hello.md");
|
|
40
|
+
const previous = await api.getRevisionMarkdown("notes/hello.md", history[1].hash);
|
|
41
|
+
const current = await api.getCurrentDiff("notes/hello.md");
|
|
42
|
+
const compare = await api.compareRevisions({
|
|
43
|
+
filePath: "notes/hello.md",
|
|
44
|
+
fromHash: history[1].hash,
|
|
45
|
+
toHash: history[0].hash,
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- `getHistory(filePath)` — commit history for the file (newest first) as
|
|
50
|
+
`DiffRevision[]`
|
|
51
|
+
- `getRevisionMarkdown(filePath, hash)` — Markdown source at a given revision,
|
|
52
|
+
or `null`
|
|
53
|
+
- `getCurrentDiff(filePath)` — line diff between the latest revision and its
|
|
54
|
+
predecessor (or from an empty source when there is no predecessor)
|
|
55
|
+
- `compareRevisions({ filePath, fromHash, toHash })` — line diff between two
|
|
56
|
+
revisions; `fromHash: null` diffs from an empty source
|
|
57
|
+
|
|
58
|
+
## Options
|
|
59
|
+
|
|
60
|
+
`createPostDiffApi(options?)` accepts `GitHistoryReaderOptions`:
|
|
61
|
+
|
|
62
|
+
| Option | Type | Default | Description |
|
|
63
|
+
| ------ | ---- | ------- | ----------- |
|
|
64
|
+
| `cwd` | `string` | `process.cwd()` | Working directory for Git commands |
|
|
65
|
+
|
|
66
|
+
When `cwd` is not inside a Git repository, API calls resolve to empty results
|
|
67
|
+
(`[]` / `null`) instead of throwing.
|
|
68
|
+
|
|
69
|
+
## Types
|
|
70
|
+
|
|
71
|
+
| Type | Description |
|
|
72
|
+
| ---- | ----------- |
|
|
73
|
+
| `DiffRevision` | Commit metadata: `hash`, `shortHash`, `date`, `message`, `author` |
|
|
74
|
+
| `MarkdownRevision` | `DiffRevision` with the Markdown source |
|
|
75
|
+
| `PostDiff` | `from`, `to`, and `lines` |
|
|
76
|
+
| `DiffLine` | A single diff line: `{ type, content }` |
|
|
77
|
+
| `DiffLineType` | `"context" \| "added" \| "removed"` |
|
|
78
|
+
| `RevisionComparisonInput` | `{ filePath, fromHash: string \| null, toHash }` |
|
|
79
|
+
|
|
80
|
+
## Exports
|
|
81
|
+
|
|
82
|
+
- `diff(options?)` — plugin factory
|
|
83
|
+
- `createPostDiffApi(options?)` — programmatic API factory
|
|
84
|
+
- `createLineDiff(from, to)` — LCS-based line diff
|
|
85
|
+
- `GitMarkdownHistoryReader` — Git-backed history reader class
|
|
86
|
+
- Types listed above
|
|
87
|
+
|
|
88
|
+
## See also
|
|
89
|
+
|
|
90
|
+
- [Plugin guide](../../../docs/en/reference/plugin-api.md)
|
package/README_ja.md
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
# @riebeckite/plugin-diff
|
|
2
|
-
|
|
3
|
-
ローカル Git リポジトリから、Markdown ノートの履歴と行単位の差分を取得するプラグインです。
|
|
4
|
-
|
|
5
|
-
[English](./README.md)
|
|
6
|
-
|
|
7
|
-
## できること
|
|
8
|
-
|
|
9
|
-
中心となる API は `createPostDiffApi()` です。リネームや移動後のファイルも `git log --follow` で追跡し、履歴、指定リビジョンの本文、任意の二つのリビジョン間の差分を返します。`createLineDiff()` は単独でも使える純粋な差分関数です。
|
|
10
|
-
|
|
11
|
-
## 設定と利用例
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { defineConfig } from "@riebeckite/core";
|
|
15
|
-
import { createPostDiffApi, diff } from "@riebeckite/plugin-diff";
|
|
16
|
-
|
|
17
|
-
export default defineConfig({ plugins: [diff({ cwd: "./content" })] });
|
|
18
|
-
|
|
19
|
-
const api = createPostDiffApi({ cwd: "./content" });
|
|
20
|
-
const history = await api.getHistory("notes/hello.md");
|
|
21
|
-
const current = await api.getCurrentDiff("notes/hello.md");
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
| API | 返す内容 |
|
|
25
|
-
| --- | --- |
|
|
26
|
-
| `getHistory(filePath)` | 新しい順の `DiffRevision[]` |
|
|
27
|
-
| `getRevisionMarkdown(filePath, hash)` | その時点の Markdown。なければ `null` |
|
|
28
|
-
| `getCurrentDiff(filePath)` | 最新と一つ前のリビジョンの差分 |
|
|
29
|
-
| `compareRevisions(input)` | 指定した二つのリビジョンの差分 |
|
|
30
|
-
|
|
31
|
-
`cwd` は Git コマンドを実行するディレクトリで、既定値は `process.cwd()` です。Git リポジトリ外を指定しても例外は投げず、空の結果を返します。
|
|
32
|
-
|
|
33
|
-
## 公開 API
|
|
34
|
-
|
|
35
|
-
- `diff(options?)`、`createPostDiffApi(options?)`
|
|
36
|
-
- `createLineDiff(from, to)`、`GitMarkdownHistoryReader`
|
|
37
|
-
- `DiffRevision`、`MarkdownRevision`、`PostDiff`、`DiffLine`、`DiffLineType`、`RevisionComparisonInput`
|
|
38
|
-
|
|
39
|
-
## 関連資料
|
|
40
|
-
|
|
41
|
-
- [プラグインシステム](../../../docs/ja/plugin-
|
|
1
|
+
# @riebeckite/plugin-diff
|
|
2
|
+
|
|
3
|
+
ローカル Git リポジトリから、Markdown ノートの履歴と行単位の差分を取得するプラグインです。
|
|
4
|
+
|
|
5
|
+
[English](./README.md)
|
|
6
|
+
|
|
7
|
+
## できること
|
|
8
|
+
|
|
9
|
+
中心となる API は `createPostDiffApi()` です。リネームや移動後のファイルも `git log --follow` で追跡し、履歴、指定リビジョンの本文、任意の二つのリビジョン間の差分を返します。`createLineDiff()` は単独でも使える純粋な差分関数です。
|
|
10
|
+
|
|
11
|
+
## 設定と利用例
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { defineConfig } from "@riebeckite/core";
|
|
15
|
+
import { createPostDiffApi, diff } from "@riebeckite/plugin-diff";
|
|
16
|
+
|
|
17
|
+
export default defineConfig({ plugins: [diff({ cwd: "./content" })] });
|
|
18
|
+
|
|
19
|
+
const api = createPostDiffApi({ cwd: "./content" });
|
|
20
|
+
const history = await api.getHistory("notes/hello.md");
|
|
21
|
+
const current = await api.getCurrentDiff("notes/hello.md");
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
| API | 返す内容 |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `getHistory(filePath)` | 新しい順の `DiffRevision[]` |
|
|
27
|
+
| `getRevisionMarkdown(filePath, hash)` | その時点の Markdown。なければ `null` |
|
|
28
|
+
| `getCurrentDiff(filePath)` | 最新と一つ前のリビジョンの差分 |
|
|
29
|
+
| `compareRevisions(input)` | 指定した二つのリビジョンの差分 |
|
|
30
|
+
|
|
31
|
+
`cwd` は Git コマンドを実行するディレクトリで、既定値は `process.cwd()` です。Git リポジトリ外を指定しても例外は投げず、空の結果を返します。
|
|
32
|
+
|
|
33
|
+
## 公開 API
|
|
34
|
+
|
|
35
|
+
- `diff(options?)`、`createPostDiffApi(options?)`
|
|
36
|
+
- `createLineDiff(from, to)`、`GitMarkdownHistoryReader`
|
|
37
|
+
- `DiffRevision`、`MarkdownRevision`、`PostDiff`、`DiffLine`、`DiffLineType`、`RevisionComparisonInput`
|
|
38
|
+
|
|
39
|
+
## 関連資料
|
|
40
|
+
|
|
41
|
+
- [プラグインシステム](../../../docs/ja/reference/plugin-api.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-diff",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"./style.css": "./style.css"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@riebeckite/core": "0.0.
|
|
24
|
+
"@riebeckite/core": "0.0.13"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^24.5.2",
|
|
28
28
|
"tsx": "^4.22.4",
|
|
29
|
-
"@riebeckite/test": "0.0.
|
|
29
|
+
"@riebeckite/test": "0.0.13"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|