mdat 1.3.4 → 1.4.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.
Files changed (37) hide show
  1. package/dist/.DS_Store +0 -0
  2. package/dist/bin/cli.js +1399 -0
  3. package/dist/bin/typescript-DT_UEyMt.js +1 -0
  4. package/dist/bin/typescript-HSmT12zI.js +449 -0
  5. package/dist/lib/index.d.ts +155 -0
  6. package/dist/lib/index.js +842 -0
  7. package/package.json +49 -36
  8. package/readme.md +17 -14
  9. package/bin/cli.js +0 -29419
  10. package/dist/api.d.ts +0 -31
  11. package/dist/config.d.ts +0 -74
  12. package/dist/index.d.ts +0 -5
  13. package/dist/index.js +0 -24796
  14. package/dist/mdat-json-loader.d.ts +0 -7
  15. package/dist/processors.d.ts +0 -12
  16. package/dist/readme/api.d.ts +0 -46
  17. package/dist/readme/config.d.ts +0 -14
  18. package/dist/readme/init.d.ts +0 -18
  19. package/dist/readme/rules/badges.d.ts +0 -7
  20. package/dist/readme/rules/banner.d.ts +0 -7
  21. package/dist/readme/rules/code.d.ts +0 -6
  22. package/dist/readme/rules/contributing.d.ts +0 -7
  23. package/dist/readme/rules/description.d.ts +0 -10
  24. package/dist/readme/rules/footer.d.ts +0 -10
  25. package/dist/readme/rules/header.d.ts +0 -11
  26. package/dist/readme/rules/index.d.ts +0 -66
  27. package/dist/readme/rules/license.d.ts +0 -7
  28. package/dist/readme/rules/short-description.d.ts +0 -12
  29. package/dist/readme/rules/size-table.d.ts +0 -6
  30. package/dist/readme/rules/size.d.ts +0 -6
  31. package/dist/readme/rules/table-of-contents.d.ts +0 -9
  32. package/dist/readme/rules/title.d.ts +0 -8
  33. package/dist/readme/rules/toc.d.ts +0 -11
  34. package/dist/readme/rules/utilities/size/size-report.d.ts +0 -19
  35. package/dist/readme/templates/index.d.ts +0 -27
  36. package/dist/readme/utilities.d.ts +0 -15
  37. package/dist/utilities.d.ts +0 -10
