@stephansama/auto-readme 0.2.10 → 0.2.12

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.
@@ -0,0 +1,189 @@
1
+ ---
2
+ name: auto-readme
3
+ description: >
4
+ Auto-generate and update tables and lists in README files using HTML comment
5
+ markers. Supports WORKSPACE (monorepo package tables), ACTION (GitHub Action
6
+ inputs from action.yml), PKG (package.json dependency tables), ZOD (zod schema
7
+ reference tables), USAGE actions. Run via CLI or as a pre-commit hook with
8
+ --changes to process only modified READMEs.
9
+ type: core
10
+ library: "@stephansama/auto-readme"
11
+ library_version: "1.0.0"
12
+ sources:
13
+ - stephansama/packages:core/auto-readme/src/comment.ts
14
+ - stephansama/packages:core/auto-readme/src/data.ts
15
+ - stephansama/packages:core/auto-readme/src/plugin.ts
16
+ - stephansama/packages:core/auto-readme/src/schema.ts
17
+ - stephansama/packages:core/auto-readme/README.md
18
+ ---
19
+
20
+ # auto-readme
21
+
22
+ Keeps README files up to date by replacing content between HTML comment markers. Run manually, in CI, or as a pre-commit hook.
23
+
24
+ ## Comment syntax
25
+
26
+ ```md
27
+ <!-- ACTION_TYPE [options] start -->
28
+ <!-- ACTION_TYPE end -->
29
+ ```
30
+
31
+ Content between markers is replaced on every run. Markers must be paired — every `start` needs a matching `end`.
32
+
33
+ ## Setup
34
+
35
+ ```sh
36
+ pnpx @stephansama/auto-readme
37
+ ```
38
+
39
+ Add configuration to `package.json`:
40
+
41
+ ```json
42
+ {
43
+ "auto-readme": {
44
+ "disableEmojis": false,
45
+ "onlyShowPublicPackages": true
46
+ }
47
+ }
48
+ ```
49
+
50
+ Or use a standalone config file (`.autoreadmerc.json`, `.config/autoreadmerc.ts`, `autoreadme.config.ts`, etc.).
51
+
52
+ ## Core Patterns
53
+
54
+ ### Monorepo workspace table
55
+
56
+ ```md
57
+ <!-- WORKSPACE start -->
58
+ <!-- WORKSPACE end -->
59
+ ```
60
+
61
+ Generates a table of all packages in the workspace with name, version badge, download badge, and description. Reads from the pnpm/npm workspace config.
62
+
63
+ ### GitHub Action inputs table
64
+
65
+ ```md
66
+ <!-- ACTION start -->
67
+ <!-- ACTION end -->
68
+ ```
69
+
70
+ Place this comment in a README inside a directory that contains `action.yml` or `action.yaml`. Generates a table of action inputs with name, required, default, and description columns.
71
+
72
+ ### Package.json dependency table
73
+
74
+ ```md
75
+ <!-- PKG start -->
76
+ <!-- PKG end -->
77
+ ```
78
+
79
+ Generates a table of dependencies and devDependencies from the nearest `package.json`. Pass `path=` to point to a different package.json:
80
+
81
+ ```md
82
+ <!-- PKG path="../other-package" start -->
83
+ <!-- PKG end -->
84
+ ```
85
+
86
+ ### Zod schema reference table
87
+
88
+ ```md
89
+ <!-- ZOD path="./src/schema.js" start -->
90
+ <!-- ZOD end -->
91
+ ```
92
+
93
+ Generates a markdown reference table from the default export of the given file using `zod2md`. The `path=` parameter is required and must point to a file with a zod schema as its default export.
94
+
95
+ ### Pre-commit hook (changed files only)
96
+
97
+ ```sh
98
+ # .husky/pre-commit
99
+ auto-readme --changes
100
+ ```
101
+
102
+ `--changes` (`-g`) only processes README files that are modified in the current git changeset. Use in pre-commit hooks to avoid re-processing the entire repo on every commit.
103
+
104
+ ## Common Mistakes
105
+
106
+ ### HIGH ZOD action used with LIST format
107
+
108
+ Wrong:
109
+
110
+ ```md
111
+ <!-- ZOD-LIST path="./src/schema.js" start -->
112
+ <!-- ZOD-LIST end -->
113
+ ```
114
+
115
+ Correct:
116
+
117
+ ```md
118
+ <!-- ZOD path="./src/schema.js" start -->
119
+ <!-- ZOD end -->
120
+ ```
121
+
122
+ The ZOD action only supports TABLE format. Specifying LIST (e.g. `ZOD-LIST`) throws `"cannot display zod in list format"` at pipeline execution time.
123
+
124
+ Source: `core/auto-readme/src/data.ts`
125
+
126
+ ### HIGH ZOD comment missing path= parameter
127
+
128
+ Wrong:
129
+
130
+ ```md
131
+ <!-- ZOD start -->
132
+ <!-- ZOD end -->
133
+ ```
134
+
135
+ Correct:
136
+
137
+ ```md
138
+ <!-- ZOD path="./src/schema.js" start -->
139
+ <!-- ZOD end -->
140
+ ```
141
+
142
+ The ZOD data loader requires `path=` to locate the schema file. Without it, auto-readme throws `"no path found for zod table at markdown file <file>"`.
143
+
144
+ Source: `core/auto-readme/src/data.ts`
145
+
146
+ ### HIGH ACTION comment without action.yml in the same directory
147
+
148
+ Wrong:
149
+
150
+ ```md
151
+ <!-- In docs/README.md, but no action.yml in docs/ -->
152
+ <!-- ACTION start -->
153
+ <!-- ACTION end -->
154
+ ```
155
+
156
+ Correct:
157
+
158
+ ```md
159
+ <!-- In the same directory as action.yml -->
160
+ <!-- ACTION start -->
161
+ <!-- ACTION end -->
162
+ ```
163
+
164
+ The ACTION data loader looks for `action.yml` or `action.yaml` in the same directory as the README file. Place the ACTION comment in the README co-located with the action definition, or use PKG for dependency tables in other directories.
165
+
166
+ Source: `core/auto-readme/src/data.ts:loadActionYaml`
167
+
168
+ ### MEDIUM Unclosed or mismatched comment markers
169
+
170
+ Wrong:
171
+
172
+ ```md
173
+ <!-- WORKSPACE start -->
174
+
175
+ Some content
176
+
177
+ <!-- WORKSPACE start --> ← second start, no end
178
+ ```
179
+
180
+ Correct:
181
+
182
+ ```md
183
+ <!-- WORKSPACE start -->
184
+ <!-- WORKSPACE end -->
185
+ ```
186
+
187
+ The `remark-zone` processor requires matched `start`/`end` pairs. Unmatched or duplicated markers cause the zone transform to silently skip or corrupt the section without an error.
188
+
189
+ Source: `core/auto-readme/src/plugin.ts`
package/cli.mjs DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const cli = await import("./dist/index.mjs");
4
- await cli.run();
package/config/schema.cjs DELETED
@@ -1,127 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
- //#endregion
24
- let zod = require("zod");
25
- zod = __toESM(zod, 1);
26
- //#region src/schema.ts
27
- const actionsSchema = zod.enum([
28
- "ACTION",
29
- "PKG",
30
- "USAGE",
31
- "WORKSPACE",
32
- "ZOD"
33
- ]).meta({ description: "Comment action options" });
34
- const formatsSchema = zod.enum(["LIST", "TABLE"]).default("TABLE");
35
- const languageSchema = zod.enum(["JS", "RS"]).default("JS");
36
- const headingsSchema = zod.enum([
37
- "default",
38
- "description",
39
- "devDependency",
40
- "downloads",
41
- "name",
42
- "private",
43
- "required",
44
- "version"
45
- ]).meta({ description: "Table heading options" });
46
- const tableHeadingsSchema = zod.record(actionsSchema, headingsSchema.array().optional()).default({
47
- ACTION: [
48
- "name",
49
- "required",
50
- "default",
51
- "description"
52
- ],
53
- PKG: [
54
- "name",
55
- "version",
56
- "devDependency"
57
- ],
58
- USAGE: [],
59
- WORKSPACE: [
60
- "name",
61
- "version",
62
- "downloads",
63
- "description"
64
- ],
65
- ZOD: []
66
- }).meta({ description: "Table heading action configuration" });
67
- const templatesSchema = zod.object({
68
- downloadImage: zod.string().trim().default("https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F"),
69
- emojis: zod.record(headingsSchema, zod.string().trim()).default({
70
- default: "⚙️",
71
- description: "📝",
72
- devDependency: "💻",
73
- downloads: "📥",
74
- name: "🏷️",
75
- private: "🔒",
76
- required: "",
77
- version: ""
78
- }).meta({ description: "Table heading emojis used when enabled" }),
79
- registryUrl: zod.string().trim().default("https://www.npmjs.com/package/{{name}}"),
80
- versionImage: zod.string().trim().default("https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F")
81
- });
82
- const defaultTemplates = templatesSchema.parse({});
83
- const defaultTableHeadings = tableHeadingsSchema.parse(void 0);
84
- const configSchema = zod.object({
85
- affectedRegexes: zod.array(zod.string().trim()),
86
- collapseHeadings: zod.array(zod.string().trim()),
87
- defaultLanguage: languageSchema.meta({
88
- alias: "l",
89
- description: "Default language to infer projects from"
90
- }),
91
- disableEmojis: zod.boolean().default(false).meta({
92
- alias: "e",
93
- description: "Whether or not to use emojis in markdown table headings"
94
- }),
95
- disableMarkdownHeadings: zod.boolean().default(false).meta({ description: "Whether or not to display markdown headings" }),
96
- enablePrettier: zod.boolean().default(true).meta({ description: "Whether or not to use prettier to format the files" }),
97
- enableToc: zod.boolean().default(false).meta({
98
- alias: "t",
99
- description: "generate table of contents for readmes"
100
- }),
101
- enableUsage: zod.boolean().default(false).meta({ description: "Whether or not to enable usage plugin" }),
102
- headings: tableHeadingsSchema.optional().default(defaultTableHeadings).describe("List of headings for different table outputs"),
103
- onlyReadmes: zod.boolean().default(true).meta({
104
- alias: "r",
105
- description: "Whether or not to only traverse readmes"
106
- }),
107
- onlyShowPublicPackages: zod.boolean().default(false).meta({
108
- alias: "p",
109
- description: "Only show public packages in workspaces"
110
- }),
111
- removeScope: zod.string().trim().default("").meta({ description: "Remove common workspace scope" }),
112
- templates: templatesSchema.optional().default(defaultTemplates).describe("Handlebars templates used to fuel list and table generation"),
113
- tocHeading: zod.string().trim().default("Table of contents").meta({ description: "Markdown heading used to generate table of contents" }),
114
- usageFile: zod.string().trim().default("").meta({ description: "Workspace level usage file" }),
115
- usageHeading: zod.string().trim().default("Usage").meta({ description: "Markdown heading used to generate usage example" }),
116
- verbose: zod.boolean().default(false).meta({
117
- alias: "v",
118
- description: "whether or not to display verbose logging"
119
- })
120
- }).optional();
121
- //#endregion
122
- exports.actionsSchema = actionsSchema;
123
- exports.configSchema = configSchema;
124
- exports.defaultTableHeadings = defaultTableHeadings;
125
- exports.defaultTemplates = defaultTemplates;
126
- exports.formatsSchema = formatsSchema;
127
- exports.languageSchema = languageSchema;
@@ -1,130 +0,0 @@
1
- import * as z from "zod";
2
-
3
- //#region src/schema.d.ts
4
- declare const actionsSchema: z.ZodEnum<{
5
- ACTION: "ACTION";
6
- PKG: "PKG";
7
- USAGE: "USAGE";
8
- WORKSPACE: "WORKSPACE";
9
- ZOD: "ZOD";
10
- }>;
11
- declare const formatsSchema: z.ZodDefault<z.ZodEnum<{
12
- LIST: "LIST";
13
- TABLE: "TABLE";
14
- }>>;
15
- declare const languageSchema: z.ZodDefault<z.ZodEnum<{
16
- JS: "JS";
17
- RS: "RS";
18
- }>>;
19
- declare const defaultTemplates: {
20
- downloadImage: string;
21
- emojis: Record<"description" | "default" | "devDependency" | "downloads" | "name" | "private" | "required" | "version", string>;
22
- registryUrl: string;
23
- versionImage: string;
24
- };
25
- declare const defaultTableHeadings: Record<"ACTION" | "PKG" | "USAGE" | "WORKSPACE" | "ZOD", ("description" | "default" | "devDependency" | "downloads" | "name" | "private" | "required" | "version")[] | undefined>;
26
- declare const _configSchema: z.ZodObject<{
27
- affectedRegexes: z.ZodArray<z.ZodString>;
28
- collapseHeadings: z.ZodArray<z.ZodString>;
29
- defaultLanguage: z.ZodDefault<z.ZodEnum<{
30
- JS: "JS";
31
- RS: "RS";
32
- }>>;
33
- disableEmojis: z.ZodDefault<z.ZodBoolean>;
34
- disableMarkdownHeadings: z.ZodDefault<z.ZodBoolean>;
35
- enablePrettier: z.ZodDefault<z.ZodBoolean>;
36
- enableToc: z.ZodDefault<z.ZodBoolean>;
37
- enableUsage: z.ZodDefault<z.ZodBoolean>;
38
- headings: z.ZodDefault<z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodEnum<{
39
- ACTION: "ACTION";
40
- PKG: "PKG";
41
- USAGE: "USAGE";
42
- WORKSPACE: "WORKSPACE";
43
- ZOD: "ZOD";
44
- }>, z.ZodOptional<z.ZodArray<z.ZodEnum<{
45
- description: "description";
46
- default: "default";
47
- devDependency: "devDependency";
48
- downloads: "downloads";
49
- name: "name";
50
- private: "private";
51
- required: "required";
52
- version: "version";
53
- }>>>>>>>;
54
- onlyReadmes: z.ZodDefault<z.ZodBoolean>;
55
- onlyShowPublicPackages: z.ZodDefault<z.ZodBoolean>;
56
- removeScope: z.ZodDefault<z.ZodString>;
57
- templates: z.ZodDefault<z.ZodOptional<z.ZodObject<{
58
- downloadImage: z.ZodDefault<z.ZodString>;
59
- emojis: z.ZodDefault<z.ZodRecord<z.ZodEnum<{
60
- description: "description";
61
- default: "default";
62
- devDependency: "devDependency";
63
- downloads: "downloads";
64
- name: "name";
65
- private: "private";
66
- required: "required";
67
- version: "version";
68
- }>, z.ZodString>>;
69
- registryUrl: z.ZodDefault<z.ZodString>;
70
- versionImage: z.ZodDefault<z.ZodString>;
71
- }, z.core.$strip>>>;
72
- tocHeading: z.ZodDefault<z.ZodString>;
73
- usageFile: z.ZodDefault<z.ZodString>;
74
- usageHeading: z.ZodDefault<z.ZodString>;
75
- verbose: z.ZodDefault<z.ZodBoolean>;
76
- }, z.core.$strip>;
77
- declare const configSchema: z.ZodOptional<z.ZodObject<{
78
- affectedRegexes: z.ZodArray<z.ZodString>;
79
- collapseHeadings: z.ZodArray<z.ZodString>;
80
- defaultLanguage: z.ZodDefault<z.ZodEnum<{
81
- JS: "JS";
82
- RS: "RS";
83
- }>>;
84
- disableEmojis: z.ZodDefault<z.ZodBoolean>;
85
- disableMarkdownHeadings: z.ZodDefault<z.ZodBoolean>;
86
- enablePrettier: z.ZodDefault<z.ZodBoolean>;
87
- enableToc: z.ZodDefault<z.ZodBoolean>;
88
- enableUsage: z.ZodDefault<z.ZodBoolean>;
89
- headings: z.ZodDefault<z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodEnum<{
90
- ACTION: "ACTION";
91
- PKG: "PKG";
92
- USAGE: "USAGE";
93
- WORKSPACE: "WORKSPACE";
94
- ZOD: "ZOD";
95
- }>, z.ZodOptional<z.ZodArray<z.ZodEnum<{
96
- description: "description";
97
- default: "default";
98
- devDependency: "devDependency";
99
- downloads: "downloads";
100
- name: "name";
101
- private: "private";
102
- required: "required";
103
- version: "version";
104
- }>>>>>>>;
105
- onlyReadmes: z.ZodDefault<z.ZodBoolean>;
106
- onlyShowPublicPackages: z.ZodDefault<z.ZodBoolean>;
107
- removeScope: z.ZodDefault<z.ZodString>;
108
- templates: z.ZodDefault<z.ZodOptional<z.ZodObject<{
109
- downloadImage: z.ZodDefault<z.ZodString>;
110
- emojis: z.ZodDefault<z.ZodRecord<z.ZodEnum<{
111
- description: "description";
112
- default: "default";
113
- devDependency: "devDependency";
114
- downloads: "downloads";
115
- name: "name";
116
- private: "private";
117
- required: "required";
118
- version: "version";
119
- }>, z.ZodString>>;
120
- registryUrl: z.ZodDefault<z.ZodString>;
121
- versionImage: z.ZodDefault<z.ZodString>;
122
- }, z.core.$strip>>>;
123
- tocHeading: z.ZodDefault<z.ZodString>;
124
- usageFile: z.ZodDefault<z.ZodString>;
125
- usageHeading: z.ZodDefault<z.ZodString>;
126
- verbose: z.ZodDefault<z.ZodBoolean>;
127
- }, z.core.$strip>>;
128
- type Config = Partial<z.infer<typeof _configSchema>>;
129
- //#endregion
130
- export { Config, actionsSchema, configSchema, defaultTableHeadings, defaultTemplates, formatsSchema, languageSchema };
package/dist/index.d.cts DELETED
@@ -1,4 +0,0 @@
1
- //#region src/index.d.ts
2
- declare function run(): Promise<void>;
3
- //#endregion
4
- export { run };
File without changes
File without changes