@stephansama/auto-readme 0.2.2 → 0.2.4

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/index.js CHANGED
@@ -5,7 +5,7 @@ import ora from "ora";
5
5
  import debug from "debug";
6
6
  import yargs from "yargs";
7
7
  import { hideBin } from "yargs/helpers";
8
- import z$1, { z } from "zod";
8
+ import * as z from "zod";
9
9
  import { commentMarker } from "mdast-comment-marker";
10
10
  import toml from "@iarna/toml";
11
11
  import { cosmiconfig, getDefaultSearchPlaces } from "cosmiconfig";
@@ -28,16 +28,16 @@ import Handlebars from "handlebars";
28
28
  import { markdownTable } from "markdown-table";
29
29
  import { zone } from "mdast-zone";
30
30
 
31
- //#region src/schema.js
31
+ //#region src/schema.ts
32
32
  const actionsSchema = z.enum([
33
33
  "ACTION",
34
34
  "PKG",
35
35
  "USAGE",
36
36
  "WORKSPACE",
37
37
  "ZOD"
38
- ]).describe("Comment action options");
39
- const formatsSchema = z.enum(["LIST", "TABLE"]).default("TABLE").optional();
40
- const languageSchema = z.enum(["JS", "RS"]).optional().default("JS");
38
+ ]).meta({ description: "Comment action options" });
39
+ const formatsSchema = z.enum(["LIST", "TABLE"]).default("TABLE");
40
+ const languageSchema = z.enum(["JS", "RS"]).default("JS");
41
41
  const headingsSchema = z.enum([
42
42
  "default",
43
43
  "description",
@@ -47,8 +47,8 @@ const headingsSchema = z.enum([
47
47
  "private",
48
48
  "required",
49
49
  "version"
50
- ]).describe("Table heading options");
51
- const tableHeadingsSchema = z.record(actionsSchema, headingsSchema.array().optional()).optional().describe("Table heading action configuration").default({
50
+ ]).meta({ description: "Table heading options" });
51
+ const tableHeadingsSchema = z.record(actionsSchema, headingsSchema.array().optional()).default({
52
52
  ACTION: [
53
53
  "name",
54
54
  "required",
@@ -60,6 +60,7 @@ const tableHeadingsSchema = z.record(actionsSchema, headingsSchema.array().optio
60
60
  "version",
61
61
  "devDependency"
62
62
  ],
63
+ USAGE: [],
63
64
  WORKSPACE: [
64
65
  "name",
65
66
  "version",
@@ -67,10 +68,10 @@ const tableHeadingsSchema = z.record(actionsSchema, headingsSchema.array().optio
67
68
  "description"
68
69
  ],
69
70
  ZOD: []
70
- });
71
+ }).meta({ description: "Table heading action configuration" });
71
72
  const templatesSchema = z.object({
72
- downloadImage: z.string().optional().default("https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F"),
73
- emojis: z.record(headingsSchema, z.string()).optional().describe("Table heading emojis used when enabled").default({
73
+ downloadImage: z.string().default("https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F"),
74
+ emojis: z.record(headingsSchema, z.string()).default({
74
75
  default: "⚙️",
75
76
  description: "📝",
76
77
  devDependency: "💻",
@@ -79,15 +80,15 @@ const templatesSchema = z.object({
79
80
  private: "🔒",
80
81
  required: "",
81
82
  version: ""
82
- }),
83
- registryUrl: z.string().optional().default("https://www.npmjs.com/package/{{name}}"),
84
- versionImage: z.string().optional().default("https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F")
83
+ }).meta({ description: "Table heading emojis used when enabled" }),
84
+ registryUrl: z.string().default("https://www.npmjs.com/package/{{name}}"),
85
+ versionImage: z.string().default("https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F")
85
86
  });
86
87
  const defaultTemplates = templatesSchema.parse({});
87
88
  const defaultTableHeadings = tableHeadingsSchema.parse(void 0);
88
89
  const _configSchema = z.object({
89
- affectedRegexes: z.string().array().optional().default([]),
90
- collapseHeadings: z.string().array().optional().default([]),
90
+ affectedRegexes: z.string().array().default([]),
91
+ collapseHeadings: z.string().array().default([]),
91
92
  defaultLanguage: languageSchema.meta({
92
93
  alias: "l",
93
94
  description: "Default language to infer projects from"
@@ -102,7 +103,7 @@ const _configSchema = z.object({
102
103
  alias: "t",
103
104
  description: "generate table of contents for readmes"
104
105
  }),
105
- enableUsage: z.boolean().optional().default(false).meta({ description: "Whether or not to enable usage plugin" }),
106
+ enableUsage: z.boolean().default(false).meta({ description: "Whether or not to enable usage plugin" }),
106
107
  headings: tableHeadingsSchema.optional().default(defaultTableHeadings).describe("List of headings for different table outputs"),
107
108
  onlyReadmes: z.boolean().default(true).meta({
108
109
  alias: "r",
@@ -112,18 +113,17 @@ const _configSchema = z.object({
112
113
  alias: "p",
113
114
  description: "Only show public packages in workspaces"
114
115
  }),
115
- removeScope: z.string().optional().default("").meta({ description: "Remove common workspace scope" }),
116
+ removeScope: z.string().default("").meta({ description: "Remove common workspace scope" }),
116
117
  templates: templatesSchema.optional().default(defaultTemplates).describe("Handlebars templates used to fuel list and table generation"),
117
- tocHeading: z.string().optional().default("Table of contents").meta({ description: "Markdown heading used to generate table of contents" }),
118
- usageFile: z.string().optional().default("").meta({ description: "Workspace level usage file" }),
119
- usageHeading: z.string().optional().default("Usage").meta({ description: "Markdown heading used to generate usage example" }),
118
+ tocHeading: z.string().default("Table of contents").meta({ description: "Markdown heading used to generate table of contents" }),
119
+ usageFile: z.string().default("").meta({ description: "Workspace level usage file" }),
120
+ usageHeading: z.string().default("Usage").meta({ description: "Markdown heading used to generate usage example" }),
120
121
  verbose: z.boolean().default(false).meta({
121
122
  alias: "v",
122
123
  description: "whether or not to display verbose logging"
123
124
  })
124
125
  });
125
126
  const configSchema = _configSchema.optional();
126
- /** @typedef {Partial<z.infer<typeof _configSchema>>} Config */
127
127
 
128
128
  //#endregion
129
129
  //#region src/args.ts
@@ -163,12 +163,12 @@ function zodToYargs() {
163
163
  const { shape } = configSchema.unwrap();
164
164
  const entries = Object.entries(shape).map(([key, value]) => {
165
165
  if (complexOptions.includes(key)) return [];
166
- if (value.def.innerType instanceof z$1.ZodObject) return [];
166
+ if (value.def.innerType instanceof z.ZodObject) return [];
167
167
  const meta = value.meta();
168
168
  const { innerType } = value.def;
169
- const isBoolean = innerType instanceof z$1.ZodBoolean;
170
- const isNumber = innerType instanceof z$1.ZodNumber;
171
- const yargType = innerType instanceof z$1.ZodArray && "array" || isNumber && "number" || isBoolean && "boolean" || "string";
169
+ const isBoolean = innerType instanceof z.ZodBoolean;
170
+ const isNumber = innerType instanceof z.ZodNumber;
171
+ const yargType = innerType instanceof z.ZodArray && "array" || isNumber && "number" || isBoolean && "boolean" || "string";
172
172
  const options = {
173
173
  default: value.def.defaultValue,
174
174
  type: yargType
@@ -311,18 +311,6 @@ function findAffectedMarkdowns(root, config) {
311
311
  INFO("Found the following readmes", dedupe);
312
312
  return dedupe;
313
313
  }
314
- function findNearestReadme(gitRoot, inputFile, maxRotations = 15) {
315
- let dir = path$1.dirname(inputFile);
316
- let rotations = 0;
317
- while (true) {
318
- const option = path$1.join(dir, "README.md");
319
- if (fs.existsSync(option)) return option;
320
- const parent = path$1.dirname(dir);
321
- if (parent === dir || dir === gitRoot || ++rotations > maxRotations) break;
322
- dir = parent;
323
- }
324
- return null;
325
- }
326
314
  function getGitRoot() {
327
315
  const root = cp.execSync(sh`git rev-parse --show-toplevel`, opts).trim();
328
316
  if (!root) throw new Error("must be ran within a git directory.");
@@ -342,6 +330,18 @@ async function getPrettierPaths(paths) {
342
330
  return path$1.join(path$1.dirname(file), symlink);
343
331
  }));
344
332
  }
333
+ function findNearestReadme(gitRoot, inputFile, maxRotations = 15) {
334
+ let dir = path$1.dirname(inputFile);
335
+ let rotations = 0;
336
+ while (true) {
337
+ const option = path$1.join(dir, "README.md");
338
+ if (fs.existsSync(option)) return option;
339
+ const parent = path$1.dirname(dir);
340
+ if (parent === dir || dir === gitRoot || ++rotations > maxRotations) break;
341
+ dir = parent;
342
+ }
343
+ return null;
344
+ }
345
345
 
346
346
  //#endregion
347
347
  //#region src/data.ts
@@ -630,5 +630,4 @@ async function run() {
630
630
  }
631
631
 
632
632
  //#endregion
633
- export { run };
634
- //# sourceMappingURL=index.js.map
633
+ export { run };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stephansama/auto-readme",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Generate lists and tables for your README automagically based on your repository and comments",
5
5
  "keywords": [
6
6
  "auto",
@@ -15,7 +15,7 @@
15
15
  "homepage": "https://packages.stephansama.info/api/@stephansama/auto-readme",
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "https://github.com/stephansama/packages",
18
+ "url": "git+https://github.com/stephansama/packages.git",
19
19
  "directory": "core/auto-readme"
20
20
  },
21
21
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  }
38
38
  },
39
39
  "./schema.json": "./config/schema.json",
40
- "./schema.yaml": "./config/schema.yaml"
40
+ "./package.json": "./package.json"
41
41
  },
42
42
  "main": "./config/schema.js",
43
43
  "types": "./config/schema.d.ts",
@@ -50,28 +50,26 @@
50
50
  "dependencies": {
51
51
  "@iarna/toml": "^2.2.5",
52
52
  "@manypkg/get-packages": "^3.1.0",
53
- "chalk": "^5.5.0",
54
- "cosmiconfig": "^9.0.0",
55
- "debug": "^4.4.1",
53
+ "cosmiconfig": "9.0.0",
54
+ "debug": "^4.4.3",
56
55
  "deepmerge": "^4.3.1",
57
56
  "fast-glob": "^3.3.3",
58
- "handlebars": "^4.7.8",
57
+ "handlebars": "4.7.8",
59
58
  "markdown-table": "^3.0.4",
60
59
  "mdast-comment-marker": "^3.0.0",
61
60
  "mdast-util-from-markdown": "^2.0.2",
62
- "mdast-util-gfm": "^3.1.0",
63
61
  "mdast-zone": "github:stephansama/mdast-zone#1c5b08cd97240debeed4c9c6afad49df5877a132",
64
62
  "ora": "^8.2.0",
65
63
  "pkg-types": "^2.2.0",
66
- "remark": "^15.0.1",
64
+ "remark": "15.0.1",
67
65
  "remark-code-import": "^1.2.0",
68
66
  "remark-collapse": "^0.1.2",
69
67
  "remark-toc": "^9.0.0",
70
68
  "remark-usage": "^11.0.1",
71
69
  "vfile": "^6.0.3",
72
70
  "yaml": "^2.8.1",
73
- "yargs": "^18.0.0",
74
- "zod": "^4.0.15",
71
+ "yargs": "18.0.0",
72
+ "zod": "4.2.1",
75
73
  "zod2md": "^0.2.4"
76
74
  },
77
75
  "devDependencies": {
@@ -80,7 +78,7 @@
80
78
  "@types/vfile": "^4.0.0",
81
79
  "@types/yargs": "^17.0.33",
82
80
  "mdast": "^3.0.0",
83
- "tsdown": "^0.15.12",
81
+ "tsdown": "0.15.12",
84
82
  "unified": "^11.0.5"
85
83
  },
86
84
  "publishConfig": {
@@ -89,6 +87,7 @@
89
87
  },
90
88
  "scripts": {
91
89
  "build": "node build.mjs",
90
+ "postbuild": "publint",
92
91
  "dev": "node --watch-path=./src build.mjs",
93
92
  "lint": "eslint ./src/ --pass-on-no-patterns --no-error-on-unmatched-pattern"
94
93
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.cjs","names":["z"],"sources":["../src/schema.js"],"sourcesContent":["import { z } from \"zod\";\n\nexport const actionsSchema = z\n\t.enum([\"ACTION\", \"PKG\", \"USAGE\", \"WORKSPACE\", \"ZOD\"])\n\t.describe(\"Comment action options\");\n\nexport const formatsSchema = z\n\t.enum([\"LIST\", \"TABLE\"])\n\t.default(\"TABLE\")\n\t.optional();\n\nexport const languageSchema = z.enum([\"JS\", \"RS\"]).optional().default(\"JS\");\n\nexport const headingsSchema = z\n\t.enum([\n\t\t\"default\",\n\t\t\"description\",\n\t\t\"devDependency\",\n\t\t\"downloads\",\n\t\t\"name\",\n\t\t\"private\",\n\t\t\"required\",\n\t\t\"version\",\n\t])\n\t.describe(\"Table heading options\");\n\nexport const tableHeadingsSchema = z\n\t.record(actionsSchema, headingsSchema.array().optional())\n\t.optional()\n\t.describe(\"Table heading action configuration\")\n\t.default({\n\t\tACTION: [\"name\", \"required\", \"default\", \"description\"],\n\t\tPKG: [\"name\", \"version\", \"devDependency\"],\n\t\tWORKSPACE: [\"name\", \"version\", \"downloads\", \"description\"],\n\t\tZOD: [],\n\t});\n\nexport const templatesSchema = z.object({\n\tdownloadImage: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\"https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F\"),\n\temojis: z\n\t\t.record(headingsSchema, z.string())\n\t\t.optional()\n\t\t.describe(\"Table heading emojis used when enabled\")\n\t\t.default({\n\t\t\tdefault: \"⚙️\",\n\t\t\tdescription: \"📝\",\n\t\t\tdevDependency: \"💻\",\n\t\t\tdownloads: \"📥\",\n\t\t\tname: \"🏷️\",\n\t\t\tprivate: \"🔒\",\n\t\t\trequired: \"\",\n\t\t\tversion: \"\",\n\t\t}),\n\tregistryUrl: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\"https://www.npmjs.com/package/{{name}}\"),\n\tversionImage: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\n\t\t\t\"https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F\",\n\t\t),\n});\n\nexport const defaultTemplates = templatesSchema.parse({});\nexport const defaultTableHeadings = tableHeadingsSchema.parse(undefined);\n\nconst _configSchema = z.object({\n\taffectedRegexes: z.string().array().optional().default([]),\n\tcollapseHeadings: z.string().array().optional().default([]),\n\tdefaultLanguage: languageSchema.meta({\n\t\talias: \"l\",\n\t\tdescription: \"Default language to infer projects from\",\n\t}),\n\tdisableEmojis: z.boolean().default(false).meta({\n\t\talias: \"e\",\n\t\tdescription: \"Whether or not to use emojis in markdown table headings\",\n\t}),\n\tdisableMarkdownHeadings: z.boolean().default(false).meta({\n\t\tdescription: \"Whether or not to display markdown headings\",\n\t}),\n\tenablePrettier: z.boolean().default(true).meta({\n\t\tdescription: \"Whether or not to use prettier to format the files\",\n\t}),\n\tenableToc: z.boolean().default(false).meta({\n\t\talias: \"t\",\n\t\tdescription: \"generate table of contents for readmes\",\n\t}),\n\tenableUsage: z.boolean().optional().default(false).meta({\n\t\tdescription: \"Whether or not to enable usage plugin\",\n\t}),\n\theadings: tableHeadingsSchema\n\t\t.optional()\n\t\t.default(defaultTableHeadings)\n\t\t.describe(\"List of headings for different table outputs\"),\n\tonlyReadmes: z.boolean().default(true).meta({\n\t\talias: \"r\",\n\t\tdescription: \"Whether or not to only traverse readmes\",\n\t}),\n\tonlyShowPublicPackages: z.boolean().default(false).meta({\n\t\talias: \"p\",\n\t\tdescription: \"Only show public packages in workspaces\",\n\t}),\n\tremoveScope: z.string().optional().default(\"\").meta({\n\t\tdescription: \"Remove common workspace scope\",\n\t}),\n\ttemplates: templatesSchema\n\t\t.optional()\n\t\t.default(defaultTemplates)\n\t\t.describe(\n\t\t\t\"Handlebars templates used to fuel list and table generation\",\n\t\t),\n\ttocHeading: z.string().optional().default(\"Table of contents\").meta({\n\t\tdescription: \"Markdown heading used to generate table of contents\",\n\t}),\n\tusageFile: z.string().optional().default(\"\").meta({\n\t\tdescription: \"Workspace level usage file\",\n\t}),\n\tusageHeading: z.string().optional().default(\"Usage\").meta({\n\t\tdescription: \"Markdown heading used to generate usage example\",\n\t}),\n\tverbose: z.boolean().default(false).meta({\n\t\talias: \"v\",\n\t\tdescription: \"whether or not to display verbose logging\",\n\t}),\n});\n\nexport const configSchema = _configSchema.optional();\n\n/** @typedef {Partial<z.infer<typeof _configSchema>>} Config */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,gBAAgBA,MAC3B,KAAK;CAAC;CAAU;CAAO;CAAS;CAAa;CAAM,CAAC,CACpD,SAAS,yBAAyB;AAEpC,MAAa,gBAAgBA,MAC3B,KAAK,CAAC,QAAQ,QAAQ,CAAC,CACvB,QAAQ,QAAQ,CAChB,UAAU;AAEZ,MAAa,iBAAiBA,MAAE,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,UAAU,CAAC,QAAQ,KAAK;AAE3E,MAAa,iBAAiBA,MAC5B,KAAK;CACL;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,CAAC,CACD,SAAS,wBAAwB;AAEnC,MAAa,sBAAsBA,MACjC,OAAO,eAAe,eAAe,OAAO,CAAC,UAAU,CAAC,CACxD,UAAU,CACV,SAAS,qCAAqC,CAC9C,QAAQ;CACR,QAAQ;EAAC;EAAQ;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,MAAE,SAAS,CAAC,UAAU,CAAC,QAAQ,MAAM,CAAC,KAAK,EACvD,aAAa,yCACb,CAAC;CACF,UAAU,oBACR,UAAU,CACV,QAAQ,qBAAqB,CAC7B,SAAS,+CAA+C;CAC1D,aAAaA,MAAE,SAAS,CAAC,QAAQ,KAAK,CAAC,KAAK;EAC3C,OAAO;EACP,aAAa;EACb,CAAC;CACF,wBAAwBA,MAAE,SAAS,CAAC,QAAQ,MAAM,CAAC,KAAK;EACvD,OAAO;EACP,aAAa;EACb,CAAC;CACF,aAAaA,MAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,KAAK,EACnD,aAAa,iCACb,CAAC;CACF,WAAW,gBACT,UAAU,CACV,QAAQ,iBAAiB,CACzB,SACA,8DACA;CACF,YAAYA,MAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,oBAAoB,CAAC,KAAK,EACnE,aAAa,uDACb,CAAC;CACF,WAAWA,MAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,KAAK,EACjD,aAAa,8BACb,CAAC;CACF,cAAcA,MAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,QAAQ,CAAC,KAAK,EACzD,aAAa,mDACb,CAAC;CACF,SAASA,MAAE,SAAS,CAAC,QAAQ,MAAM,CAAC,KAAK;EACxC,OAAO;EACP,aAAa;EACb,CAAC;CACF,CAAC;AAEF,MAAa,eAAe,cAAc,UAAU"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../src/schema.js"],"sourcesContent":["import { z } from \"zod\";\n\nexport const actionsSchema = z\n\t.enum([\"ACTION\", \"PKG\", \"USAGE\", \"WORKSPACE\", \"ZOD\"])\n\t.describe(\"Comment action options\");\n\nexport const formatsSchema = z\n\t.enum([\"LIST\", \"TABLE\"])\n\t.default(\"TABLE\")\n\t.optional();\n\nexport const languageSchema = z.enum([\"JS\", \"RS\"]).optional().default(\"JS\");\n\nexport const headingsSchema = z\n\t.enum([\n\t\t\"default\",\n\t\t\"description\",\n\t\t\"devDependency\",\n\t\t\"downloads\",\n\t\t\"name\",\n\t\t\"private\",\n\t\t\"required\",\n\t\t\"version\",\n\t])\n\t.describe(\"Table heading options\");\n\nexport const tableHeadingsSchema = z\n\t.record(actionsSchema, headingsSchema.array().optional())\n\t.optional()\n\t.describe(\"Table heading action configuration\")\n\t.default({\n\t\tACTION: [\"name\", \"required\", \"default\", \"description\"],\n\t\tPKG: [\"name\", \"version\", \"devDependency\"],\n\t\tWORKSPACE: [\"name\", \"version\", \"downloads\", \"description\"],\n\t\tZOD: [],\n\t});\n\nexport const templatesSchema = z.object({\n\tdownloadImage: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\"https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F\"),\n\temojis: z\n\t\t.record(headingsSchema, z.string())\n\t\t.optional()\n\t\t.describe(\"Table heading emojis used when enabled\")\n\t\t.default({\n\t\t\tdefault: \"⚙️\",\n\t\t\tdescription: \"📝\",\n\t\t\tdevDependency: \"💻\",\n\t\t\tdownloads: \"📥\",\n\t\t\tname: \"🏷️\",\n\t\t\tprivate: \"🔒\",\n\t\t\trequired: \"\",\n\t\t\tversion: \"\",\n\t\t}),\n\tregistryUrl: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\"https://www.npmjs.com/package/{{name}}\"),\n\tversionImage: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\n\t\t\t\"https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F\",\n\t\t),\n});\n\nexport const defaultTemplates = templatesSchema.parse({});\nexport const defaultTableHeadings = tableHeadingsSchema.parse(undefined);\n\nconst _configSchema = z.object({\n\taffectedRegexes: z.string().array().optional().default([]),\n\tcollapseHeadings: z.string().array().optional().default([]),\n\tdefaultLanguage: languageSchema.meta({\n\t\talias: \"l\",\n\t\tdescription: \"Default language to infer projects from\",\n\t}),\n\tdisableEmojis: z.boolean().default(false).meta({\n\t\talias: \"e\",\n\t\tdescription: \"Whether or not to use emojis in markdown table headings\",\n\t}),\n\tdisableMarkdownHeadings: z.boolean().default(false).meta({\n\t\tdescription: \"Whether or not to display markdown headings\",\n\t}),\n\tenablePrettier: z.boolean().default(true).meta({\n\t\tdescription: \"Whether or not to use prettier to format the files\",\n\t}),\n\tenableToc: z.boolean().default(false).meta({\n\t\talias: \"t\",\n\t\tdescription: \"generate table of contents for readmes\",\n\t}),\n\tenableUsage: z.boolean().optional().default(false).meta({\n\t\tdescription: \"Whether or not to enable usage plugin\",\n\t}),\n\theadings: tableHeadingsSchema\n\t\t.optional()\n\t\t.default(defaultTableHeadings)\n\t\t.describe(\"List of headings for different table outputs\"),\n\tonlyReadmes: z.boolean().default(true).meta({\n\t\talias: \"r\",\n\t\tdescription: \"Whether or not to only traverse readmes\",\n\t}),\n\tonlyShowPublicPackages: z.boolean().default(false).meta({\n\t\talias: \"p\",\n\t\tdescription: \"Only show public packages in workspaces\",\n\t}),\n\tremoveScope: z.string().optional().default(\"\").meta({\n\t\tdescription: \"Remove common workspace scope\",\n\t}),\n\ttemplates: templatesSchema\n\t\t.optional()\n\t\t.default(defaultTemplates)\n\t\t.describe(\n\t\t\t\"Handlebars templates used to fuel list and table generation\",\n\t\t),\n\ttocHeading: z.string().optional().default(\"Table of contents\").meta({\n\t\tdescription: \"Markdown heading used to generate table of contents\",\n\t}),\n\tusageFile: z.string().optional().default(\"\").meta({\n\t\tdescription: \"Workspace level usage file\",\n\t}),\n\tusageHeading: z.string().optional().default(\"Usage\").meta({\n\t\tdescription: \"Markdown heading used to generate usage example\",\n\t}),\n\tverbose: z.boolean().default(false).meta({\n\t\talias: \"v\",\n\t\tdescription: \"whether or not to display verbose logging\",\n\t}),\n});\n\nexport const configSchema = _configSchema.optional();\n\n/** @typedef {Partial<z.infer<typeof _configSchema>>} Config */\n"],"mappings":";;;AAEA,MAAa,gBAAgB,EAC3B,KAAK;CAAC;CAAU;CAAO;CAAS;CAAa;CAAM,CA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M,CAAC,KAAK;EACxC,OAAO;EACP,aAAa;EACb,CAAC;CACF,CAAC;AAEF,MAAa,eAAe,cAAc,UAAU"}
@@ -1,193 +0,0 @@
1
- $schema: https://json-schema.org/draft/2020-12/schema
2
- type: object
3
- properties:
4
- affectedRegexes:
5
- default: []
6
- type: array
7
- items:
8
- type: string
9
- collapseHeadings:
10
- default: []
11
- type: array
12
- items:
13
- type: string
14
- defaultLanguage:
15
- alias: l
16
- description: Default language to infer projects from
17
- default: JS
18
- type: string
19
- enum:
20
- - JS
21
- - RS
22
- disableEmojis:
23
- alias: e
24
- description: Whether or not to use emojis in markdown table headings
25
- default: false
26
- type: boolean
27
- disableMarkdownHeadings:
28
- description: Whether or not to display markdown headings
29
- default: false
30
- type: boolean
31
- enablePrettier:
32
- description: Whether or not to use prettier to format the files
33
- default: true
34
- type: boolean
35
- enableToc:
36
- alias: t
37
- description: generate table of contents for readmes
38
- default: false
39
- type: boolean
40
- enableUsage:
41
- description: Whether or not to enable usage plugin
42
- default: false
43
- type: boolean
44
- headings:
45
- description: List of headings for different table outputs
46
- default:
47
- ACTION:
48
- - name
49
- - required
50
- - default
51
- - description
52
- PKG:
53
- - name
54
- - version
55
- - devDependency
56
- WORKSPACE:
57
- - name
58
- - version
59
- - downloads
60
- - description
61
- ZOD: []
62
- type: object
63
- propertyNames:
64
- description: Comment action options
65
- type: string
66
- enum:
67
- - ACTION
68
- - PKG
69
- - USAGE
70
- - WORKSPACE
71
- - ZOD
72
- additionalProperties:
73
- type: array
74
- items:
75
- description: Table heading options
76
- type: string
77
- enum:
78
- - default
79
- - description
80
- - devDependency
81
- - downloads
82
- - name
83
- - private
84
- - required
85
- - version
86
- onlyReadmes:
87
- alias: r
88
- description: Whether or not to only traverse readmes
89
- default: true
90
- type: boolean
91
- onlyShowPublicPackages:
92
- alias: p
93
- description: Only show public packages in workspaces
94
- default: false
95
- type: boolean
96
- removeScope:
97
- description: Remove common workspace scope
98
- default: ""
99
- type: string
100
- templates:
101
- description: Handlebars templates used to fuel list and table generation
102
- default:
103
- downloadImage: https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F
104
- emojis:
105
- default: ⚙️
106
- description: 📝
107
- devDependency: 💻
108
- downloads: 📥
109
- name: 🏷️
110
- private: 🔒
111
- required: ""
112
- version: ""
113
- registryUrl: https://www.npmjs.com/package/{{name}}
114
- versionImage: https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F
115
- type: object
116
- properties:
117
- downloadImage:
118
- default: https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F
119
- type: string
120
- emojis:
121
- default:
122
- default: ⚙️
123
- description: 📝
124
- devDependency: 💻
125
- downloads: 📥
126
- name: 🏷️
127
- private: 🔒
128
- required: ""
129
- version: ""
130
- description: Table heading emojis used when enabled
131
- type: object
132
- propertyNames:
133
- description: Table heading options
134
- type: string
135
- enum:
136
- - default
137
- - description
138
- - devDependency
139
- - downloads
140
- - name
141
- - private
142
- - required
143
- - version
144
- additionalProperties:
145
- type: string
146
- registryUrl:
147
- default: https://www.npmjs.com/package/{{name}}
148
- type: string
149
- versionImage:
150
- default: https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F
151
- type: string
152
- required:
153
- - downloadImage
154
- - emojis
155
- - registryUrl
156
- - versionImage
157
- additionalProperties: false
158
- tocHeading:
159
- description: Markdown heading used to generate table of contents
160
- default: Table of contents
161
- type: string
162
- usageFile:
163
- description: Workspace level usage file
164
- default: ""
165
- type: string
166
- usageHeading:
167
- description: Markdown heading used to generate usage example
168
- default: Usage
169
- type: string
170
- verbose:
171
- alias: v
172
- description: whether or not to display verbose logging
173
- default: false
174
- type: boolean
175
- required:
176
- - affectedRegexes
177
- - collapseHeadings
178
- - defaultLanguage
179
- - disableEmojis
180
- - disableMarkdownHeadings
181
- - enablePrettier
182
- - enableToc
183
- - enableUsage
184
- - headings
185
- - onlyReadmes
186
- - onlyShowPublicPackages
187
- - removeScope
188
- - templates
189
- - tocHeading
190
- - usageFile
191
- - usageHeading
192
- - verbose
193
- additionalProperties: false
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["z","z","yargType: Options[\"type\"]","options: Options","opts: Partial<Options>","args","opts","toml","opts: { encoding: BufferEncoding }","fsp","cp","path","fs","path","fs","error","fsp","autoReadmeRemarkPlugin: Plugin<[Config, ActionData], Root>","zod","value","heading","path","Handlebars","remarkCodeImport","path","remarkUsage","remarkToc","remarkCollapse","vfile","VFile","args","config: Config","fsp","path","opts: cp.CommonExecOptions","opts"],"sources":["../src/schema.js","../src/args.ts","../src/log.ts","../src/comment.ts","../src/config.ts","../src/utils.ts","../src/data.ts","../src/plugin.ts","../src/pipeline.ts","../src/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const actionsSchema = z\n\t.enum([\"ACTION\", \"PKG\", \"USAGE\", \"WORKSPACE\", \"ZOD\"])\n\t.describe(\"Comment action options\");\n\nexport const formatsSchema = z\n\t.enum([\"LIST\", \"TABLE\"])\n\t.default(\"TABLE\")\n\t.optional();\n\nexport const languageSchema = z.enum([\"JS\", \"RS\"]).optional().default(\"JS\");\n\nexport const headingsSchema = z\n\t.enum([\n\t\t\"default\",\n\t\t\"description\",\n\t\t\"devDependency\",\n\t\t\"downloads\",\n\t\t\"name\",\n\t\t\"private\",\n\t\t\"required\",\n\t\t\"version\",\n\t])\n\t.describe(\"Table heading options\");\n\nexport const tableHeadingsSchema = z\n\t.record(actionsSchema, headingsSchema.array().optional())\n\t.optional()\n\t.describe(\"Table heading action configuration\")\n\t.default({\n\t\tACTION: [\"name\", \"required\", \"default\", \"description\"],\n\t\tPKG: [\"name\", \"version\", \"devDependency\"],\n\t\tWORKSPACE: [\"name\", \"version\", \"downloads\", \"description\"],\n\t\tZOD: [],\n\t});\n\nexport const templatesSchema = z.object({\n\tdownloadImage: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\"https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F\"),\n\temojis: z\n\t\t.record(headingsSchema, z.string())\n\t\t.optional()\n\t\t.describe(\"Table heading emojis used when enabled\")\n\t\t.default({\n\t\t\tdefault: \"⚙️\",\n\t\t\tdescription: \"📝\",\n\t\t\tdevDependency: \"💻\",\n\t\t\tdownloads: \"📥\",\n\t\t\tname: \"🏷️\",\n\t\t\tprivate: \"🔒\",\n\t\t\trequired: \"\",\n\t\t\tversion: \"\",\n\t\t}),\n\tregistryUrl: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\"https://www.npmjs.com/package/{{name}}\"),\n\tversionImage: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\n\t\t\t\"https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F\",\n\t\t),\n});\n\nexport const defaultTemplates = templatesSchema.parse({});\nexport const defaultTableHeadings = tableHeadingsSchema.parse(undefined);\n\nconst _configSchema = z.object({\n\taffectedRegexes: z.string().array().optional().default([]),\n\tcollapseHeadings: z.string().array().optional().default([]),\n\tdefaultLanguage: languageSchema.meta({\n\t\talias: \"l\",\n\t\tdescription: \"Default language to infer projects from\",\n\t}),\n\tdisableEmojis: z.boolean().default(false).meta({\n\t\talias: \"e\",\n\t\tdescription: \"Whether or not to use emojis in markdown table headings\",\n\t}),\n\tdisableMarkdownHeadings: z.boolean().default(false).meta({\n\t\tdescription: \"Whether or not to display markdown headings\",\n\t}),\n\tenablePrettier: z.boolean().default(true).meta({\n\t\tdescription: \"Whether or not to use prettier to format the files\",\n\t}),\n\tenableToc: z.boolean().default(false).meta({\n\t\talias: \"t\",\n\t\tdescription: \"generate table of contents for readmes\",\n\t}),\n\tenableUsage: z.boolean().optional().default(false).meta({\n\t\tdescription: \"Whether or not to enable usage plugin\",\n\t}),\n\theadings: tableHeadingsSchema\n\t\t.optional()\n\t\t.default(defaultTableHeadings)\n\t\t.describe(\"List of headings for different table outputs\"),\n\tonlyReadmes: z.boolean().default(true).meta({\n\t\talias: \"r\",\n\t\tdescription: \"Whether or not to only traverse readmes\",\n\t}),\n\tonlyShowPublicPackages: z.boolean().default(false).meta({\n\t\talias: \"p\",\n\t\tdescription: \"Only show public packages in workspaces\",\n\t}),\n\tremoveScope: z.string().optional().default(\"\").meta({\n\t\tdescription: \"Remove common workspace scope\",\n\t}),\n\ttemplates: templatesSchema\n\t\t.optional()\n\t\t.default(defaultTemplates)\n\t\t.describe(\n\t\t\t\"Handlebars templates used to fuel list and table generation\",\n\t\t),\n\ttocHeading: z.string().optional().default(\"Table of contents\").meta({\n\t\tdescription: \"Markdown heading used to generate table of contents\",\n\t}),\n\tusageFile: z.string().optional().default(\"\").meta({\n\t\tdescription: \"Workspace level usage file\",\n\t}),\n\tusageHeading: z.string().optional().default(\"Usage\").meta({\n\t\tdescription: \"Markdown heading used to generate usage example\",\n\t}),\n\tverbose: z.boolean().default(false).meta({\n\t\talias: \"v\",\n\t\tdescription: \"whether or not to display verbose logging\",\n\t}),\n});\n\nexport const configSchema = _configSchema.optional();\n\n/** @typedef {Partial<z.infer<typeof _configSchema>>} Config */\n","import debug from \"debug\";\nimport yargs, { type Options } from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport z from \"zod\";\n\nimport { configSchema } from \"./schema\";\n\nexport type Args = Awaited<ReturnType<typeof parseArgs>>;\n\nconst complexOptions = [\n\t\"affectedRegexes\",\n\t\"collapseHeadings\",\n\t\"headings\",\n\t\"templates\",\n] as const;\n\ntype ComplexOptions = (typeof complexOptions)[number];\n\nconst args = {\n\t...zodToYargs(),\n\tchanges: {\n\t\talias: \"g\",\n\t\tdefault: false,\n\t\tdescription: \"Check only changed git files\",\n\t\ttype: \"boolean\",\n\t},\n\tcheck: {\n\t\talias: \"k\",\n\t\tdefault: false,\n\t\tdescription: \"Do not write to files. Only check for changes\",\n\t\ttype: \"boolean\",\n\t},\n\tconfig: { alias: \"c\", description: \"Path to config file\", type: \"string\" },\n} satisfies Record<string, Options>;\n\nexport async function parseArgs() {\n\tconst yargsInstance = yargs(hideBin(process.argv))\n\t\t.options(args)\n\t\t.help(\"h\")\n\t\t.alias(\"h\", \"help\")\n\t\t.epilogue(`--> @stephansama open-source ${new Date().getFullYear()}`);\n\n\tconst parsed = await yargsInstance\n\t\t.wrap(yargsInstance.terminalWidth())\n\t\t.parse();\n\n\tif (parsed.verbose) debug.enable(\"autoreadme*\");\n\n\treturn parsed;\n}\n\nexport function zodToYargs(): Omit<\n\tRecord<keyof typeof shape, Options>,\n\tComplexOptions\n> {\n\tconst { shape } = configSchema.unwrap();\n\tconst entries = Object.entries(shape).map(([key, value]) => {\n\t\tif (complexOptions.includes(key as ComplexOptions)) return [];\n\t\tif (value.def.innerType instanceof z.ZodObject) return [];\n\t\tconst meta = value.meta();\n\t\tconst { innerType } = value.def;\n\t\tconst isBoolean = innerType instanceof z.ZodBoolean;\n\t\tconst isNumber = innerType instanceof z.ZodNumber;\n\t\tconst isArray = innerType instanceof z.ZodArray;\n\n\t\tconst yargType: Options[\"type\"] =\n\t\t\t(isArray && \"array\") ||\n\t\t\t(isNumber && \"number\") ||\n\t\t\t(isBoolean && \"boolean\") ||\n\t\t\t\"string\";\n\n\t\tconst options: Options = {\n\t\t\tdefault: value.def.defaultValue,\n\t\t\ttype: yargType,\n\t\t};\n\n\t\tif (meta?.alias) options.alias = meta.alias as string;\n\t\tif (meta?.description) options.description = meta.description;\n\n\t\treturn [key, options];\n\t});\n\n\treturn Object.fromEntries(entries);\n}\n","import debug from \"debug\";\n\nconst error = debug(\"autoreadme:error\");\nconst info = debug(\"autoreadme:info\");\nconst warn = debug(\"autoreadme:warn\");\n\nexport function ERROR(...rest: unknown[]) {\n\tconst [first, ...remaining] = rest;\n\terror(`${first} %O`, ...remaining);\n}\n\nexport function INFO(...rest: unknown[]) {\n\tconst [first, ...remaining] = rest;\n\tinfo(`${first} %O`, ...remaining);\n}\n\nexport function WARN(...rest: unknown[]) {\n\tconst [first, ...remaining] = rest;\n\twarn(`${first} %O`, ...remaining);\n}\n","import type { Html, Root } from \"mdast\";\n\nimport { commentMarker } from \"mdast-comment-marker\";\n\nimport { INFO } from \"./log\";\nimport { actionsSchema, formatsSchema, languageSchema } from \"./schema\";\n\nexport const SEPARATOR = \"-\" as const;\n\nexport type AstComments = ReturnType<typeof loadAstComments>;\n\nexport function loadAstComments(root: Root) {\n\treturn root.children\n\t\t.map((child) => child.type === \"html\" && getComment(child))\n\t\t.filter((f): f is ReturnType<typeof parseComment> => f !== false);\n}\n\nexport function parseComment(comment: string) {\n\tconst input = trimComment(comment);\n\tconst [type, ...parameters] = input.split(\" \");\n\tconst [first, second, third] = type.split(SEPARATOR);\n\n\tINFO(\"parsing inputs\", { first, second, third });\n\n\tconst languageInput = third ? first : undefined;\n\tconst actionInput = third ? second : first;\n\tconst formatInput = third ? third : second;\n\tconst language = languageSchema.parse(languageInput);\n\tconst action = actionsSchema.parse(actionInput);\n\tconst format = formatsSchema.parse(formatInput);\n\tconst isStart = comment.includes(\"start\");\n\tconst parsed = { action, format, isStart, language, parameters };\n\n\tINFO(`Parsed comment ${comment}`, parsed);\n\n\treturn parsed;\n}\n\nconst startComment = \"<!--\";\nconst endComment = \"-->\";\n\nexport function trimComment(comment: string) {\n\treturn comment\n\t\t.replace(startComment, \"\")\n\t\t.replace(/start|end/, \"\")\n\t\t.replace(endComment, \"\")\n\t\t.trim();\n}\n\nfunction getComment(comment: Html) {\n\tif (!isComment(comment.value)) return false;\n\n\tconst marker = commentMarker(comment);\n\tif (!marker) return false;\n\n\t// TODO: update parseComment to use comment marker\n\treturn parseComment(comment.value);\n}\n\nfunction isComment(comment: string) {\n\treturn comment.startsWith(startComment) && comment.endsWith(endComment);\n}\n","import toml from \"@iarna/toml\";\nimport { cosmiconfig, getDefaultSearchPlaces, type Options } from \"cosmiconfig\";\nimport deepmerge from \"deepmerge\";\n\nimport type { Args } from \"./args\";\n\nimport { INFO, WARN } from \"./log\";\nimport { configSchema } from \"./schema\";\n\nconst moduleName = \"autoreadme\";\n\nconst searchPlaces = getSearchPlaces();\n\nconst loaders = { [\".toml\"]: loadToml };\n\nexport async function loadConfig(args: Partial<Args>) {\n\tconst opts: Partial<Options> = { loaders, searchPlaces };\n\n\tif (args.config) opts.searchPlaces = [args.config];\n\n\tconst explorer = cosmiconfig(moduleName, opts);\n\n\tconst search = await explorer.search();\n\n\tif (!search) {\n\t\tconst location = args.config ? \" at location: \" + args.config : \"\";\n\t\tWARN(`no config file found`, location);\n\t\tINFO(\"using default configuration\");\n\t} else {\n\t\tINFO(\"found configuration file at: \", search.filepath);\n\t\tINFO(\"loaded cosmiconfig\", search.config);\n\t}\n\n\targs = removeFalsy(args);\n\n\tINFO(\"merging config with args\", args);\n\n\treturn configSchema.parse(\n\t\tdeepmerge(search?.config || {}, args, {\n\t\t\tarrayMerge: (_, sourceArray) => sourceArray,\n\t\t}),\n\t);\n}\n\nexport function loadToml(_filepath: string, content: string) {\n\treturn toml.parse(content);\n}\n\nfunction getSearchPlaces() {\n\treturn [\n\t\t...getDefaultSearchPlaces(moduleName),\n\t\t`.${moduleName}rc.toml`,\n\t\t`.config/.${moduleName}rc`,\n\t\t`.config/${moduleName}rc.toml`,\n\t\t`.config/.${moduleName}rc.toml`,\n\t\t`.config/.${moduleName}rc.json`,\n\t\t`.config/.${moduleName}rc.yaml`,\n\t\t`.config/.${moduleName}rc.yml`,\n\t];\n}\n\nfunction removeFalsy(obj: object) {\n\treturn Object.fromEntries(\n\t\tObject.entries(obj)\n\t\t\t.map(([k, v]) => (!v ? false : [k, v]))\n\t\t\t.filter((e): e is [string, unknown] => Boolean(e)),\n\t);\n}\n","import glob from \"fast-glob\";\nimport * as cp from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as fsp from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport type { Config } from \"./schema\";\n\nimport { ERROR, INFO } from \"./log\";\n\nconst sh = String.raw;\n\nconst opts: { encoding: BufferEncoding } = { encoding: \"utf8\" };\n\nconst ignore = [\"**/node_modules/**\"];\n\nconst matches = [\n\t/.*README\\.md$/gi,\n\t/.*Cargo\\.toml$/gi,\n\t/.*action\\.ya?ml$/gi,\n\t/.*package\\.json$/gi,\n\t/.*pnpm-workspace\\.yaml$/gi,\n];\n\nexport async function fileExists(file: string) {\n\treturn await fsp\n\t\t.access(file)\n\t\t.then(() => true)\n\t\t.catch(() => false);\n}\n\nexport function findAffectedMarkdowns(root: string, config: Config) {\n\tconst affected = cp\n\t\t/* cspell:disable-next-line because of the filter */\n\t\t.execSync(sh`git diff --cached --name-only --diff-filter=MACT`, opts)\n\t\t.trim()\n\t\t.split(\"\\n\")\n\t\t.filter(Boolean);\n\n\tif (!affected.length) ERROR(\"no staged files found\");\n\n\tif (config.affectedRegexes?.length) {\n\t\tINFO(\"adding the following expressions: \", config.affectedRegexes);\n\t}\n\n\tconst allMatches = [\n\t\t...matches,\n\t\t...(config.affectedRegexes?.map((r) => new RegExp(r)) || []),\n\t];\n\n\tINFO(\"Checking affected files against regexes\", affected, allMatches);\n\n\tconst eligible = affected.filter((a) => allMatches.some((m) => a.match(m)));\n\n\tINFO(\"Found the following eligible affected files\", eligible);\n\n\tconst md = eligible.map((e) => findNearestReadme(root, path.resolve(e)));\n\tconst rootMd = path.join(root, \"README.md\");\n\tconst dedupe = [...new Set(md), rootMd].filter((s): s is string =>\n\t\tBoolean(s),\n\t);\n\n\tINFO(\"Found the following readmes\", dedupe);\n\n\treturn dedupe;\n}\n\nexport function findNearestReadme(\n\tgitRoot: string,\n\tinputFile: string,\n\tmaxRotations = 15,\n) {\n\tlet dir = path.dirname(inputFile);\n\tlet rotations = 0;\n\n\twhile (true) {\n\t\tconst option = path.join(dir, \"README.md\");\n\n\t\tif (fs.existsSync(option)) return option;\n\n\t\tconst parent = path.dirname(dir);\n\n\t\tif (parent === dir || dir === gitRoot || ++rotations > maxRotations) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdir = parent;\n\t}\n\n\treturn null;\n}\n\nexport function getGitRoot() {\n\tconst root = cp.execSync(sh`git rev-parse --show-toplevel`, opts).trim();\n\n\tif (!root) {\n\t\tthrow new Error(\"must be ran within a git directory.\");\n\t}\n\n\tINFO(\"found git root at location: \", root);\n\n\treturn root;\n}\n\nexport async function getMarkdownPaths(cwd: string, config: Config) {\n\tconst pattern = `**/${config?.onlyReadmes ? \"README\" : \"*\"}.md`;\n\tconst readmes = await glob(pattern, { cwd, ignore });\n\treturn readmes.map((readme) => path.resolve(cwd, readme));\n}\n\nexport async function getPrettierPaths(paths: string[]) {\n\treturn await Promise.all(\n\t\tpaths.map(async (file) => {\n\t\t\tconst stats = await fsp.lstat(file);\n\t\t\tconst isSymbolicLink = stats.isSymbolicLink();\n\t\t\tif (!isSymbolicLink) return file;\n\t\t\tconst symlink = await fsp.readlink(file);\n\t\t\treturn path.join(path.dirname(file), symlink);\n\t\t}),\n\t);\n}\n","import { getPackages } from \"@manypkg/get-packages\";\nimport * as fs from \"node:fs\";\nimport * as fsp from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { readPackageJSON } from \"pkg-types\";\nimport * as yaml from \"yaml\";\nimport { zod2md } from \"zod2md\";\n\nimport type { AstComments } from \"./comment\";\n\nimport { fileExists } from \"./utils\";\n\nexport type ActionData = Awaited<ReturnType<typeof loadActionData>>;\n\nexport type ActionTableHeading = \"name\" | keyof ActionInput;\n\nexport type ActionYaml = { inputs?: Record<string, ActionInput> };\n\ntype ActionInput = {\n\tdefault?: string;\n\tdescription?: string;\n\trequired?: boolean;\n};\n\nexport function createFindParameter(parameterList: string[]) {\n\treturn function (parameterName: string) {\n\t\treturn parameterList\n\t\t\t?.find((p) => p.startsWith(parameterName))\n\t\t\t?.replace(parameterName + \"=\", \"\")\n\t\t\t?.replace(/\"/gi, \"\")\n\t\t\t?.replace(/_/gi, \" \");\n\t};\n}\n\nexport async function loadActionData(\n\tactions: AstComments,\n\tfile: string,\n\troot: string,\n) {\n\tconst startActions = actions.filter((action) => action.isStart);\n\treturn await Promise.all(\n\t\tstartActions.map(async (action) => {\n\t\t\tconst find = createFindParameter(action.parameters);\n\t\t\tswitch (action.action) {\n\t\t\t\tcase \"ACTION\": {\n\t\t\t\t\tconst baseDir = path.dirname(file);\n\t\t\t\t\tconst actionYaml = await loadActionYaml(baseDir);\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction: action.action,\n\t\t\t\t\t\tactionYaml,\n\t\t\t\t\t\tparameters: action.parameters,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"PKG\": {\n\t\t\t\t\tconst inputPath = find(\"path\");\n\t\t\t\t\tconst filename = inputPath\n\t\t\t\t\t\t? path.resolve(path.dirname(file), inputPath)\n\t\t\t\t\t\t: path.dirname(file);\n\t\t\t\t\tconst pkgJson = await readPackageJSON(filename);\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction: action.action,\n\t\t\t\t\t\tparameters: action.parameters,\n\t\t\t\t\t\tpkgJson,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"USAGE\": {\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction: action.action,\n\t\t\t\t\t\tparameters: action.parameters,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"WORKSPACE\": {\n\t\t\t\t\tconst workspaces = await getPackages(process.cwd());\n\t\t\t\t\tconst pnpmPath = path.resolve(root, \"pnpm-workspace.yaml\");\n\t\t\t\t\tconst isPnpm = fs.existsSync(pnpmPath);\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction: action.action,\n\t\t\t\t\t\tisPnpm,\n\t\t\t\t\t\tparameters: action.parameters,\n\t\t\t\t\t\troot,\n\t\t\t\t\t\tworkspaces,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"ZOD\": {\n\t\t\t\t\tif (action.format === \"LIST\") {\n\t\t\t\t\t\tthrow new Error(\"cannot display zod in list format\");\n\t\t\t\t\t}\n\n\t\t\t\t\tconst inputPath = find(\"path\");\n\t\t\t\t\tif (!inputPath) {\n\t\t\t\t\t\tconst error = `no path found for zod table at markdown file ${file}`;\n\t\t\t\t\t\tthrow new Error(error);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst body = await zod2md({\n\t\t\t\t\t\tentry: path.resolve(path.dirname(file), inputPath),\n\t\t\t\t\t\ttitle: find(\"title\") || \"Zod Schema\",\n\t\t\t\t\t});\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction: action.action,\n\t\t\t\t\t\tbody,\n\t\t\t\t\t\tparameters: action.parameters,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(\"feature not yet implemented\");\n\t\t\t}\n\t\t}),\n\t);\n}\n\nasync function loadActionYaml(baseDir: string) {\n\tconst actionYmlPath = path.resolve(baseDir, \"action.yml\");\n\tconst actionYamlPath = path.resolve(baseDir, \"action.yaml\");\n\tconst actualPath =\n\t\t((await fileExists(actionYamlPath)) && actionYamlPath) ||\n\t\t((await fileExists(actionYmlPath)) && actionYmlPath);\n\n\tif (!actualPath) {\n\t\tconst locations = [actionYmlPath, actionYamlPath];\n\t\tconst error = `no yaml file found at locations: ${locations}`;\n\t\tthrow new Error(error);\n\t}\n\n\tconst actionFile = await fsp.readFile(actualPath, { encoding: \"utf8\" });\n\n\treturn yaml.parse(actionFile) as ActionYaml;\n}\n","import type { Root } from \"mdast\";\nimport type { Plugin } from \"unified\";\n\nimport Handlebars from \"handlebars\";\nimport { markdownTable } from \"markdown-table\";\nimport { fromMarkdown } from \"mdast-util-from-markdown\";\nimport { zone } from \"mdast-zone\";\nimport path from \"node:path\";\n\nimport type { ActionData } from \"./data\";\nimport type { Config } from \"./schema\";\n\nimport { parseComment } from \"./comment\";\nimport { defaultTableHeadings, defaultTemplates } from \"./schema\";\n\ntype TemplateContext = {\n\tname: string;\n\turi_name: string;\n};\n\nfunction createHeading(\n\theadings: (keyof NonNullable<Config[\"templates\"]>[\"emojis\"])[],\n\tdisableEmojis = false,\n\temojis: typeof defaultTemplates.emojis = defaultTemplates.emojis,\n) {\n\treturn headings.map(\n\t\t(h) =>\n\t\t\t`${disableEmojis ? \"\" : emojis[h] + \" \"}${h?.at(0)?.toUpperCase() + h?.slice(1)}`,\n\t);\n}\n\nfunction wrapRequired(required: boolean | undefined, input: string) {\n\tif (!required) return input;\n\treturn `<b>*${input}</b>`;\n}\n\nexport const autoReadmeRemarkPlugin: Plugin<[Config, ActionData], Root> =\n\t(config, data) => (tree) => {\n\t\tzone(tree, /.*ZOD.*/gi, function (start, _, end) {\n\t\t\tconst zod = data.find((d) => d?.action === \"ZOD\");\n\t\t\tif (!zod?.body) {\n\t\t\t\tthrow new Error(\"unable to load zod body\");\n\t\t\t}\n\n\t\t\tconst ast = fromMarkdown(zod.body);\n\t\t\treturn [start, ast, end];\n\t\t});\n\n\t\tzone(tree, /.*ACTION.*/gi, function (start, _, end) {\n\t\t\tconst value = start.type === \"html\" && start.value;\n\t\t\tconst options = value && parseComment(value);\n\t\t\tif (!options) throw new Error(\"not able to parse comment\");\n\n\t\t\tconst first = data.find((d) => d?.action === \"ACTION\");\n\t\t\tconst inputs = first?.actionYaml?.inputs || {};\n\t\t\tconst heading = `### ${config.disableEmojis ? \"\" : \"🧰\"} actions`;\n\n\t\t\tif (options.format === \"LIST\") {\n\t\t\t\tconst body =\n\t\t\t\t\t`${heading}\\n` +\n\t\t\t\t\tObject.entries(inputs)\n\t\t\t\t\t\t.sort((a) => (a[1].required ? -1 : 1))\n\t\t\t\t\t\t.map(([key, value]) => {\n\t\t\t\t\t\t\treturn `- ${wrapRequired(value.required, key)}: (default: ${value.default})\\n\\n${value.description}`;\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\tconst ast = fromMarkdown(body);\n\t\t\t\treturn [start, ast, end];\n\t\t\t}\n\n\t\t\tconst headings =\n\t\t\t\t(config.headings?.ACTION?.length && config.headings.ACTION) ||\n\t\t\t\tdefaultTableHeadings.ACTION!;\n\n\t\t\tconst table = markdownTable([\n\t\t\t\tcreateHeading(\n\t\t\t\t\theadings,\n\t\t\t\t\tconfig.disableEmojis,\n\t\t\t\t\tconfig.templates?.emojis,\n\t\t\t\t),\n\t\t\t\t...Object.entries(inputs).map(([k, v]) =>\n\t\t\t\t\theadings\n\t\t\t\t\t\t.map((heading) => v[heading as keyof typeof v] || k)\n\t\t\t\t\t\t.map(String),\n\t\t\t\t),\n\t\t\t]);\n\t\t\tconst body = [heading, \"\", table].join(\"\\n\");\n\t\t\tconst ast = fromMarkdown(body);\n\t\t\treturn [start, ast, end];\n\t\t});\n\n\t\tzone(tree, /.*WORKSPACE.*/gi, function (start, _, end) {\n\t\t\tconst value = start.type === \"html\" && start.value;\n\t\t\tconst comment = value && parseComment(value);\n\t\t\tconst workspace = data.find((d) => d?.action === \"WORKSPACE\");\n\t\t\tconst templates = loadTemplates(config.templates);\n\t\t\tconst packages = workspace?.workspaces?.packages || [];\n\t\t\tconst headings =\n\t\t\t\t(config.headings?.WORKSPACE?.length &&\n\t\t\t\t\tconfig.headings?.WORKSPACE) ||\n\t\t\t\tdefaultTableHeadings.WORKSPACE!;\n\n\t\t\tif (comment && comment.format === \"LIST\") {\n\t\t\t\t// throw new Error(\"List is currently not su\")\n\t\t\t}\n\n\t\t\tconst tableHeadings = createHeading(\n\t\t\t\theadings,\n\t\t\t\tconfig.disableEmojis,\n\t\t\t\tconfig.templates?.emojis,\n\t\t\t);\n\n\t\t\tconst table = markdownTable([\n\t\t\t\ttableHeadings,\n\t\t\t\t...packages\n\t\t\t\t\t.filter((pkg) =>\n\t\t\t\t\t\tconfig.onlyShowPublicPackages\n\t\t\t\t\t\t\t? !pkg.packageJson.private\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t)\n\t\t\t\t\t.map((pkg) => {\n\t\t\t\t\t\tconst { name } = pkg.packageJson;\n\t\t\t\t\t\treturn headings.map((heading) => {\n\t\t\t\t\t\t\tif (heading === \"name\") {\n\t\t\t\t\t\t\t\tconst scoped = config.removeScope\n\t\t\t\t\t\t\t\t\t? name.replace(config.removeScope, \"\")\n\t\t\t\t\t\t\t\t\t: name;\n\t\t\t\t\t\t\t\treturn `[${scoped}](${path.relative(\n\t\t\t\t\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\t\t\t\t\tpath.resolve(pkg.dir, \"README.md\"),\n\t\t\t\t\t\t\t\t)})`;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (heading === \"version\") {\n\t\t\t\t\t\t\t\treturn `![npm version image](${templates.versionImage(\n\t\t\t\t\t\t\t\t\t{ uri_name: encodeURIComponent(name) },\n\t\t\t\t\t\t\t\t)})`;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (heading === \"downloads\") {\n\t\t\t\t\t\t\t\treturn `![npm downloads](${templates.downloadImage(\n\t\t\t\t\t\t\t\t\t{ name },\n\t\t\t\t\t\t\t\t)})`;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (heading === \"description\") {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\tpkg.packageJson as { description?: string }\n\t\t\t\t\t\t\t\t)?.description;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn ``;\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t]);\n\n\t\t\tconst heading = `### ${config.disableEmojis ? \"\" : \"🏭\"} workspace`;\n\t\t\tconst body = [heading, \"\", table].join(\"\\n\");\n\t\t\tconst ast = fromMarkdown(body);\n\t\t\treturn [start, ast, end];\n\t\t});\n\n\t\tzone(tree, /.*PKG.*/gi, function (start, _, end) {\n\t\t\tconst value = start.type === \"html\" && start.value;\n\t\t\tconst comment = value && parseComment(value);\n\t\t\tconst first = data.find((d) => d?.action === \"PKG\");\n\t\t\tconst templates = loadTemplates(config.templates);\n\t\t\tconst headings =\n\t\t\t\t(config.headings?.PKG?.length && config.headings?.PKG) ||\n\t\t\t\tdefaultTableHeadings.PKG!;\n\n\t\t\tif (comment && comment.format === \"LIST\") {\n\t\t\t\tconst ast = fromMarkdown(\"\");\n\t\t\t\treturn [start, ast, end];\n\t\t\t}\n\n\t\t\tfunction mapDependencies(isDev: boolean) {\n\t\t\t\treturn function ([name, version]: [string, string]) {\n\t\t\t\t\tconst url = templates.registryUrl({ name });\n\t\t\t\t\treturn headings.map((key) => {\n\t\t\t\t\t\tif (key === \"devDependency\") {\n\t\t\t\t\t\t\tif (config.disableEmojis) {\n\t\t\t\t\t\t\t\treturn `\\`${isDev}\\``;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn `${isDev ? \"⌨️\" : \"👥\"}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (key === \"name\") {\n\t\t\t\t\t\t\treturn `[${name}](${url})`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (key === \"version\") {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t[\"workspace\", \"catalog\", \"*\"].some((type) =>\n\t\t\t\t\t\t\t\t\tversion.includes(type),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn `\\`${version}\\``;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn `![npm version](${templates.versionImage({ uri_name: encodeURIComponent(name) })})`;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { dependencies = {}, devDependencies = {} } =\n\t\t\t\tfirst?.pkgJson || {};\n\n\t\t\tconst table = markdownTable([\n\t\t\t\tcreateHeading(\n\t\t\t\t\theadings,\n\t\t\t\t\tconfig.disableEmojis,\n\t\t\t\t\tconfig.templates?.emojis,\n\t\t\t\t),\n\t\t\t\t...Object.entries(devDependencies).map(mapDependencies(true)),\n\t\t\t\t...Object.entries(dependencies).map(mapDependencies(false)),\n\t\t\t]);\n\n\t\t\tconst heading = `### ${config.disableEmojis ? \"\" : \"📦\"} packages`;\n\t\t\tconst body = [heading, \"\", table].join(\"\\n\");\n\t\t\tconst tableAst = fromMarkdown(body);\n\n\t\t\treturn [start, tableAst, end];\n\t\t});\n\t};\n\nfunction loadTemplates(\n\ttemplates: Config[\"templates\"],\n): Record<\n\tkeyof NonNullable<Config[\"templates\"]>,\n\t(context: Partial<TemplateContext>) => string\n> {\n\tif (!templates) throw new Error(\"failed to load templates\");\n\n\treturn Object.fromEntries(\n\t\tObject.entries(templates).map(([key, value]) => {\n\t\t\tif (typeof value !== \"string\") return [];\n\t\t\treturn [key, Handlebars.compile(value)];\n\t\t}),\n\t);\n}\n","import * as path from \"node:path\";\nimport { remark } from \"remark\";\nimport remarkCodeImport from \"remark-code-import\";\nimport remarkCollapse from \"remark-collapse\";\nimport remarkToc from \"remark-toc\";\nimport remarkUsage from \"remark-usage\";\nimport { VFile } from \"vfile\";\n\nimport type { ActionData } from \"./data\";\nimport type { Config } from \"./schema\";\n\nimport { createFindParameter } from \"./data\";\nimport { INFO, WARN } from \"./log\";\nimport { autoReadmeRemarkPlugin } from \"./plugin\";\nimport { fileExists } from \"./utils\";\n\nexport async function parse(\n\tfile: string,\n\tfilepath: string,\n\troot: string,\n\tconfig: Config,\n\tdata: ActionData,\n) {\n\tconst pipeline = remark()\n\t\t.use(autoReadmeRemarkPlugin, config, data)\n\t\t.use(remarkCodeImport, {});\n\n\tconst usage = data.find((d) => d.action === \"USAGE\");\n\n\tif (usage?.action === \"USAGE\" || config.enableUsage) {\n\t\tconst find = createFindParameter(usage?.parameters || []);\n\t\tconst examplePath = find(\"path\");\n\t\tconst dirname = path.dirname(filepath);\n\t\tconst resolvePath = examplePath && path.resolve(dirname, examplePath);\n\t\tconst relativeProjectPath =\n\t\t\tconfig.usageFile &&\n\t\t\tpath.relative(root, path.resolve(dirname, config.usageFile));\n\t\tconst example =\n\t\t\t(examplePath && resolvePath && path.relative(root, resolvePath)) ||\n\t\t\trelativeProjectPath ||\n\t\t\tundefined;\n\n\t\tif (example && (await fileExists(example))) {\n\t\t\tINFO(\"generating usage section\");\n\t\t\tpipeline.use(remarkUsage, {\n\t\t\t\texample,\n\t\t\t\theading: config.usageHeading,\n\t\t\t});\n\t\t} else {\n\t\t\tWARN(\"not able to find example file for readme\", filepath, example);\n\t\t}\n\t}\n\n\tif (config.enableToc) {\n\t\tINFO(\"generating table of contents section\");\n\t\tpipeline.use(remarkToc, { heading: config.tocHeading });\n\t}\n\n\tif (config.enableToc || config.collapseHeadings?.length) {\n\t\tconst additional = config.collapseHeadings?.length\n\t\t\t? config.collapseHeadings\n\t\t\t: [];\n\t\tconst headings = [...additional, config.tocHeading];\n\t\tpipeline.use(remarkCollapse, {\n\t\t\ttest: {\n\t\t\t\tignoreFinalDefinitions: true,\n\t\t\t\ttest: (value, _) => {\n\t\t\t\t\treturn headings.some((i) => value.trim() === i?.trim());\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tconst vfile = new VFile({ path: path.resolve(filepath), value: file });\n\tconst markdown = await pipeline.process(vfile);\n\treturn markdown.toString();\n}\n","import { fromMarkdown } from \"mdast-util-from-markdown\";\nimport * as cp from \"node:child_process\";\nimport * as fsp from \"node:fs/promises\";\nimport ora from \"ora\";\n\nimport type { Config } from \"./schema\";\n\nimport { parseArgs } from \"./args\";\nimport { loadAstComments } from \"./comment\";\nimport { loadConfig } from \"./config\";\nimport { loadActionData } from \"./data\";\nimport { ERROR, INFO, WARN } from \"./log\";\nimport { parse } from \"./pipeline\";\nimport {\n\tfindAffectedMarkdowns,\n\tgetGitRoot,\n\tgetMarkdownPaths,\n\tgetPrettierPaths,\n} from \"./utils\";\n\nexport async function run() {\n\tconst args = await parseArgs();\n\tconst config: Config = (await loadConfig(args)) || {};\n\n\tINFO(\"Loaded the following configuration:\", config);\n\n\tconst root = getGitRoot();\n\n\tconst isAffected = args.changes && \"affected\";\n\n\tINFO(`Loading ${!isAffected ? \"all \" : \"affected \"}files`);\n\n\tconst paths = isAffected\n\t\t? findAffectedMarkdowns(root, config)\n\t\t: await getMarkdownPaths(root, config);\n\n\tINFO(\"Loaded the following files:\", paths.join(\"\\n\"));\n\n\tconst type = args.onlyReadmes ? \"readmes\" : \"all markdown files\";\n\n\tif (!paths.length) {\n\t\treturn ERROR(`no ${isAffected} readmes found to update`);\n\t}\n\n\tconst spinner = !args.verbose && ora(`Updating ${type}`).start();\n\n\tawait Promise.all(\n\t\tpaths.map(async (path) => {\n\t\t\tconst file = await fsp.readFile(path, { encoding: \"utf8\" });\n\t\t\t// get rid of ast via garbage collector faster\n\t\t\tconst actions = (() => {\n\t\t\t\tconst ast = fromMarkdown(file);\n\t\t\t\treturn loadAstComments(ast);\n\t\t\t})();\n\n\t\t\tif (!actions.length) {\n\t\t\t\tWARN(`no action comments found in`, path);\n\t\t\t\tif (!config.enableUsage || !config.enableToc) {\n\t\t\t\t\treturn ERROR(\"no action or plugins found\");\n\t\t\t\t} else {\n\t\t\t\t\tINFO(\"plugins enabled. continuing parsing\", path);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst data = await loadActionData(actions, path, root);\n\n\t\t\tINFO(\"Loaded comment action data\", data);\n\n\t\t\tconst content = await parse(file, path, root, config, data);\n\t\t\tawait fsp.writeFile(path, content);\n\t\t}),\n\t);\n\n\tconst opts: cp.CommonExecOptions = { stdio: \"inherit\" };\n\n\tif (config.enablePrettier) {\n\t\tINFO(\"formatting with prettier\");\n\n\t\tconst prettierPaths = await getPrettierPaths(paths);\n\t\tcp.execFileSync(\"prettier\", [\"--write\", ...prettierPaths], opts);\n\t}\n\n\tif (isAffected) {\n\t\tINFO(\"adding affected files to git stage\");\n\n\t\tcp.execFileSync(\"git\", [\"add\", ...paths], opts);\n\t}\n\n\tif (spinner) spinner.stop();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,gBAAgBA,MAC3B,KAAK;CAAC;CAAU;CAAO;CAAS;CAAa;CAAM,CAAC,CACpD,SAAS,yBAAyB;AAEpC,MAAa,gBAAgBA,MAC3B,KAA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