@@ -0,0 +1,155 @@
1
+ import { Options, Rules } from "remark-mdat";
2
+ import { VFile } from "vfile";
3
+ import { Simplify } from "type-fest";
4
+
5
+ //#region src/lib/config.d.ts
6
+ type Config = Simplify<Options & {
7
+ assetsPath?: string;
8
+ packageFile?: string;
9
+ }>;
10
+ type ConfigLoaded = {
11
+ addMetaComment: boolean | string;
12
+ assetsPath: string;
13
+ closingPrefix: string;
14
+ keywordPrefix: string;
15
+ metaCommentIdentifier: string;
16
+ packageFile: string | undefined;
17
+ rules: Rules;
18
+ };
19
+ /**
20
+ * Generously accept either string paths to .ts, .js, or .json files with
21
+ * `Config` type default exports. Takes a single value, or an array of values which
22
+ * will be merged right to left.
23
+ */
24
+ type ConfigToLoad = Array<Config | string> | Config | string;
25
+ /**
26
+ * Generously accept either string paths to .ts, .js, or .json files with
27
+ * `Rules` type default exports.
28
+ */
29
+ type RulesToLoad = Array<Rules | string> | Rules | string;
30
+ /**
31
+ * Load and validate mdat configuration / rule sets
32
+ * Uses cosmiconfig to search in the usual places.
33
+ * Merge precedence: Base Defaults < Readme Defaults < Searched Config < Additional Config Paths
34
+ *
35
+ * Generic to accommodate additional Config options, so set T to your custom config type if needed. You must provide a matching configExtensionSchema as well.
36
+ */
37
+ declare function loadConfig(options?: {
38
+ /**
39
+ * Additional Config objects to merge.
40
+ *
41
+ * Strings are treated as paths to `ts`, `js`, or `json` files with `Config` type default exports. These will be dynamically loaded by Cosmiconfig.
42
+ * Accepts an individual item, or an array. Objects in the array will be merged right to left.
43
+ *
44
+ */
45
+ additionalConfig?: ConfigToLoad;
46
+ /**
47
+ * Additional Rules objects to merge.
48
+ *
49
+ * Strings are treated as paths to `ts`, `js`, or `json` files with `Rules` type default exports. These will be dynamically loaded by Cosmiconfig.
50
+ * Accepts an individual item, or an array. Objects in the array will be merged right to left, and take precedence over any rules in previously loaded Config objects as well.
51
+ */
52
+ additionalRules?: RulesToLoad;
53
+ /**
54
+ * Readme-specific defaults that have higher priority than base defaults but lower than searched config.
55
+ * Used internally by loadConfigReadme.
56
+ */
57
+ readmeDefaults?: Config; /** Search for config in specific directories, mainly useful for testing. Cosmiconfig default search paths used if unset. */
58
+ searchFrom?: string;
59
+ }): Promise<ConfigLoaded>;
60
+ /**
61
+ * Convenience function for merging configs
62
+ * Performs a deep merge, with the rightmost object taking precedence
63
+ */
64
+ declare function mergeConfigs(a: Config, b: Config): Config;
65
+ //#endregion
66
+ //#region src/lib/api.d.ts
67
+ /**
68
+ * Expand MDAT comments in one or more Markdown files
69
+ * Writing is the responsibility of the caller (e.g. via `await write(result)`)
70
+ * @returns an array of VFiles (Even if you only pass a single file path!)
71
+ */
72
+ declare function expandFiles(files: string | string[], name?: string, output?: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
73
+ /**
74
+ * Expand MDAT comments in a Markdown string
75
+ */
76
+ declare function expandString(markdown: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile>;
77
+ /**
78
+ * Check and validate MDAT comments in one or more Markdown files
79
+ * @returns an array of VFiles (Even if you only pass a single file path!)
80
+ */
81
+ declare function checkFiles(files: string | string[], name?: string, output?: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
82
+ /**
83
+ * Check and validate MDAT comments in a Markdown string
84
+ */
85
+ declare function checkString(markdown: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile>;
86
+ /**
87
+ * Collapse MDAT comments in one or more Markdown files
88
+ * Writing is the responsibility of the caller (e.g. via `await write(result)`)
89
+ * @returns an array of VFiles (Even if you only pass a single file path!)
90
+ */
91
+ declare function collapseFiles(files: string | string[], name?: string, output?: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
92
+ /**
93
+ * Collapse MDAT comments in a Markdown string
94
+ */
95
+ declare function collapseString(markdown: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile>;
96
+ //#endregion
97
+ //#region src/lib/readme/api.d.ts
98
+ /**
99
+ * Expands MDAT readme comments in the closest readme.md file
100
+ * Basically an alias to `expandReadmeFiles()` with certain arguments elided.
101
+ * @see `findReadme()` for more details on the search process.
102
+ */
103
+ declare function expandReadme(config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
104
+ /**
105
+ * Expands MDAT readme comments in one or more Markdown files
106
+ * Searches up for a readme.md file if none is provided.
107
+ * @see `findReadme()` for more details on the search process.
108
+ */
109
+ declare function expandReadmeFiles(files?: string | string[], name?: string, output?: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
110
+ /**
111
+ * Expands MDAT readme comments in a Markdown string
112
+ */
113
+ declare function expandReadmeString(markdown: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile>;
114
+ /**
115
+ * Checks and validates MDAT readme comments in the closest readme.md file
116
+ * Basically an alias to `checkReadmeFiles()` with certain arguments elided.
117
+ * @see `findReadme()` for more details on the search process.
118
+ */
119
+ declare function checkReadme(config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
120
+ /**
121
+ * Checks and validates MDAT readme comments in one or more Markdown files
122
+ * Searches up for a readme.md file if none is provided.
123
+ * @see `findReadme()` for more details on the search process.
124
+ */
125
+ declare function checkReadmeFiles(files?: string | string[], name?: string, output?: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
126
+ /**
127
+ * Checks and validates MDAT readme comments in a Markdown string
128
+ */
129
+ declare function checkReadmeString(markdown: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile>;
130
+ /**
131
+ * Collapses MDAT readme comments in the closest readme.md file
132
+ * Basically an alias to `collapseReadmeFiles()` with certain arguments elided.
133
+ * @see `findReadme()` for more details on the search process.
134
+ */
135
+ declare function collapseReadme(config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
136
+ /**
137
+ * Collapses MDAT readme comments in one or more Markdown files
138
+ * Searches up for a readme.md file if none is provided.
139
+ * @see `findReadme()` for more details on the search process.
140
+ */
141
+ declare function collapseReadmeFiles(files?: string | string[], name?: string, output?: string, config?: ConfigToLoad, rules?: RulesToLoad): Promise<VFile[]>;
142
+ //#endregion
143
+ //#region src/lib/readme/config.d.ts
144
+ type ReadmeConfigLoaded = Simplify<ConfigLoaded & {
145
+ packageFile: string;
146
+ }>;
147
+ type LoadConfigOptions = Parameters<typeof loadConfig>[0];
148
+ /**
149
+ * Convenience loader to always include the default readme config.
150
+ * The readme defaults should have lower priority than searched/user config,
151
+ * but higher priority than base mdat defaults.
152
+ */
153
+ declare function loadConfigReadme(options?: LoadConfigOptions): Promise<ReadmeConfigLoaded>;
154
+ //#endregion
155
+ export { type Config, type Rules, checkFiles, checkReadme, checkReadmeFiles, checkReadmeString, checkString, collapseFiles, collapseReadme, collapseReadmeFiles, collapseString, expandFiles, expandReadme, expandReadmeFiles, expandReadmeString, expandString, loadConfig, loadConfigReadme, mergeConfigs };