mdat 3.6.2 → 3.6.3

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/dist/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { S as version, a as expand, b as setLogger$1, d as templates_default, f as ensureArray, l as createReadme, r as collapse, s as strip, t as check, u as createReadmeInteractive, x as name, y as log } from "../lib-BEUFGevf.js";
2
+ import { S as version, a as expand, b as setLogger$1, d as templates_default, f as ensureArray, l as createReadme, r as collapse, s as strip, t as check, u as createReadmeInteractive, x as name, y as log } from "../lib-CX9VHWwF.js";
3
3
  import { createLogger } from "lognow";
4
4
  import picocolors from "picocolors";
5
5
  import prettyMilliseconds from "pretty-ms";
@@ -146,8 +146,6 @@ export declare function checkString(markdown: string, config?: ConfigToLoad, opt
146
146
  /**
147
147
  * Get a bunch of platform-agnostic local metadata via metascope, exposed
148
148
  * primarily for plugin developers. Result is memoized the result.
149
- *
150
- * @throws {Error} If no package.json is found
151
149
  */
152
150
  export declare function getContextMetadata(): Promise<MetadataContext>;
153
151
  declare const readmeMetadataTemplate: import("metascope").Template<{
@@ -191,6 +189,7 @@ declare const readmeMetadataTemplate: import("metascope").Template<{
191
189
  repositoryUrl: string | undefined;
192
190
  runtimePlatform: string[] | undefined;
193
191
  usesGitLfs: boolean;
192
+ usesSharedConfig: boolean;
194
193
  vscodeExtensionId: string | undefined;
195
194
  }>;
196
195
  type ReadmeMetadata = ReturnType<typeof readmeMetadataTemplate>;
@@ -240,6 +239,7 @@ export declare function getReadmeMetadata(): Promise<{
240
239
  repositoryUrl: string | undefined;
241
240
  runtimePlatform: string[] | undefined;
242
241
  usesGitLfs: boolean;
242
+ usesSharedConfig: boolean;
243
243
  vscodeExtensionId: string | undefined;
244
244
  }>;
245
245
  /**
package/dist/lib/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { _ as getReadmeMetadata, a as expand, b as setLogger, c as stripString, g as getContextMetadata, h as mergeConfig, i as collapseString, l as createReadme, m as loadConfig, n as checkString, o as expandString, p as defineConfig, r as collapse, s as strip, t as check, u as createReadmeInteractive, v as resetMetadataCaches } from "../lib-BEUFGevf.js";
1
+ import { _ as getReadmeMetadata, a as expand, b as setLogger, c as stripString, g as getContextMetadata, h as mergeConfig, i as collapseString, l as createReadme, m as loadConfig, n as checkString, o as expandString, p as defineConfig, r as collapse, s as strip, t as check, u as createReadmeInteractive, v as resetMetadataCaches } from "../lib-CX9VHWwF.js";
2
2
 
3
3
  export { check, checkString, collapse, collapseString, createReadme as create, createReadmeInteractive as createInteractive, defineConfig, expand, expandString, getContextMetadata, getReadmeMetadata, loadConfig, mergeConfig, resetMetadataCaches, setLogger, strip, stripString };
@@ -26,7 +26,7 @@ import { confirm, group, intro, note, outro, select } from "@clack/prompts";
26
26
 
27
27
  //#region package.json
28
28
  var name = "mdat";
29
- var version = "3.6.2";
29
+ var version = "3.6.3";
30
30
 
31
31
  //#endregion
32
32
  //#region src/lib/deep-merge-defined.ts
@@ -94,8 +94,6 @@ let metascopeMetadata;
94
94
  /**
95
95
  * Get a bunch of platform-agnostic local metadata via metascope, exposed
96
96
  * primarily for plugin developers. Result is memoized the result.
97
- *
98
- * @throws {Error} If no package.json is found
99
97
  */
100
98
  async function getContextMetadata() {
101
99
  if (metascopeMetadata !== void 0) return metascopeMetadata;
@@ -143,6 +141,13 @@ const PACKAGE_MANAGER_REGEX = /^(?<name>[^@]+)@(?<version>[^+]+)/v;
143
141
  const BREWPUB_TAP_REGEX = /\bbrewpub\b[^&;]*?--tap[ =](?<tap>[\w.\-\/]+)/v;
144
142
  const BREWPUB_NAME_REGEX = /\bbrewpub\b[^&;]*?--name[ =](?<name>[\w.\-\/@+]+)/v;
145
143
  const HOMEBREW_TAP_PREFIX_REGEX = /^homebrew-/v;
144
+ const SHARED_CONFIG_PACKAGE = "@kitschpatrol/shared-config";
145
+ /**
146
+ * Normalize repository URLs for README links and badges.
147
+ */
148
+ function normalizeRepositoryUrl(url) {
149
+ return url?.replace(GIT_PREFIX_REGEX, "").replace(GIT_SUFFIX_REGEX, "").replace(TRAILING_SLASH_REGEX, "");
150
+ }
146
151
  /**
147
152
  * True if the package.json `exports` field declares a `types` condition
148
153
  * anywhere in its (possibly nested) structure.
@@ -215,6 +220,13 @@ function getRepositoryDirectory(nodePackage) {
215
220
  return typeof nodePackage?.repository === "object" ? nodePackage.repository.directory : void 0;
216
221
  }
217
222
  /**
223
+ * True if package.json lists `@kitschpatrol/shared-config` as a dependency or
224
+ * dev dependency, meaning the repository is linted and formatted with `ksc`.
225
+ */
226
+ function dependsOnSharedConfig(nodePackage) {
227
+ return nodePackage?.dependencies?.[SHARED_CONFIG_PACKAGE] !== void 0 || nodePackage?.devDependencies?.[SHARED_CONFIG_PACKAGE] !== void 0;
228
+ }
229
+ /**
218
230
  * Reset cached context metadata. Call between tests or when the underlying
219
231
  * project files may have changed on disk.
220
232
  *
@@ -229,7 +241,7 @@ const readmeMetadataTemplate = defineTemplate((context) => {
229
241
  const nodePackage = helpers.firstOf(nodePackageJson)?.data;
230
242
  const licenseFileData = helpers.firstOf(licenseFile);
231
243
  const ciActionFilePath = helpers.ensureArray(githubActions).find((entry) => entry.data.name.toLowerCase() === "ci")?.source;
232
- const repositoryUrl = codemeta.codeRepository?.replace(GIT_PREFIX_REGEX, "").replace(GIT_SUFFIX_REGEX, "").replace(TRAILING_SLASH_REGEX, "");
244
+ const repositoryUrl = normalizeRepositoryUrl(codemeta.codeRepository);
233
245
  const bin = (() => {
234
246
  if (nodePackage === void 0) return;
235
247
  const binField = nodePackage.bin;
@@ -309,6 +321,7 @@ const readmeMetadataTemplate = defineTemplate((context) => {
309
321
  repositoryUrl,
310
322
  runtimePlatform: codemeta.runtimePlatform,
311
323
  usesGitLfs: helpers.firstOf(gitStats)?.data.hasLfs === true,
324
+ usesSharedConfig: dependsOnSharedConfig(nodePackage),
312
325
  vscodeExtensionId
313
326
  };
314
327
  });
@@ -413,7 +426,7 @@ const badgeDefinitions = [
413
426
  },
414
427
  {
415
428
  key: "license",
416
- render: ({ license, licenseUrl }) => license === void 0 || licenseUrl === void 0 ? { unavailable: "no license file matching a known SPDX license was found" } : [`[![License: ${license}](https://img.shields.io/badge/License-${license.replaceAll("-", "--")}-yellow.svg)](${licenseUrl})`]
429
+ render: ({ license, licenseUrl }) => license === void 0 || licenseUrl === void 0 ? { unavailable: "no license file matching a known SPDX license was found" } : [`[![License: ${license}](https://img.shields.io/badge/License-${escapeStaticBadgeText(license)}-yellow.svg)](${licenseUrl})`]
417
430
  },
418
431
  {
419
432
  key: "ci",
@@ -622,15 +635,16 @@ var contributing_default = { contributing: { async content(options) {
622
635
  heading: headingSchema,
623
636
  headingLevel: headingLevelSchema
624
637
  }).optional().parse(options);
625
- const { issuesUrl } = await getReadmeMetadata();
626
- if (issuesUrl === void 0) throw new Error("Could not find \"bugs.url\" entry in package.json");
638
+ const { issuesUrl, usesSharedConfig } = await getReadmeMetadata();
639
+ if (issuesUrl === void 0) throw new Error("Could not find an issue tracker URL in the project metadata. Add \"bugs.url\" to package.json, \"issueTracker\" to codemeta.json, or a GitHub repository URL.");
640
+ const toolingLine = usesSharedConfig ? "This repository uses [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config) (via its `ksc` CLI) for linting and formatting, plus [MDAT](https://github.com/kitschpatrol/mdat) for readme placeholder expansion." : "This repository uses [MDAT](https://github.com/kitschpatrol/mdat) for readme placeholder expansion.";
627
641
  return [
628
642
  ...getHeadingLines(validOptions?.heading, validOptions?.headingLevel ?? 2, "Contributing"),
629
643
  `[Issues](${issuesUrl}) are welcome and appreciated.`,
630
644
  "",
631
645
  "Please open an issue to discuss changes before submitting a pull request. Unsolicited PRs (especially AI-generated ones) are unlikely to be merged.",
632
646
  "",
633
- "This repository uses [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config) (via its `ksc` CLI) for linting and formatting, plus [MDAT](https://github.com/kitschpatrol/mdat) for readme placeholder expansion."
647
+ toolingLine
634
648
  ].join("\n");
635
649
  } } };
636
650
 
@@ -749,7 +763,7 @@ var dependencies_default = { dependencies: { async content(options) {
749
763
  */
750
764
  var description_default = { description: { async content() {
751
765
  const { description } = await getReadmeMetadata();
752
- if (description === void 0) throw new Error("Could not find \"description\" entry in package.json");
766
+ if (description === void 0) throw new Error("Could not find project description");
753
767
  return `**${description}**`;
754
768
  } } };
755
769
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdat",
3
- "version": "3.6.2",
3
+ "version": "3.6.3",
4
4
  "description": "CLI tool and TypeScript library to turn comments into content in Markdown files. MDAT makes it easy to generate and update dynamic boilerplate in project readmes.",
5
5
  "keywords": [
6
6
  "mdat",
@@ -11,7 +11,8 @@
11
11
  "docs-generator",
12
12
  "docs",
13
13
  "cli",
14
- "npm-package"
14
+ "npm-package",
15
+ "homebrew-formula"
15
16
  ],
16
17
  "homepage": "https://github.com/kitschpatrol/mdat",
17
18
  "bugs": "https://github.com/kitschpatrol/mdat/issues",
@@ -52,7 +53,7 @@
52
53
  "gray-matter-es": "^0.2.1",
53
54
  "lognow": "^0.8.5",
54
55
  "mdast-util-toc": "^7.1.0",
55
- "metascope": "^0.12.2",
56
+ "metascope": "^0.13.2",
56
57
  "path-type": "^6.0.0",
57
58
  "picocolors": "^1.1.1",
58
59
  "plur": "^6.0.0",
@@ -67,31 +68,31 @@
67
68
  "untildify": "^6.0.0",
68
69
  "vfile": "^6.0.3",
69
70
  "yargs": "^18.2.0",
70
- "zod": "^4.6.5"
71
+ "zod": "^4.6.7"
71
72
  },
72
73
  "devDependencies": {
73
74
  "@arethetypeswrong/core": "^0.18.5",
74
- "@kitschpatrol/shared-config": "^8.12.1",
75
+ "@kitschpatrol/shared-config": "^8.13.1",
75
76
  "@types/mdast": "^4.0.4",
76
77
  "@types/node": "~24.13.6",
77
78
  "@types/unist": "^3.0.3",
78
79
  "@types/yargs": "^17.0.35",
79
- "@vitest/coverage-v8": "^5.0.3",
80
+ "@vitest/coverage-v8": "^5.0.4",
80
81
  "brewpub": "^0.5.0",
81
82
  "bumpp": "^12.3.0",
82
- "execa": "^10.0.1",
83
- "mdat-plugin-cli-help": "^3.4.0",
84
- "mdat-plugin-example": "^3.0.0",
85
- "mdat-plugin-tldraw": "^3.0.0",
83
+ "execa": "^10.1.0",
84
+ "mdat-plugin-cli-help": "^3.4.1",
85
+ "mdat-plugin-example": "^3.0.1",
86
+ "mdat-plugin-tldraw": "^3.0.1",
86
87
  "nanoid": "^6.0.2",
87
- "prettier": "^3.9.9",
88
+ "prettier": "^3.9.10",
88
89
  "publint": "^0.3.25",
89
90
  "shx": "^0.4.0",
90
- "skills": "^1.7.0",
91
- "tsdown": "^0.23.0",
91
+ "skills": "1.7.1",
92
+ "tsdown": "^0.23.1",
92
93
  "typescript": "~6.0.3",
93
94
  "unplugin-raw": "^0.8.0",
94
- "vitest": "^5.0.3"
95
+ "vitest": "^5.0.4"
95
96
  },
96
97
  "peerDependencies": {
97
98
  "prettier": "^3.0.0"
package/readme.md CHANGED
@@ -42,7 +42,7 @@
42
42
  - [Agent skills](#agent-skills)
43
43
  - [Skill: `mdat`](#skill-mdat)
44
44
  - [Skill: `mdat-plugin-authoring`](#skill-mdat-plugin-authoring)
45
- - [Migrating from 1.x to 2.x](#migrating-from-1x-to-2x)
45
+ - [Migrating from 1.x to 2.x or 3.x](#migrating-from-1x-to-2x-or-3x)
46
46
  - [Flat CLI commands](#flat-cli-commands)
47
47
  - [Polyglot metadata](#polyglot-metadata)
48
48
  - [Simplified configuration](#simplified-configuration)
@@ -231,6 +231,18 @@ npm install mdat
231
231
 
232
232
  Bundled rules pull normalized metadata from almost any project type via [metascope](https://github.com/kitschpatrol/metascope), not just `package.json`.
233
233
 
234
+ Projects without a package manifest can provide a `metadata.json` file (`metadata.yaml` and `metadata.yml` also work):
235
+
236
+ ```json
237
+ {
238
+ "description": "A light sculpture for Disorient.",
239
+ "keywords": ["installation", "led"],
240
+ "repository": "https://github.com/kitschpatrol/asterism"
241
+ }
242
+ ```
243
+
244
+ This is a small format for GitHub descriptions, homepages, and topics. Metascope's shared CodeMeta templates also aggregate these fields, and MDAT consumes their normalized result. Project names and richer metadata come from package manifests, `codemeta.json`, or other supported sources; an existing README heading remains a title fallback.
245
+
234
246
  ## Usage
235
247
 
236
248
  > [!WARNING]
@@ -662,7 +674,7 @@ Rules that generate inline content, like `badges`, `code`, and `size`, have no h
662
674
 
663
675
  - ##### `<!-- contributing -->`
664
676
 
665
- Invites issues and pull requests with links derived from project metadata.
677
+ Invites issues and pull requests with links derived from project metadata. Mentions [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config) only when `package.json` lists it as a dependency.
666
678
 
667
679
  - ##### `<!-- license -->`
668
680
 
@@ -829,9 +841,11 @@ Write custom mdat expansion rules and publishable mdat rule plugins (mdat-plugin
829
841
 
830
842
  <!-- /skills -->
831
843
 
832
- ## Migrating from 1.x to 2.x
844
+ ## Migrating from 1.x to 2.x or 3.x
845
+
846
+ The 2.0 version introduces significant breaking changes in the interest of simplicity and a somewhat narrowed scope of concerns. 3.0 was a mostly non-breaking, only dropping support for Node 22.
833
847
 
834
- The 2.0 version introduces significant breaking changes in the interest of simplicity and a somewhat narrowed scope of concerns.
848
+ Plugin compatibility was broken from 1.x to 2.x, but maintained in 3.x.
835
849
 
836
850
  Details of the changes and migration strategies are enumerated below.
837
851
 
@@ -846,6 +860,7 @@ The `mdat readme` subcommand is gone. All commands are now top-level:
846
860
  | `mdat readme check` | `mdat check` |
847
861
  | `mdat expand` | `mdat expand` |
848
862
  | `mdat collapse` | `mdat collapse` |
863
+ | _no equivalent_ | `mdat strip` |
849
864
 
850
865
  Running `mdat` with no arguments expands the closest readme, matching the behavior of the 1.x `mdat readme` command.
851
866