mdat 0.8.1 → 0.10.0

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.
@@ -1,11 +1,12 @@
1
1
  import { type Root } from 'mdast';
2
2
  import { VFile } from 'vfile';
3
3
  import { type ConfigLoaded, type ConfigToLoad, type loadConfig, type RulesToLoad } from './config';
4
+ import { type AmbientRemarkConfig } from './utilities';
4
5
  type Loader = typeof loadConfig;
5
6
  type ProcessorGetter = typeof getCleanProcessor | typeof getExpandProcessor;
6
7
  export declare function processFiles(files: string | string[], loader: Loader, processorGetter: ProcessorGetter, name?: string, output?: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
7
8
  export declare function processString(markdown: string, loader: Loader, processorGetter: ProcessorGetter, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile>;
8
- export declare function getExpandProcessor(options: ConfigLoaded): import("unified").Processor<Root, undefined, undefined, Root, string>;
9
- export declare function getCleanProcessor(options: ConfigLoaded): import("unified").Processor<Root, undefined, undefined, Root, string>;
10
- export declare function getCheckProcessor(options: ConfigLoaded): import("unified").Processor<Root, undefined, undefined, Root, string>;
9
+ export declare function getExpandProcessor(options: ConfigLoaded, ambientRemarkConfig: AmbientRemarkConfig): import("unified").Processor<Root, undefined, undefined, Root, string>;
10
+ export declare function getCleanProcessor(options: ConfigLoaded, ambientRemarkConfig: AmbientRemarkConfig): import("unified").Processor<Root, undefined, undefined, Root, string>;
11
+ export declare function getCheckProcessor(options: ConfigLoaded, ambientRemarkConfig: AmbientRemarkConfig): import("unified").Processor<Root, undefined, undefined, Root, string>;
11
12
  export {};
@@ -33,8 +33,8 @@ export type ProgramInfo = {
33
33
  subcommandName?: string;
34
34
  };
35
35
  declare const _default: {
36
- meow: typeof helpStringToObjectMeow;
37
36
  yargs: typeof helpStringToObjectYargs;
37
+ meow: typeof helpStringToObjectMeow;
38
38
  };
39
39
  export default _default;
40
40
  export declare function getCommandParts(wholeCommand: string | undefined): {
@@ -1,3 +1,5 @@
1
+ import { type ConfigResult as AmbientRemarkConfig } from 'unified-engine';
2
+ export { type ConfigResult as AmbientRemarkConfig } from 'unified-engine';
1
3
  export declare function getInputOutputPaths(inputs: string[], output: string | undefined, name: string | undefined, extension: string | undefined): Array<{
2
4
  input: string;
3
5
  name: string;
@@ -11,3 +13,4 @@ export declare function getInputOutputPath(input: string, output: string | undef
11
13
  export declare function expandPath(file: string): string;
12
14
  export declare function findPackage(): Promise<string | undefined>;
13
15
  export declare function ensureArray<T>(value: T | T[] | undefined): T[];
16
+ export declare function loadAmbientRemarkConfig(): Promise<AmbientRemarkConfig>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdat",
3
- "version": "0.8.1",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "CLI tool and 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.",
6
6
  "repository": "github:kitschpatrol/mdat",
@@ -39,46 +39,48 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "@clack/prompts": "^0.7.0",
42
- "@kitschpatrol/tldraw-cli": "^4.6.22",
42
+ "@kitschpatrol/tldraw-cli": "^4.6.28",
43
43
  "@types/mdast": "^4.0.4",
44
44
  "@types/node": "18.19.0",
45
45
  "@types/unist": "^3.0.3",
46
46
  "@types/yargs": "^17.0.33",
47
47
  "cosmiconfig": "^9.0.0",
48
- "cosmiconfig-typescript-loader": "^6.0.0",
49
- "execa": "^9.5.1",
48
+ "cosmiconfig-typescript-loader": "^6.1.0",
49
+ "execa": "^9.5.2",
50
50
  "globby": "^14.0.2",
51
51
  "read-pkg": "^9.0.1",
52
+ "remark-mdat": "^0.7.5",
53
+ "type-fest": "^4.33.0",
54
+ "unified-engine": "^11.2.2",
55
+ "vfile": "^6.0.3",
52
56
  "which": "^5.0.0"
53
57
  },
54
58
  "devDependencies": {
55
59
  "@kitschpatrol/shared-config": "^4.7.12",
56
60
  "@types/which": "^3.0.4",
57
- "bumpp": "^9.8.1",
58
- "chalk": "^5.3.0",
61
+ "bumpp": "^10.0.1",
62
+ "chalk": "^5.4.1",
59
63
  "chevrotain": "^11.0.3",
60
64
  "find-up": "^7.0.0",
61
65
  "is-executable": "^2.0.1",
66
+ "mdast-util-to-markdown": "^2.1.2",
62
67
  "mdast-util-toc": "^7.1.0",
63
- "nanoid": "^5.0.8",
68
+ "nanoid": "^5.0.9",
64
69
  "package-up": "^5.0.0",
65
70
  "path-type": "^6.0.0",
66
71
  "pkg-dir": "^8.0.0",
67
72
  "plur": "^5.1.0",
68
73
  "pretty-bytes": "^6.1.1",
69
- "pretty-ms": "^9.1.0",
74
+ "pretty-ms": "^9.2.0",
70
75
  "remark": "^15.0.1",
71
76
  "remark-gfm": "^4.0.0",
72
- "remark-mdat": "^0.7.4",
73
77
  "to-vfile": "^8.0.0",
74
- "tsup": "^8.3.5",
75
- "type-fest": "^4.26.1",
76
- "typescript": "^5.6.3",
78
+ "tsup": "^8.3.6",
79
+ "typescript": "^5.7.3",
77
80
  "untildify": "^5.0.0",
78
- "vfile": "^6.0.3",
79
- "vitest": "^2.1.4",
81
+ "vitest": "^2.1.8",
80
82
  "yargs": "^17.7.2",
81
- "zod": "^3.23.8"
83
+ "zod": "^3.24.1"
82
84
  },
83
85
  "publishConfig": {
84
86
  "access": "public"
package/readme.md CHANGED
@@ -216,7 +216,8 @@ As [noted below](#similar-projects), there are several similar projects out ther
216
216
 
217
217
  ## Usage
218
218
 
219
- > \[!WARNING]\
219
+ > [!WARNING]
220
+ >
220
221
  > **The MDAT CLI tool directly manipulates the contents of readme files, in close (and perhaps dangerous) proximity to your painstakingly crafted words.**
221
222
  >
222
223
  > Please make sure any text you care about is committed before running `mdat`, and never directly modify content inside of the comment expansion blocks.
@@ -601,6 +602,32 @@ TypeScript or JavaScript with JSDoc annotations are recommended for the most fle
601
602
 
602
603
  `mdat` also allows arbitrary JSON files to be loaded as rule sets, flattening them so any value may be accessed by using a dot-notation key path as a comment keyword.
603
604
 
605
+ #### Configuration in package.json
606
+
607
+ "Shared" configurations can be specified in `package.json` as a special case by passing a string that can be resolved to a module which default-exports an `mdat` `Config` type object. For example, in your `package.json`:
608
+
609
+ ```json
610
+ {
611
+ "mdat": "@kitschpatrol/mdat-config"
612
+ }
613
+ ```
614
+
615
+ Though a string is not technically a valid `mdat` `Config` object, it is detected as a special case which loads the `Config` object exported from the `@kitschpatrol/mdat-config` module.
616
+
617
+ Rules may also be defined directly in `package.json`, but of course only static replacements are supported. For programmatic rules, you will need to create a JavaScript or TypeScript configuration file.
618
+
619
+ For example, the following configuration in your `package.json` will expand `<!-- what -->` comments:
620
+
621
+ ```json
622
+ {
623
+ "mdat": {
624
+ "rules": {
625
+ "what": "hath god wrought"
626
+ }
627
+ }
628
+ }
629
+ ```
630
+
604
631
  #### Configuration file format
605
632
 
606
633
  The `mdat` configuration file is a record object allowing you to customize aspects of the comment expansion process, and also optionally define expansion rules as well under the `rules` key:
@@ -619,7 +646,11 @@ type Config = {
619
646
 
620
647
  A valid configuration file default-exports an object conforming to the above type.
621
648
 
622
- The configuration file may be located in any location supported by [cosmicconfig](https://github.com/cosmiconfig/cosmiconfig?tab=readme-ov-file#searchplaces). I use an `.mdatrc.ts` file in the root of my projects.
649
+ The configuration file may be located in any location supported by [cosmicconfig](https://github.com/cosmiconfig/cosmiconfig?tab=readme-ov-file#searchplaces). I use an `mdat.config.ts` file in the root of my projects.
650
+
651
+ > [!NOTE]
652
+ >
653
+ > The `mdat` commands _also_ search for and merge any ambient Remark `.remarkrc` configuration files you might have in your project. This is unrelated to the `mdat` rule configuration files, but it _can_ have an affect how Markdown is validated and rendered by `mdat`.
623
654
 
624
655
  #### Rule file format
625
656
 
@@ -714,8 +745,8 @@ See the [Examples section](https://github.com/kitschpatrol/remark-mdat#examples)
714
745
 
715
746
  | File | Original | Gzip | Brotli |
716
747
  | ------------ | -------- | ------- | ------ |
717
- | package.json | 2.5 kB | 1.1 kB | 978 B |
718
- | readme.md | 56.1 kB | 10.9 kB | 8.7 kB |
748
+ | package.json | 2.6 kB | 1.2 kB | 1 kB |
749
+ | readme.md | 57.4 kB | 11.4 kB | 9.1 kB |
719
750
 
720
751
  <!-- /size-table -->
721
752
 
@@ -830,6 +861,10 @@ Recommended workflow integration approach:
830
861
 
831
862
  - Invoke via hooks / GitHub actions?
832
863
 
864
+ Architectural improvements:
865
+
866
+ - Use [unified-engine](https://github.com/unifiedjs/unified-engine) to handle file loading and transformation.
867
+
833
868
  ## Maintainers
834
869
 
835
870
  [@kitschpatrol](https://github.com/kitschpatrol)