mdat 2.3.0 → 2.3.1

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
@@ -42,7 +42,7 @@ function deepMergeDefined(...objects) {
42
42
  //#endregion
43
43
  //#region package.json
44
44
  var name = "mdat";
45
- var version = "2.3.0";
45
+ var version = "2.3.1";
46
46
 
47
47
  //#endregion
48
48
  //#region src/lib/log.ts
@@ -56,9 +56,11 @@ let log = createLogger({
56
56
  setLogger(getChildLogger(log, "remark-mdat"));
57
57
  setLogger$1(getChildLogger(log, "metascope"));
58
58
  /**
59
- * Set the logger instance for the module.
60
- * Export this for library consumers to inject their own logger.
61
- * @param logger - Accepts either a LogLayer instance or a Console- or Stream-like log target
59
+ * Set the logger instance for the module. Export this for library consumers to
60
+ * inject their own logger.
61
+ *
62
+ * @param logger - Accepts either a LogLayer instance or a Console- or
63
+ * Stream-like log target
62
64
  */
63
65
  function setLogger$2(logger) {
64
66
  log = injectionHelper(logger);
@@ -69,9 +71,10 @@ function setLogger$2(logger) {
69
71
  //#endregion
70
72
  //#region src/lib/mdat-json-loader.ts
71
73
  /**
72
- * Lets arbitrary JSON objects (like from package.json) become reasonably good mdat rule sets
73
- * HOWEVER cosmiconfig treats package.json as a special case and will always load only specific keys from it
74
- * So we have to intercept and load them manually in config.ts
74
+ * Lets arbitrary JSON objects (like from package.json) become reasonably good
75
+ * mdat rule sets HOWEVER cosmiconfig treats package.json as a special case and
76
+ * will always load only specific keys from it So we have to intercept and load
77
+ * them manually in config.ts
75
78
  */
76
79
  function mdatJsonLoader(filePath, content) {
77
80
  const defaultJsonLoader = defaultLoaders[".json"];
@@ -183,6 +186,7 @@ const readmeMetadataTemplate = defineTemplate((context) => {
183
186
  issuesUrl: codemeta.issueTracker,
184
187
  license: helpers.toBasicLicense(helpers.firstOf(helpers.ensureArray(codemeta.license))),
185
188
  licenseFilePath: licenseFileData?.source,
189
+ licenseUrl: licenseFileData?.data.spdxUrl,
186
190
  name: codemeta.name,
187
191
  operatingSystem: codemeta.operatingSystem,
188
192
  peerDependencies,
@@ -215,12 +219,12 @@ var badges_default = { badges: { async content(options) {
215
219
  npm: z.array(z.string()).optional()
216
220
  }).optional().parse(options);
217
221
  const metadata = await getReadmeMetadata();
218
- const { ciActionFileName, license, name, repositoryUrl } = metadata;
222
+ const { ciActionFileName, license, licenseUrl, name, repositoryUrl } = metadata;
219
223
  const badges = [];
220
224
  if (validOptions?.npm === void 0) {
221
225
  if (metadata.isPublicNpmPackage) badges.push(`[![NPM Package ${name}](https://img.shields.io/npm/v/${name}.svg)](https://npmjs.com/package/${name})`);
222
226
  } else for (const name of validOptions.npm) badges.push(`[![NPM Package ${name}](https://img.shields.io/npm/v/${name}.svg)](https://npmjs.com/package/${name})`);
223
- if (license !== void 0) badges.push(`[![License: ${license}](https://img.shields.io/badge/License-${license.replaceAll("-", "--")}-yellow.svg)](https://opensource.org/licenses/${license})`);
227
+ if (license !== void 0 && licenseUrl !== void 0) badges.push(`[![License: ${license}](https://img.shields.io/badge/License-${license.replaceAll("-", "--")}-yellow.svg)](${licenseUrl})`);
224
228
  if (ciActionFileName !== void 0 && repositoryUrl !== void 0) badges.push(`[![CI](${repositoryUrl}/actions/workflows/${ciActionFileName}/badge.svg)](${repositoryUrl}/actions/workflows/${ciActionFileName})`);
225
229
  if (validOptions?.custom !== void 0) for (const [name, { image, link }] of Object.entries(validOptions.custom)) badges.push(`[![${name}](${image})](${link})`);
226
230
  return badges.join("\n");
@@ -484,6 +488,7 @@ const brotliCompressAsync = promisify(brotliCompress);
484
488
  const gzipCompressAsync = promisify(gzip);
485
489
  /**
486
490
  * Creates a SizeInfo object with formatted values
491
+ *
487
492
  * @param bytes - Size in bytes
488
493
  * @param originalSize - Original file size for percentage calculation
489
494
  */
@@ -498,9 +503,11 @@ function createSizeInfo(bytes, originalSize) {
498
503
  }
499
504
  /**
500
505
  * Analyzes a file's size and its compressed sizes using Brotli and Gzip
506
+ *
501
507
  * @param filePath - Path to the file to analyze
508
+ *
502
509
  * @returns Promise containing detailed size report
503
- * @throws {Error} if file cannot be read or compressed
510
+ * @throws {Error} If file cannot be read or compressed
504
511
  */
505
512
  async function createSizeReport(filePath) {
506
513
  try {
@@ -724,8 +731,8 @@ function validateConfig(value) {
724
731
  let cachedPrettier;
725
732
  const configCache = /* @__PURE__ */ new Map();
726
733
  /**
727
- * Format a markdown string with Prettier, using config discovered from the file path.
728
- * Requires `prettier` to be installed as a peer dependency.
734
+ * Format a markdown string with Prettier, using config discovered from the file
735
+ * path. Requires `prettier` to be installed as a peer dependency.
729
736
  */
730
737
  async function formatWithPrettier(content, filePath) {
731
738
  if (cachedPrettier === void 0) try {
@@ -956,6 +963,7 @@ var templates_default = {
956
963
  //#region src/lib/readme/create.ts
957
964
  /**
958
965
  * Creates a new readme file interactively.
966
+ *
959
967
  * @returns Path to the created readme file.
960
968
  */
961
969
  async function createReadmeInteractive() {
@@ -996,6 +1004,7 @@ async function createReadmeInteractive() {
996
1004
  }
997
1005
  /**
998
1006
  * Creates a new readme file with the given options.
1007
+ *
999
1008
  * @returns Path to the created readme file.
1000
1009
  */
1001
1010
  async function createReadme(options) {
@@ -60,11 +60,13 @@ type MdatReadmeCreateOptions = {
60
60
  };
61
61
  /**
62
62
  * Creates a new readme file interactively.
63
+ *
63
64
  * @returns Path to the created readme file.
64
65
  */
65
66
  declare function createReadmeInteractive(): Promise<string>;
66
67
  /**
67
68
  * Creates a new readme file with the given options.
69
+ *
68
70
  * @returns Path to the created readme file.
69
71
  */
70
72
  declare function createReadme(options?: Partial<MdatReadmeCreateOptions>): Promise<string>;
@@ -163,6 +165,7 @@ declare const readmeMetadataTemplate: _$metascope.Template<{
163
165
  issuesUrl: string | undefined;
164
166
  license: string | undefined;
165
167
  licenseFilePath: string | undefined;
168
+ licenseUrl: string | undefined;
166
169
  name: string | undefined;
167
170
  operatingSystem: string[] | undefined;
168
171
  peerDependencies: {
@@ -194,6 +197,7 @@ declare function getReadmeMetadata(): Promise<{
194
197
  issuesUrl: string | undefined;
195
198
  license: string | undefined;
196
199
  licenseFilePath: string | undefined;
200
+ licenseUrl: string | undefined;
197
201
  name: string | undefined;
198
202
  operatingSystem: string[] | undefined;
199
203
  peerDependencies: {
@@ -214,9 +218,11 @@ declare function resetMetadataCaches(): void;
214
218
  //#endregion
215
219
  //#region src/lib/log.d.ts
216
220
  /**
217
- * Set the logger instance for the module.
218
- * Export this for library consumers to inject their own logger.
219
- * @param logger - Accepts either a LogLayer instance or a Console- or Stream-like log target
221
+ * Set the logger instance for the module. Export this for library consumers to
222
+ * inject their own logger.
223
+ *
224
+ * @param logger - Accepts either a LogLayer instance or a Console- or
225
+ * Stream-like log target
220
226
  */
221
227
  declare function setLogger(logger?: ILogBasic | ILogLayer<unknown>): void;
222
228
  //#endregion
package/dist/lib/index.js CHANGED
@@ -45,9 +45,11 @@ let log = createLogger({
45
45
  setLogger$1(getChildLogger(log, "remark-mdat"));
46
46
  setLogger$2(getChildLogger(log, "metascope"));
47
47
  /**
48
- * Set the logger instance for the module.
49
- * Export this for library consumers to inject their own logger.
50
- * @param logger - Accepts either a LogLayer instance or a Console- or Stream-like log target
48
+ * Set the logger instance for the module. Export this for library consumers to
49
+ * inject their own logger.
50
+ *
51
+ * @param logger - Accepts either a LogLayer instance or a Console- or
52
+ * Stream-like log target
51
53
  */
52
54
  function setLogger(logger) {
53
55
  log = injectionHelper(logger);
@@ -57,9 +59,10 @@ function setLogger(logger) {
57
59
  //#endregion
58
60
  //#region src/lib/mdat-json-loader.ts
59
61
  /**
60
- * Lets arbitrary JSON objects (like from package.json) become reasonably good mdat rule sets
61
- * HOWEVER cosmiconfig treats package.json as a special case and will always load only specific keys from it
62
- * So we have to intercept and load them manually in config.ts
62
+ * Lets arbitrary JSON objects (like from package.json) become reasonably good
63
+ * mdat rule sets HOWEVER cosmiconfig treats package.json as a special case and
64
+ * will always load only specific keys from it So we have to intercept and load
65
+ * them manually in config.ts
63
66
  */
64
67
  function mdatJsonLoader(filePath, content) {
65
68
  const defaultJsonLoader = defaultLoaders[".json"];
@@ -179,6 +182,7 @@ const readmeMetadataTemplate = defineTemplate((context) => {
179
182
  issuesUrl: codemeta.issueTracker,
180
183
  license: helpers.toBasicLicense(helpers.firstOf(helpers.ensureArray(codemeta.license))),
181
184
  licenseFilePath: licenseFileData?.source,
185
+ licenseUrl: licenseFileData?.data.spdxUrl,
182
186
  name: codemeta.name,
183
187
  operatingSystem: codemeta.operatingSystem,
184
188
  peerDependencies,
@@ -227,12 +231,12 @@ var badges_default = { badges: { async content(options) {
227
231
  npm: z.array(z.string()).optional()
228
232
  }).optional().parse(options);
229
233
  const metadata = await getReadmeMetadata();
230
- const { ciActionFileName, license, name, repositoryUrl } = metadata;
234
+ const { ciActionFileName, license, licenseUrl, name, repositoryUrl } = metadata;
231
235
  const badges = [];
232
236
  if (validOptions?.npm === void 0) {
233
237
  if (metadata.isPublicNpmPackage) badges.push(`[![NPM Package ${name}](https://img.shields.io/npm/v/${name}.svg)](https://npmjs.com/package/${name})`);
234
238
  } else for (const name of validOptions.npm) badges.push(`[![NPM Package ${name}](https://img.shields.io/npm/v/${name}.svg)](https://npmjs.com/package/${name})`);
235
- if (license !== void 0) badges.push(`[![License: ${license}](https://img.shields.io/badge/License-${license.replaceAll("-", "--")}-yellow.svg)](https://opensource.org/licenses/${license})`);
239
+ if (license !== void 0 && licenseUrl !== void 0) badges.push(`[![License: ${license}](https://img.shields.io/badge/License-${license.replaceAll("-", "--")}-yellow.svg)](${licenseUrl})`);
236
240
  if (ciActionFileName !== void 0 && repositoryUrl !== void 0) badges.push(`[![CI](${repositoryUrl}/actions/workflows/${ciActionFileName}/badge.svg)](${repositoryUrl}/actions/workflows/${ciActionFileName})`);
237
241
  if (validOptions?.custom !== void 0) for (const [name, { image, link }] of Object.entries(validOptions.custom)) badges.push(`[![${name}](${image})](${link})`);
238
242
  return badges.join("\n");
@@ -484,6 +488,7 @@ const brotliCompressAsync = promisify(brotliCompress);
484
488
  const gzipCompressAsync = promisify(gzip);
485
489
  /**
486
490
  * Creates a SizeInfo object with formatted values
491
+ *
487
492
  * @param bytes - Size in bytes
488
493
  * @param originalSize - Original file size for percentage calculation
489
494
  */
@@ -498,9 +503,11 @@ function createSizeInfo(bytes, originalSize) {
498
503
  }
499
504
  /**
500
505
  * Analyzes a file's size and its compressed sizes using Brotli and Gzip
506
+ *
501
507
  * @param filePath - Path to the file to analyze
508
+ *
502
509
  * @returns Promise containing detailed size report
503
- * @throws {Error} if file cannot be read or compressed
510
+ * @throws {Error} If file cannot be read or compressed
504
511
  */
505
512
  async function createSizeReport(filePath) {
506
513
  try {
@@ -729,8 +736,8 @@ function defineConfig(config) {
729
736
  let cachedPrettier;
730
737
  const configCache = /* @__PURE__ */ new Map();
731
738
  /**
732
- * Format a markdown string with Prettier, using config discovered from the file path.
733
- * Requires `prettier` to be installed as a peer dependency.
739
+ * Format a markdown string with Prettier, using config discovered from the file
740
+ * path. Requires `prettier` to be installed as a peer dependency.
734
741
  */
735
742
  async function formatWithPrettier(content, filePath) {
736
743
  if (cachedPrettier === void 0) try {
@@ -937,6 +944,7 @@ var templates_default = {
937
944
  //#region src/lib/readme/create.ts
938
945
  /**
939
946
  * Creates a new readme file interactively.
947
+ *
940
948
  * @returns Path to the created readme file.
941
949
  */
942
950
  async function createReadmeInteractive() {
@@ -977,6 +985,7 @@ async function createReadmeInteractive() {
977
985
  }
978
986
  /**
979
987
  * Creates a new readme file with the given options.
988
+ *
980
989
  * @returns Path to the created readme file.
981
990
  */
982
991
  async function createReadme(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdat",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "CLI tool and TypeScript library implementing the Markdown Autophagic Template (MDAT) system. MDAT lets you use comments as dynamic content templates in Markdown files, making it easy to generate and update readme boilerplate.",
5
5
  "keywords": [
6
6
  "mdat",
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "devDependencies": {
71
71
  "@arethetypeswrong/core": "^0.18.2",
72
- "@kitschpatrol/shared-config": "^7.4.1",
72
+ "@kitschpatrol/shared-config": "^7.5.2",
73
73
  "@types/mdast": "^4.0.4",
74
74
  "@types/node": "~22.17.2",
75
75
  "@types/unist": "^3.0.3",
@@ -77,14 +77,14 @@
77
77
  "@vitest/coverage-v8": "4.1.2",
78
78
  "bumpp": "^11.0.1",
79
79
  "execa": "^9.6.1",
80
- "mdat-plugin-cli-help": "^2.1.2",
80
+ "mdat-plugin-cli-help": "^3.0.0",
81
81
  "mdat-plugin-example": "^2.0.0",
82
- "mdat-plugin-tldraw": "^2.0.1",
82
+ "mdat-plugin-tldraw": "^2.0.2",
83
83
  "nanoid": "^5.1.9",
84
84
  "prettier": "^3.8.3",
85
85
  "publint": "^0.3.18",
86
86
  "shx": "^0.4.0",
87
- "tsdown": "^0.21.9",
87
+ "tsdown": "^0.21.10",
88
88
  "typescript": "~6.0.3",
89
89
  "unplugin-raw": "^0.7.0",
90
90
  "vitest": "^4.1.5"
package/readme.md CHANGED
@@ -824,10 +824,14 @@ This project was split from a monorepo containing both `mdat` and `remark-mdat`
824
824
 
825
825
  ## Contributing
826
826
 
827
- [Issues](https://github.com/kitschpatrol/mdat/issues) and pull requests are welcome.
827
+ [Issues](https://github.com/kitschpatrol/mdat/issues) are welcome and appreciated.
828
+
829
+ Please open an issue to discuss changes before submitting a pull request. Unsolicited PRs (especially AI-generated ones) are unlikely to be merged.
830
+
831
+ 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.
828
832
 
829
833
  ## License
830
834
 
831
- [MIT](license.txt) © Eric Mika
835
+ [MIT](license.txt) © [Eric Mika](https://ericmika.com)
832
836
 
833
837
  <!-- /footer -->