@riebeckite/plugin-rename 0.0.14 → 0.0.16
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 +5 -3
- package/README_ja.md +3 -2
- package/dist/index.js +3 -8
- package/dist/src/lock.d.ts +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,8 +65,9 @@ severity follows `onUnexpectedRemoval`.
|
|
|
65
65
|
|
|
66
66
|
The plugin never writes files directly. The only cross-build state is the route
|
|
67
67
|
lock, stored through `context.cache` under the key `routes.lock`. The cache is
|
|
68
|
-
created under
|
|
69
|
-
|
|
68
|
+
created under the resolved plugin cache directory (`.riebeckite/cache` in the
|
|
69
|
+
standard HonoX setup) and is gitignored, so the lock is machine-local and is
|
|
70
|
+
regenerated from scratch when missing or corrupt.
|
|
70
71
|
|
|
71
72
|
Because the lock is machine-local, the first build on a fresh machine has no
|
|
72
73
|
history and cannot detect a rename that happened before the lock existed.
|
|
@@ -120,4 +121,5 @@ Types:
|
|
|
120
121
|
## See also
|
|
121
122
|
|
|
122
123
|
- [Permalink plugin](../permalink/README.md) — stable URLs and `redirect_from`
|
|
123
|
-
- [Plugin guide](../../../docs/en/reference/plugin-api.md)
|
|
124
|
+
- [Plugin guide](../../../docs/en/docs/reference/plugin-api.md)
|
|
125
|
+
|
package/README_ja.md
CHANGED
|
@@ -55,7 +55,7 @@ buildRouteLock ──► 現在の RouteLock
|
|
|
55
55
|
|
|
56
56
|
## 状態の保存
|
|
57
57
|
|
|
58
|
-
プラグインが直接ファイルを書き込むことはありません。ビルドをまたぐ状態はルートロックのみで、`context.cache` の `routes.lock`
|
|
58
|
+
プラグインが直接ファイルを書き込むことはありません。ビルドをまたぐ状態はルートロックのみで、`context.cache` の `routes.lock` キーに保存します。キャッシュは解決済みの plugin cache directory(標準的な HonoX 構成では `.riebeckite/cache`)に作られて gitignore の対象なので、ロックはマシンローカルです。存在しない場合や壊れている場合は空のロックから再生成します。
|
|
59
59
|
|
|
60
60
|
ロックがマシンローカルであるため、新しいマシンでの初回ビルドには履歴がなく、ロックが存在する前に起きたリネームは検出できません。
|
|
61
61
|
|
|
@@ -100,4 +100,5 @@ buildRouteLock ──► 現在の RouteLock
|
|
|
100
100
|
## 関連
|
|
101
101
|
|
|
102
102
|
- [Permalink プラグイン](../permalink/README_ja.md) — 安定した URL と `redirect_from`
|
|
103
|
-
- [プラグインガイド](../../../docs/ja/reference/plugin-api.md)
|
|
103
|
+
- [プラグインガイド](../../../docs/ja/docs/reference/plugin-api.md)
|
|
104
|
+
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// index.ts
|
|
2
2
|
import {
|
|
3
|
-
definePlugin
|
|
4
|
-
isPublished
|
|
3
|
+
definePlugin
|
|
5
4
|
} from "@riebeckite/core";
|
|
6
5
|
|
|
7
6
|
// src/lock.ts
|
|
@@ -16,10 +15,9 @@ function emptyRouteLock() {
|
|
|
16
15
|
function isRedirectStatus(value) {
|
|
17
16
|
return value === 301 || value === 302 || value === 307 || value === 308;
|
|
18
17
|
}
|
|
19
|
-
function buildRouteLock(entries
|
|
18
|
+
function buildRouteLock(entries) {
|
|
20
19
|
const routes = {};
|
|
21
20
|
for (const entry of entries) {
|
|
22
|
-
if (!isPublished2(entry.frontmatter)) continue;
|
|
23
21
|
const id = readId(entry.frontmatter);
|
|
24
22
|
routes[entry.slug] = id ? { permalink: entry.permalink, contentHash: hashContent(entry.html), id } : { permalink: entry.permalink, contentHash: hashContent(entry.html) };
|
|
25
23
|
}
|
|
@@ -243,10 +241,7 @@ function renamePlugin(options = {}) {
|
|
|
243
241
|
return;
|
|
244
242
|
}
|
|
245
243
|
const previous = await readLock(cache, logger);
|
|
246
|
-
const current = buildRouteLock(
|
|
247
|
-
manifest.entries,
|
|
248
|
-
(frontmatter) => isPublished(config, frontmatter)
|
|
249
|
-
);
|
|
244
|
+
const current = buildRouteLock(manifest.publicEntries);
|
|
250
245
|
const result = diffRoutes(previous, current, {
|
|
251
246
|
status,
|
|
252
247
|
onUnexpectedRemoval
|
package/dist/src/lock.d.ts
CHANGED
|
@@ -34,8 +34,8 @@ export type DiffRoutesOptions = {
|
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* Minimal shape `buildRouteLock` reads from a content manifest entry. Only
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* routable entries should reach this function so this module stays free of any
|
|
38
|
+
* runtime Core import.
|
|
39
39
|
*/
|
|
40
40
|
export type RouteLockSourceEntry = {
|
|
41
41
|
slug: string;
|
|
@@ -47,11 +47,11 @@ export declare function hashContent(html: string): string;
|
|
|
47
47
|
export declare function emptyRouteLock(): RouteLock;
|
|
48
48
|
export declare function isRedirectStatus(value: unknown): value is RedirectStatus;
|
|
49
49
|
/**
|
|
50
|
-
* Builds the current route lock from manifest
|
|
51
|
-
* slug and only
|
|
50
|
+
* Builds the current route lock from the routed manifest view. Entries are keyed by
|
|
51
|
+
* slug and only routable entries are considered. Output is deterministic:
|
|
52
52
|
* route keys are sorted and redirects (always empty here) stay sorted.
|
|
53
53
|
*/
|
|
54
|
-
export declare function buildRouteLock(entries: readonly RouteLockSourceEntry[]
|
|
54
|
+
export declare function buildRouteLock(entries: readonly RouteLockSourceEntry[]): RouteLock;
|
|
55
55
|
/**
|
|
56
56
|
* Parses a persisted lock. Returns `undefined` when the value is corrupt or
|
|
57
57
|
* uses an unknown format, so callers can fall back to an empty lock.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-rename",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@riebeckite/core": "0.0.
|
|
17
|
+
"@riebeckite/core": "0.0.16"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"tsx": "^4.22.4"
|