@riebeckite/plugin-diagnostics 0.0.15 → 0.0.17

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 CHANGED
@@ -32,7 +32,7 @@ export default defineConfig({
32
32
 
33
33
  - `addDiagnostics` — runs the analysis at build time; results go to
34
34
  `manifest.diagnostics`
35
- - `onBuildEnd` — with `failOnError: true`, throws `DiagnosticsFailure` when
35
+ - `buildEnd` — with `failOnError: true`, throws `DiagnosticsFailure` when
36
36
  error-level diagnostics exist
37
37
 
38
38
  ## Checks
@@ -48,8 +48,8 @@ export default defineConfig({
48
48
  | `publish-conflict` | `warning` | `publish: true` combined with `draft: true` / `private: true` |
49
49
  | `duplicate-title` | `warning` | Multiple published notes share a title within the same language |
50
50
  | `slug-collision` | `error` | Slugs collide case-insensitively |
51
- | `duplicate-content-id` | `error` | Published notes share a stable content ID (`id`/`uid`) |
52
- | `invalid-content-id` | `error` | `id`/`uid` frontmatter violates the stable content ID contract |
51
+ | `duplicate-content-id` | `error` | Published notes share a stable content ID (`id`) |
52
+ | `invalid-content-id` | `error` | `id` frontmatter violates the stable content ID contract |
53
53
  | `excluded-public` | `warning` | Excluded note is marked `publish: true` |
54
54
  | `publish-boundary` | `warning` | Published content links to or embeds non-published content |
55
55
  | `analytics-untracked` | `info` | Published note has no stable `id` and the analytics plugin will not track it (enabled with `reportAnalyticsCoverage`, or automatically when the config enables the analytics plugin) |
@@ -160,4 +160,3 @@ assertNoErrors(report);
160
160
  ## See also
161
161
 
162
162
  - [Plugin guide](../../../docs/en/docs/reference/plugin-api.md)
163
-
package/README_ja.md CHANGED
@@ -24,6 +24,8 @@ export default defineConfig({
24
24
  });
25
25
  ```
26
26
 
27
+ `failOnError: true` を指定すると、`buildEnd` で error レベルの Diagnostics が残っている場合に `DiagnosticsFailure` を送出します。
28
+
27
29
  ## 検出する問題
28
30
 
29
31
  | コード | 既定の重要度 | 内容 |
@@ -37,8 +39,8 @@ export default defineConfig({
37
39
  | `publish-conflict` | warning | `publish: true` と `draft: true` または `private: true` が同居している |
38
40
  | `duplicate-title` | warning | 同じ言語の公開ノート同士でタイトルが重複している |
39
41
  | `slug-collision` | error | 大文字・小文字を区別しない slug が衝突している |
40
- | `duplicate-content-id` | error | 公開ノート同士で安定コンテンツ ID(`id`/`uid`)が重複している |
41
- | `invalid-content-id` | error | `id`/`uid` の frontmatter が安定コンテンツ ID の要件を満たしていない |
42
+ | `duplicate-content-id` | error | 公開ノート同士で安定コンテンツ ID(`id`)が重複している |
43
+ | `invalid-content-id` | error | `id` の frontmatter が安定コンテンツ ID の要件を満たしていない |
42
44
  | `excluded-public` | warning | 除外されたノートに `publish: true` が指定されている |
43
45
  | `publish-boundary` | warning | 公開コンテンツから非公開コンテンツへリンク・埋め込みしている |
44
46
  | `analytics-untracked` | info | 安定 `id` のない公開ノートは analytics プラグインで計測されない(`reportAnalyticsCoverage` で有効化。設定で analytics プラグインが有効な場合は自動で有効化) |
@@ -116,4 +118,3 @@ assertNoErrors(report);
116
118
  ## 関連資料
117
119
 
118
120
  - [プラグインシステム](../../../docs/ja/docs/reference/plugin-api.md)
119
-
package/dist/bin.js CHANGED
@@ -143,7 +143,7 @@ function checkAnalyticsCoverage(source, options, diagnostics) {
143
143
  }
144
144
  }
145
145
  function hasAnalyticsId(note) {
146
- return hasField(note.fm.values, "id") || hasField(note.fm.values, "uid");
146
+ return hasField(note.fm.values, "id");
147
147
  }
148
148
 
149
149
  // src/checks/assets.ts
@@ -180,7 +180,7 @@ function checkContentIdIntegrity(source, options, diagnostics) {
180
180
  "invalid-content-id",
181
181
  `invalid content id frontmatter: ${toErrorMessage(error)}`,
182
182
  void 0,
183
- 'set a unique, trimmed "id" value and remove a conflicting "uid" value'
183
+ 'set a unique, trimmed "id" value'
184
184
  );
185
185
  continue;
186
186
  }
@@ -200,7 +200,7 @@ function checkContentIdIntegrity(source, options, diagnostics) {
200
200
  "duplicate-content-id",
201
201
  `content id "${id}" is used by multiple published notes: ${slugs}`,
202
202
  id,
203
- 'give each note a unique "id" (or "uid") frontmatter value'
203
+ 'give each note a unique "id" frontmatter value'
204
204
  );
205
205
  }
206
206
  }
package/dist/index.js CHANGED
@@ -139,7 +139,7 @@ function checkAnalyticsCoverage(source, options, diagnostics2) {
139
139
  }
140
140
  }
141
141
  function hasAnalyticsId(note) {
142
- return hasField(note.fm.values, "id") || hasField(note.fm.values, "uid");
142
+ return hasField(note.fm.values, "id");
143
143
  }
144
144
 
145
145
  // src/checks/assets.ts
@@ -176,7 +176,7 @@ function checkContentIdIntegrity(source, options, diagnostics2) {
176
176
  "invalid-content-id",
177
177
  `invalid content id frontmatter: ${toErrorMessage(error)}`,
178
178
  void 0,
179
- 'set a unique, trimmed "id" value and remove a conflicting "uid" value'
179
+ 'set a unique, trimmed "id" value'
180
180
  );
181
181
  continue;
182
182
  }
@@ -196,7 +196,7 @@ function checkContentIdIntegrity(source, options, diagnostics2) {
196
196
  "duplicate-content-id",
197
197
  `content id "${id}" is used by multiple published notes: ${slugs}`,
198
198
  id,
199
- 'give each note a unique "id" (or "uid") frontmatter value'
199
+ 'give each note a unique "id" frontmatter value'
200
200
  );
201
201
  }
202
202
  }
@@ -1010,7 +1010,7 @@ function checkSiteIntegrity(manifest, options = {}) {
1010
1010
  checkResolvedLinks(entry, publicSlugs, assetPaths, diagnostics2, options);
1011
1011
  checkHtmlReferences(entry, publicRoutes, assetPaths, diagnostics2, options);
1012
1012
  }
1013
- checkRedirectTargets(manifest, publicRoutes, diagnostics2, options);
1013
+ checkRedirectTargets(manifest, diagnostics2, options);
1014
1014
  checkRedirectCycles(manifest, diagnostics2, options);
1015
1015
  checkAmbiguousFolderPageOwners(manifest, diagnostics2, options);
1016
1016
  return diagnostics2;
@@ -1049,13 +1049,6 @@ function buildRouteOwners(manifest, diagnostics2, options) {
1049
1049
  });
1050
1050
  }
1051
1051
  }
1052
- for (const output of manifest.generatedOutputs ?? []) {
1053
- reserveRoute(owners, diagnostics2, options, {
1054
- path: normalizeRoutePath(output.path),
1055
- slug: "(generated-output)",
1056
- kind: "output"
1057
- });
1058
- }
1059
1052
  return owners;
1060
1053
  }
1061
1054
  function reserveRoute(owners, diagnostics2, options, next) {
@@ -1072,7 +1065,7 @@ function reserveRoute(owners, diagnostics2, options, next) {
1072
1065
  slug: next.slug.startsWith("(") ? void 0 : next.slug,
1073
1066
  target: next.path,
1074
1067
  message: `Public path "${next.path}" is claimed by both ${describeOwner(previous)} and ${describeOwner(next)}.`,
1075
- suggestion: "Change one permalink, alias, redirect, page path, or generated output path.",
1068
+ suggestion: "Change one permalink, alias, redirect, or page path.",
1076
1069
  meta: { previous, next }
1077
1070
  })
1078
1071
  );
@@ -1161,11 +1154,12 @@ function checkHtmlReferences(entry, publicRoutes, assetPaths, diagnostics2, opti
1161
1154
  );
1162
1155
  }
1163
1156
  }
1164
- function checkRedirectTargets(manifest, publicRoutes, diagnostics2, options) {
1165
- for (const [path, redirect] of manifest.publicRedirects) {
1157
+ function checkRedirectTargets(manifest, diagnostics2, options) {
1158
+ for (const [path, redirect] of manifest.redirects) {
1166
1159
  const owner = manifest.bySlug.get(redirect.slug);
1167
1160
  const target = owner ? normalizeRoutePath(owner.publicLocation.permalink) : null;
1168
- if (target && publicRoutes.has(target)) continue;
1161
+ if (target && manifest.byRoutablePermalink.get(target)?.slug === redirect.slug)
1162
+ continue;
1169
1163
  diagnostics2.push(
1170
1164
  diagnostic(options, {
1171
1165
  code: "content-integrity:redirect-target-missing",
@@ -1224,8 +1218,6 @@ function buildAssetPaths(manifest) {
1224
1218
  }
1225
1219
  for (const asset of manifest.assets ?? [])
1226
1220
  paths.add(asset.path.replace(/^\/+/, ""));
1227
- for (const output of manifest.generatedOutputs ?? [])
1228
- paths.add(output.path.replace(/^\/+/, ""));
1229
1221
  return paths;
1230
1222
  }
1231
1223
  function extractAttributes(html, attribute) {
@@ -1358,7 +1350,7 @@ function diagnostics(options = {}) {
1358
1350
  onManifestCreated: ({ manifest, diagnostics: diagnostics2 }) => {
1359
1351
  diagnostics2.push(...checkSiteIntegrity(manifest, options));
1360
1352
  },
1361
- onBuildEnd: ({ manifest }) => {
1353
+ buildEnd: ({ manifest }) => {
1362
1354
  if (!options.failOnError) return void 0;
1363
1355
  const errors = manifest.diagnostics.filter(
1364
1356
  (diagnostic2) => diagnostic2.pluginName === PLUGIN_NAME3 && diagnostic2.severity === "error"
@@ -5,8 +5,8 @@ import { type NormalizedOptions } from "./shared.js";
5
5
  * Reports published content that the analytics plugin will not track.
6
6
  *
7
7
  * The analytics browser initializer emits a page view only for entries that
8
- * carry Core's source-authored stable content ID (`id`, or the compatible
9
- * `uid`). Content without that ID builds and publishes normally but is silently
8
+ * carry Core's source-authored stable content ID (`id`). Content without that
9
+ * ID builds and publishes normally but is silently
10
10
  * absent from analytics. This check surfaces that gap as factual, read-only
11
11
  * `info` findings; the analytics plugin itself never autofixes content.
12
12
  */
@@ -5,9 +5,8 @@ import { type NormalizedOptions } from "./shared.js";
5
5
  * Checks stable content ID integrity.
6
6
  *
7
7
  * Stable content IDs come from the optional source-authored `id` frontmatter
8
- * field (`uid` is accepted for legacy content). They are the identity key for
9
- * per-content consumers such as analytics page views, so duplicates silently
10
- * merge per-content metrics and conflicting declarations break the build.
8
+ * field. They are the identity key for per-content consumers such as analytics
9
+ * page views, so duplicates silently merge per-content metrics.
11
10
  * This check is intentionally generic: it validates the content-model invariant
12
11
  * without knowing which plugin consumes the ID.
13
12
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-diagnostics",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "remark-parse": "^11.0.0",
21
21
  "unified": "^11.0.5",
22
22
  "unist-util-visit": "^5.1.0",
23
- "@riebeckite/core": "0.0.15"
23
+ "@riebeckite/core": "0.0.17"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/mdast": "^4.0.4",