@stephansama/auto-readme 0.2.12 → 0.3.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.
- package/README.md +44 -24
- package/dist/cli.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{schema-CwCoMxkG.mjs → schema-Cw1sPIP7.mjs} +23 -3
- package/dist/schema.d.mts +37 -2
- package/dist/schema.json +1 -1
- package/dist/schema.mjs +2 -2
- package/dist/{src-BAFdTzfP.mjs → src-DdK6szTm.mjs} +142 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -2,15 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
# [`@stephansama`](https://github.com/stephansama) / auto-readme
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<!-- BADGE start -->
|
|
6
6
|
|
|
7
|
-
[](https://jsr.io/@stephansama/auto-readme)
|
|
7
|
+
[](https://github.com/stephansama/packages/tree/main/core/auto-readme)
|
|
8
|
+
[](https://packages.stephansama.info/api/@stephansama/auto-readme)
|
|
9
|
+
[](https://www.npmx.dev/package/@stephansama/auto-readme)
|
|
11
10
|
[](https://socket.dev/npm/package/@stephansama/auto-readme/overview)
|
|
11
|
+
[](https://jsr.io/@stephansama/auto-readme)
|
|
12
12
|
[](https://www.npmx.dev/package/@stephansama/auto-readme)
|
|
13
13
|
|
|
14
|
+
[](https://npmx.dev/package/handlebars)
|
|
15
|
+
[](https://npmx.dev/package/remark)
|
|
16
|
+
[](https://npmx.dev/package/simple-icons)
|
|
17
|
+
[](https://npmx.dev/package/yaml)
|
|
18
|
+
[](https://npmx.dev/package/zod)
|
|
19
|
+
[](https://npmx.dev/package/@tanstack/intent)
|
|
20
|
+
[](https://npmx.dev/package/tsdown)
|
|
21
|
+
|
|
22
|
+
<!-- BADGE end -->
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
14
26
|
Generate lists and tables for your README automagically based on your repository
|
|
15
27
|
|
|
16
28
|
##### Table of contents
|
|
@@ -181,30 +193,38 @@ _Enum, one of the following possible values:_
|
|
|
181
193
|
- `'USAGE'`
|
|
182
194
|
- `'WORKSPACE'`
|
|
183
195
|
- `'ZOD'`
|
|
196
|
+
- `'BADGE'`
|
|
197
|
+
|
|
198
|
+
## BadgeDependencyTypeOptions
|
|
199
|
+
|
|
200
|
+
_Array of `'dependencies' | 'devDependencies' | 'peerDependencies' | 'optionalDependencies'` items._
|
|
201
|
+
|
|
202
|
+
_Default value:_ `["dependencies","devDependencies"]`
|
|
184
203
|
|
|
185
204
|
## Config
|
|
186
205
|
|
|
187
206
|
_Object containing the following properties:_
|
|
188
207
|
|
|
189
|
-
| Property | Description | Type
|
|
190
|
-
| :-------------------------- | :---------------------------------------------------------- |
|
|
191
|
-
| **`affectedRegexes`** (\*) | | `Array<string>`
|
|
192
|
-
|
|
|
193
|
-
|
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
198
|
-
| `
|
|
199
|
-
| `
|
|
200
|
-
| `
|
|
201
|
-
| `
|
|
202
|
-
| `
|
|
203
|
-
| `
|
|
204
|
-
| `
|
|
205
|
-
| `
|
|
206
|
-
| `
|
|
207
|
-
| `
|
|
208
|
+
| Property | Description | Type | Default |
|
|
209
|
+
| :-------------------------- | :---------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
210
|
+
| **`affectedRegexes`** (\*) | | `Array<string>` | |
|
|
211
|
+
| `badgeOptions` | | _Object with properties:_<ul><li>`dependencyTypes`: [BadgeDependencyTypeOptions](#badgedependencytypeoptions)</li><li>`templates`: _Array of objects:_<br /><ul><li>**`image`** (\*): `string`</li><li>**`label`** (\*): `string`</li><li>**`url`** (\*): `string`</li></ul> - handlebar template strings where {{scope}}, {{name}} / {{key}} and {{version}} / {{value}} represent the package</li></ul> | `{"dependencyTypes":["dependencies","devDependencies"],"templates":[]}` |
|
|
212
|
+
| **`collapseHeadings`** (\*) | | `Array<string>` | |
|
|
213
|
+
| `defaultLanguage` | Default language to infer projects from | [Language](#language) | |
|
|
214
|
+
| `disableEmojis` | Whether or not to use emojis in markdown table headings | `boolean` | `false` |
|
|
215
|
+
| `disableMarkdownHeadings` | Whether or not to display markdown headings | `boolean` | `false` |
|
|
216
|
+
| `enablePrettier` | Whether or not to use prettier to format the files | `boolean` | `true` |
|
|
217
|
+
| `enableToc` | generate table of contents for readmes | `boolean` | `false` |
|
|
218
|
+
| `enableUsage` | Whether or not to enable usage plugin | `boolean` | `false` |
|
|
219
|
+
| `headings` | List of headings for different table outputs | _Object with dynamic keys of type_ [Actions](#actions) _and values of type_ `Array<'default' \| 'description' \| 'devDependency' \| 'downloads' \| 'name' \| 'private' \| 'required' \| 'version'>` (_optional_) | `{"ACTION":["name","required","default","description"],"BADGE":[],"PKG":["name","version","devDependency"],"USAGE":[],"WORKSPACE":["name","version","downloads","description"],"ZOD":[]}` |
|
|
220
|
+
| `onlyReadmes` | Whether or not to only traverse readmes | `boolean` | `true` |
|
|
221
|
+
| `onlyShowPublicPackages` | Only show public packages in workspaces | `boolean` | `false` |
|
|
222
|
+
| `removeScope` | Remove common workspace scope | `string` | `''` |
|
|
223
|
+
| `templates` | Handlebars templates used to fuel list and table generation | _Object with properties:_<ul><li>`downloadImage`: `string`</li><li>`emojis`: `Record<'default' \| 'description' \| 'devDependency' \| 'downloads' \| 'name' \| 'private' \| 'required' \| 'version', string>` - Table heading emojis used when enabled</li><li>`registryUrl`: `string`</li><li>`versionImage`: `string`</li></ul> | `{"downloadImage":"https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F","emojis":{"default":"⚙️","description":"📝","devDependency":"💻","downloads":"📥","name":"🏷️","private":"🔒","required":"","version":""},"registryUrl":"https://www.npmx.dev/package/{{name}}","versionImage":"https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F"}` |
|
|
224
|
+
| `tocHeading` | Markdown heading used to generate table of contents | `string` | `'Table of contents'` |
|
|
225
|
+
| `usageFile` | Workspace level usage file | `string` | `''` |
|
|
226
|
+
| `usageHeading` | Markdown heading used to generate usage example | `string` | `'Usage'` |
|
|
227
|
+
| `verbose` | whether or not to display verbose logging | `boolean` | `false` |
|
|
208
228
|
|
|
209
229
|
_(\*) Required._ (_optional_)
|
|
210
230
|
|
package/dist/cli.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as run } from "./src-
|
|
1
|
+
import { t as run } from "./src-DdK6szTm.mjs";
|
|
2
2
|
export { run };
|
|
@@ -5,7 +5,8 @@ const actionsSchema = z.enum([
|
|
|
5
5
|
"PKG",
|
|
6
6
|
"USAGE",
|
|
7
7
|
"WORKSPACE",
|
|
8
|
-
"ZOD"
|
|
8
|
+
"ZOD",
|
|
9
|
+
"BADGE"
|
|
9
10
|
]).meta({ description: "Comment action options" });
|
|
10
11
|
const formatsSchema = z.enum(["LIST", "TABLE"]).default("TABLE");
|
|
11
12
|
const languageSchema = z.enum(["JS", "RS"]).default("JS");
|
|
@@ -26,6 +27,7 @@ const tableHeadingsSchema = z.record(actionsSchema, headingsSchema.array().optio
|
|
|
26
27
|
"default",
|
|
27
28
|
"description"
|
|
28
29
|
],
|
|
30
|
+
BADGE: [],
|
|
29
31
|
PKG: [
|
|
30
32
|
"name",
|
|
31
33
|
"version",
|
|
@@ -52,13 +54,31 @@ const templatesSchema = z.object({
|
|
|
52
54
|
required: "",
|
|
53
55
|
version: ""
|
|
54
56
|
}).meta({ description: "Table heading emojis used when enabled" }),
|
|
55
|
-
registryUrl: z.string().trim().default("https://www.
|
|
57
|
+
registryUrl: z.string().trim().default("https://www.npmx.dev/package/{{name}}"),
|
|
56
58
|
versionImage: z.string().trim().default("https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F")
|
|
57
59
|
});
|
|
58
60
|
const defaultTemplates = templatesSchema.parse({});
|
|
59
61
|
const defaultTableHeadings = tableHeadingsSchema.parse(void 0);
|
|
62
|
+
const badgeDependencyTypeOptionsSchema = z.array(z.enum([
|
|
63
|
+
"dependencies",
|
|
64
|
+
"devDependencies",
|
|
65
|
+
"peerDependencies",
|
|
66
|
+
"optionalDependencies"
|
|
67
|
+
])).default(["dependencies", "devDependencies"]);
|
|
68
|
+
const badgeTemplateSchema = z.array(z.object({
|
|
69
|
+
image: z.string().trim(),
|
|
70
|
+
label: z.string().trim(),
|
|
71
|
+
url: z.string().trim()
|
|
72
|
+
})).default([]).meta({ description: "handlebar template strings where {{scope}}, {{name}} / {{key}} and {{version}} / {{value}} represent the package" });
|
|
60
73
|
const configSchema = z.object({
|
|
61
74
|
affectedRegexes: z.array(z.string().trim()),
|
|
75
|
+
badgeOptions: z.object({
|
|
76
|
+
dependencyTypes: badgeDependencyTypeOptionsSchema,
|
|
77
|
+
templates: badgeTemplateSchema
|
|
78
|
+
}).default({
|
|
79
|
+
dependencyTypes: badgeDependencyTypeOptionsSchema.parse(void 0),
|
|
80
|
+
templates: badgeTemplateSchema.parse(void 0)
|
|
81
|
+
}),
|
|
62
82
|
collapseHeadings: z.array(z.string().trim()),
|
|
63
83
|
defaultLanguage: languageSchema.meta({
|
|
64
84
|
alias: "l",
|
|
@@ -95,4 +115,4 @@ const configSchema = z.object({
|
|
|
95
115
|
})
|
|
96
116
|
}).optional();
|
|
97
117
|
//#endregion
|
|
98
|
-
export {
|
|
118
|
+
export { defaultTemplates as a, defaultTableHeadings as i, badgeDependencyTypeOptionsSchema as n, formatsSchema as o, configSchema as r, languageSchema as s, actionsSchema as t };
|
package/dist/schema.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ declare const actionsSchema: z.ZodEnum<{
|
|
|
7
7
|
USAGE: "USAGE";
|
|
8
8
|
WORKSPACE: "WORKSPACE";
|
|
9
9
|
ZOD: "ZOD";
|
|
10
|
+
BADGE: "BADGE";
|
|
10
11
|
}>;
|
|
11
12
|
declare const formatsSchema: z.ZodDefault<z.ZodEnum<{
|
|
12
13
|
LIST: "LIST";
|
|
@@ -22,9 +23,28 @@ declare const defaultTemplates: {
|
|
|
22
23
|
registryUrl: string;
|
|
23
24
|
versionImage: string;
|
|
24
25
|
};
|
|
25
|
-
declare const defaultTableHeadings: Record<"ACTION" | "PKG" | "USAGE" | "WORKSPACE" | "ZOD", ("description" | "default" | "devDependency" | "downloads" | "name" | "private" | "required" | "version")[] | undefined>;
|
|
26
|
+
declare const defaultTableHeadings: Record<"ACTION" | "PKG" | "USAGE" | "WORKSPACE" | "ZOD" | "BADGE", ("description" | "default" | "devDependency" | "downloads" | "name" | "private" | "required" | "version")[] | undefined>;
|
|
27
|
+
declare const badgeDependencyTypeOptionsSchema: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
28
|
+
dependencies: "dependencies";
|
|
29
|
+
devDependencies: "devDependencies";
|
|
30
|
+
peerDependencies: "peerDependencies";
|
|
31
|
+
optionalDependencies: "optionalDependencies";
|
|
32
|
+
}>>>;
|
|
26
33
|
declare const _configSchema: z.ZodObject<{
|
|
27
34
|
affectedRegexes: z.ZodArray<z.ZodString>;
|
|
35
|
+
badgeOptions: z.ZodDefault<z.ZodObject<{
|
|
36
|
+
dependencyTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
37
|
+
dependencies: "dependencies";
|
|
38
|
+
devDependencies: "devDependencies";
|
|
39
|
+
peerDependencies: "peerDependencies";
|
|
40
|
+
optionalDependencies: "optionalDependencies";
|
|
41
|
+
}>>>;
|
|
42
|
+
templates: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
43
|
+
image: z.ZodString;
|
|
44
|
+
label: z.ZodString;
|
|
45
|
+
url: z.ZodString;
|
|
46
|
+
}, z.core.$strip>>>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
28
48
|
collapseHeadings: z.ZodArray<z.ZodString>;
|
|
29
49
|
defaultLanguage: z.ZodDefault<z.ZodEnum<{
|
|
30
50
|
JS: "JS";
|
|
@@ -41,6 +61,7 @@ declare const _configSchema: z.ZodObject<{
|
|
|
41
61
|
USAGE: "USAGE";
|
|
42
62
|
WORKSPACE: "WORKSPACE";
|
|
43
63
|
ZOD: "ZOD";
|
|
64
|
+
BADGE: "BADGE";
|
|
44
65
|
}>, z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
45
66
|
description: "description";
|
|
46
67
|
default: "default";
|
|
@@ -76,6 +97,19 @@ declare const _configSchema: z.ZodObject<{
|
|
|
76
97
|
}, z.core.$strip>;
|
|
77
98
|
declare const configSchema: z.ZodOptional<z.ZodObject<{
|
|
78
99
|
affectedRegexes: z.ZodArray<z.ZodString>;
|
|
100
|
+
badgeOptions: z.ZodDefault<z.ZodObject<{
|
|
101
|
+
dependencyTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
102
|
+
dependencies: "dependencies";
|
|
103
|
+
devDependencies: "devDependencies";
|
|
104
|
+
peerDependencies: "peerDependencies";
|
|
105
|
+
optionalDependencies: "optionalDependencies";
|
|
106
|
+
}>>>;
|
|
107
|
+
templates: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
108
|
+
image: z.ZodString;
|
|
109
|
+
label: z.ZodString;
|
|
110
|
+
url: z.ZodString;
|
|
111
|
+
}, z.core.$strip>>>;
|
|
112
|
+
}, z.core.$strip>>;
|
|
79
113
|
collapseHeadings: z.ZodArray<z.ZodString>;
|
|
80
114
|
defaultLanguage: z.ZodDefault<z.ZodEnum<{
|
|
81
115
|
JS: "JS";
|
|
@@ -92,6 +126,7 @@ declare const configSchema: z.ZodOptional<z.ZodObject<{
|
|
|
92
126
|
USAGE: "USAGE";
|
|
93
127
|
WORKSPACE: "WORKSPACE";
|
|
94
128
|
ZOD: "ZOD";
|
|
129
|
+
BADGE: "BADGE";
|
|
95
130
|
}>, z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
96
131
|
description: "description";
|
|
97
132
|
default: "default";
|
|
@@ -127,4 +162,4 @@ declare const configSchema: z.ZodOptional<z.ZodObject<{
|
|
|
127
162
|
}, z.core.$strip>>;
|
|
128
163
|
type Config = Partial<z.infer<typeof _configSchema>>;
|
|
129
164
|
//#endregion
|
|
130
|
-
export { Config, actionsSchema, configSchema, defaultTableHeadings, defaultTemplates, formatsSchema, languageSchema };
|
|
165
|
+
export { Config, actionsSchema, badgeDependencyTypeOptionsSchema, configSchema, defaultTableHeadings, defaultTemplates, formatsSchema, languageSchema };
|
package/dist/schema.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"affectedRegexes":{"type":"array","items":{"type":"string"}},"collapseHeadings":{"type":"array","items":{"type":"string"}},"defaultLanguage":{"alias":"l","description":"Default language to infer projects from","default":"JS","type":"string","enum":["JS","RS"]},"disableEmojis":{"alias":"e","description":"Whether or not to use emojis in markdown table headings","default":false,"type":"boolean"},"disableMarkdownHeadings":{"description":"Whether or not to display markdown headings","default":false,"type":"boolean"},"enablePrettier":{"description":"Whether or not to use prettier to format the files","default":true,"type":"boolean"},"enableToc":{"alias":"t","description":"generate table of contents for readmes","default":false,"type":"boolean"},"enableUsage":{"description":"Whether or not to enable usage plugin","default":false,"type":"boolean"},"headings":{"description":"List of headings for different table outputs","default":{"ACTION":["name","required","default","description"],"PKG":["name","version","devDependency"],"USAGE":[],"WORKSPACE":["name","version","downloads","description"],"ZOD":[]},"type":"object","propertyNames":{"description":"Comment action options","type":"string","enum":["ACTION","PKG","USAGE","WORKSPACE","ZOD"]},"additionalProperties":{"type":"array","items":{"description":"Table heading options","type":"string","enum":["default","description","devDependency","downloads","name","private","required","version"]}}},"onlyReadmes":{"alias":"r","description":"Whether or not to only traverse readmes","default":true,"type":"boolean"},"onlyShowPublicPackages":{"alias":"p","description":"Only show public packages in workspaces","default":false,"type":"boolean"},"removeScope":{"description":"Remove common workspace scope","default":"","type":"string"},"templates":{"description":"Handlebars templates used to fuel list and table generation","default":{"downloadImage":"https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F","emojis":{"default":"⚙️","description":"📝","devDependency":"💻","downloads":"📥","name":"🏷️","private":"🔒","required":"","version":""},"registryUrl":"https://www.
|
|
1
|
+
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"affectedRegexes":{"type":"array","items":{"type":"string"}},"badgeOptions":{"default":{"dependencyTypes":["dependencies","devDependencies"],"templates":[]},"type":"object","properties":{"dependencyTypes":{"default":["dependencies","devDependencies"],"type":"array","items":{"type":"string","enum":["dependencies","devDependencies","peerDependencies","optionalDependencies"]}},"templates":{"description":"handlebar template strings where {{scope}}, {{name}} / {{key}} and {{version}} / {{value}} represent the package","default":[],"type":"array","items":{"type":"object","properties":{"image":{"type":"string"},"label":{"type":"string"},"url":{"type":"string"}},"required":["image","label","url"],"additionalProperties":false}}},"required":["dependencyTypes","templates"],"additionalProperties":false},"collapseHeadings":{"type":"array","items":{"type":"string"}},"defaultLanguage":{"alias":"l","description":"Default language to infer projects from","default":"JS","type":"string","enum":["JS","RS"]},"disableEmojis":{"alias":"e","description":"Whether or not to use emojis in markdown table headings","default":false,"type":"boolean"},"disableMarkdownHeadings":{"description":"Whether or not to display markdown headings","default":false,"type":"boolean"},"enablePrettier":{"description":"Whether or not to use prettier to format the files","default":true,"type":"boolean"},"enableToc":{"alias":"t","description":"generate table of contents for readmes","default":false,"type":"boolean"},"enableUsage":{"description":"Whether or not to enable usage plugin","default":false,"type":"boolean"},"headings":{"description":"List of headings for different table outputs","default":{"ACTION":["name","required","default","description"],"BADGE":[],"PKG":["name","version","devDependency"],"USAGE":[],"WORKSPACE":["name","version","downloads","description"],"ZOD":[]},"type":"object","propertyNames":{"description":"Comment action options","type":"string","enum":["ACTION","PKG","USAGE","WORKSPACE","ZOD","BADGE"]},"additionalProperties":{"type":"array","items":{"description":"Table heading options","type":"string","enum":["default","description","devDependency","downloads","name","private","required","version"]}}},"onlyReadmes":{"alias":"r","description":"Whether or not to only traverse readmes","default":true,"type":"boolean"},"onlyShowPublicPackages":{"alias":"p","description":"Only show public packages in workspaces","default":false,"type":"boolean"},"removeScope":{"description":"Remove common workspace scope","default":"","type":"string"},"templates":{"description":"Handlebars templates used to fuel list and table generation","default":{"downloadImage":"https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F","emojis":{"default":"⚙️","description":"📝","devDependency":"💻","downloads":"📥","name":"🏷️","private":"🔒","required":"","version":""},"registryUrl":"https://www.npmx.dev/package/{{name}}","versionImage":"https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F"},"type":"object","properties":{"downloadImage":{"default":"https://img.shields.io/npm/dw/{{name}}?labelColor=211F1F","type":"string"},"emojis":{"description":"Table heading emojis used when enabled","default":{"default":"⚙️","description":"📝","devDependency":"💻","downloads":"📥","name":"🏷️","private":"🔒","required":"","version":""},"type":"object","propertyNames":{"description":"Table heading options","type":"string","enum":["default","description","devDependency","downloads","name","private","required","version"]},"additionalProperties":{"type":"string"}},"registryUrl":{"default":"https://www.npmx.dev/package/{{name}}","type":"string"},"versionImage":{"default":"https://img.shields.io/npm/v/{{uri_name}}?logo=npm&logoColor=red&color=211F1F&labelColor=211F1F","type":"string"}},"required":["downloadImage","emojis","registryUrl","versionImage"],"additionalProperties":false},"tocHeading":{"description":"Markdown heading used to generate table of contents","default":"Table of contents","type":"string"},"usageFile":{"description":"Workspace level usage file","default":"","type":"string"},"usageHeading":{"description":"Markdown heading used to generate usage example","default":"Usage","type":"string"},"verbose":{"alias":"v","description":"whether or not to display verbose logging","default":false,"type":"boolean"}},"required":["affectedRegexes","badgeOptions","collapseHeadings","defaultLanguage","disableEmojis","disableMarkdownHeadings","enablePrettier","enableToc","enableUsage","headings","onlyReadmes","onlyShowPublicPackages","removeScope","templates","tocHeading","usageFile","usageHeading","verbose"],"additionalProperties":false}
|
package/dist/schema.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { actionsSchema, configSchema, defaultTableHeadings, defaultTemplates, formatsSchema, languageSchema };
|
|
1
|
+
import { a as defaultTemplates, i as defaultTableHeadings, n as badgeDependencyTypeOptionsSchema, o as formatsSchema, r as configSchema, s as languageSchema, t as actionsSchema } from "./schema-Cw1sPIP7.mjs";
|
|
2
|
+
export { actionsSchema, badgeDependencyTypeOptionsSchema, configSchema, defaultTableHeadings, defaultTemplates, formatsSchema, languageSchema };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as defaultTemplates, i as defaultTableHeadings, o as formatsSchema, r as configSchema, s as languageSchema, t as actionsSchema } from "./schema-Cw1sPIP7.mjs";
|
|
2
2
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
3
3
|
import * as cp from "node:child_process";
|
|
4
4
|
import * as fsp from "node:fs/promises";
|
|
@@ -17,6 +17,7 @@ import path from "node:path";
|
|
|
17
17
|
import { readPackageJSON } from "pkg-types";
|
|
18
18
|
import * as yaml from "yaml";
|
|
19
19
|
import { zod2md } from "zod2md";
|
|
20
|
+
import { findRoot } from "@manypkg/find-root";
|
|
20
21
|
import { glob } from "tinyglobby";
|
|
21
22
|
import { remark } from "remark";
|
|
22
23
|
import remarkCodeImport from "remark-code-import";
|
|
@@ -27,6 +28,9 @@ import { VFile } from "vfile";
|
|
|
27
28
|
import Handlebars from "handlebars";
|
|
28
29
|
import { markdownTable } from "markdown-table";
|
|
29
30
|
import { zone } from "mdast-zone";
|
|
31
|
+
import { colord, extend } from "colord";
|
|
32
|
+
import a11yPlugin from "colord/plugins/a11y";
|
|
33
|
+
import * as icons from "simple-icons";
|
|
30
34
|
//#region src/arguments.ts
|
|
31
35
|
const complexOptions = [
|
|
32
36
|
"affectedRegexes",
|
|
@@ -219,6 +223,36 @@ async function getPrettierPaths(paths) {
|
|
|
219
223
|
return path.join(path.dirname(file), symlink);
|
|
220
224
|
}));
|
|
221
225
|
}
|
|
226
|
+
async function loadCatalogs() {
|
|
227
|
+
const { rootDir } = await findRoot(process.cwd());
|
|
228
|
+
const pnpmWorkspacePath = path.join(rootDir, "pnpm-workspace.yaml");
|
|
229
|
+
if (fs.existsSync(pnpmWorkspacePath)) {
|
|
230
|
+
const file = await fs.promises.readFile(pnpmWorkspacePath, "utf8");
|
|
231
|
+
const parsed = yaml.parse(file);
|
|
232
|
+
return {
|
|
233
|
+
catalogs: parsed.catalogs,
|
|
234
|
+
default: parsed.catalog
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const rootJsonPath = path.join(rootDir, "package.json");
|
|
238
|
+
const rootJsonFile = await fs.promises.readFile(rootJsonPath, "utf8");
|
|
239
|
+
const rootPackageJson = JSON.parse(rootJsonFile);
|
|
240
|
+
return {
|
|
241
|
+
catalogs: rootPackageJson?.workspaces?.catalogs,
|
|
242
|
+
default: rootPackageJson?.workspaces?.catalog
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function resolveVersion({ catalogs, name, version }) {
|
|
246
|
+
if (!version.startsWith("catalog:")) return version;
|
|
247
|
+
if (!version.endsWith(":")) {
|
|
248
|
+
const catalogName = version.split(":").at(-1);
|
|
249
|
+
const pulled = catalogs?.catalogs?.[catalogName]?.[name];
|
|
250
|
+
if (pulled) return pulled;
|
|
251
|
+
}
|
|
252
|
+
const defaultVersion = catalogs?.default?.[name];
|
|
253
|
+
if (defaultVersion) return defaultVersion;
|
|
254
|
+
return version;
|
|
255
|
+
}
|
|
222
256
|
function findNearestReadme(gitRoot, inputFile, maxRotations = 15) {
|
|
223
257
|
let dirname = path.dirname(inputFile);
|
|
224
258
|
let rotations = 0;
|
|
@@ -250,11 +284,14 @@ async function loadActionData(actions, file, root) {
|
|
|
250
284
|
parameters: action.parameters
|
|
251
285
|
};
|
|
252
286
|
}
|
|
287
|
+
case "BADGE":
|
|
253
288
|
case "PKG": {
|
|
254
289
|
const inputPath = find("path");
|
|
255
290
|
const pkgJson = await readPackageJSON(inputPath ? path.resolve(path.dirname(file), inputPath) : path.dirname(file));
|
|
291
|
+
const catalogs = await loadCatalogs();
|
|
256
292
|
return {
|
|
257
293
|
action: action.action,
|
|
294
|
+
catalogs,
|
|
258
295
|
parameters: action.parameters,
|
|
259
296
|
pkgJson
|
|
260
297
|
};
|
|
@@ -308,6 +345,66 @@ async function loadActionYaml(baseDirectory) {
|
|
|
308
345
|
return yaml.parse(actionFile);
|
|
309
346
|
}
|
|
310
347
|
//#endregion
|
|
348
|
+
//#region src/color.ts
|
|
349
|
+
extend([a11yPlugin]);
|
|
350
|
+
function getContrastText(color) {
|
|
351
|
+
return colord(color).contrast("#ffffff") > colord(color).contrast("#000000") ? "ffffff" : "000000";
|
|
352
|
+
}
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/icon.ts
|
|
355
|
+
const colorMapOverride = {
|
|
356
|
+
"@tanstack/ai": "#f6339a",
|
|
357
|
+
"@tanstack/devtools": "#62748e",
|
|
358
|
+
"@tanstack/hotkeys": "#ec003f",
|
|
359
|
+
"@tanstack/intent": "#00a6f4",
|
|
360
|
+
"@tanstack/start": "#00b8db",
|
|
361
|
+
"@tanstack/table-core": "#2b7fff",
|
|
362
|
+
"@tanstack/virtual": "#ad46ff",
|
|
363
|
+
"handlebars": "#d46926",
|
|
364
|
+
"tsdown": "#3178C6"
|
|
365
|
+
};
|
|
366
|
+
const alternateNames = {
|
|
367
|
+
"@commitlint/cli": "commitlint",
|
|
368
|
+
"@dotenvx/dotenvx": "dotenv",
|
|
369
|
+
"@iconify/types": "iconify",
|
|
370
|
+
"@tanstack/intent": "tanstack",
|
|
371
|
+
"ai": "vercel",
|
|
372
|
+
"alfy": "alfred",
|
|
373
|
+
"c#": "sharp",
|
|
374
|
+
"dockerfile": "docker",
|
|
375
|
+
"handlebars": "handlebarsdotjs",
|
|
376
|
+
"html": "html5",
|
|
377
|
+
"java": "oracle",
|
|
378
|
+
"jupyter notebook": "jupyter",
|
|
379
|
+
"liquid": "shopify",
|
|
380
|
+
"makefile": "cmake",
|
|
381
|
+
"next": "nextdotjs",
|
|
382
|
+
"nuxt": "nuxtdotjs",
|
|
383
|
+
"oxc-parser": "oxc",
|
|
384
|
+
"scss": "sass",
|
|
385
|
+
"tsdown": "rolldown",
|
|
386
|
+
"turbo": "turborepo",
|
|
387
|
+
"vue": "vuedotjs"
|
|
388
|
+
};
|
|
389
|
+
function createSlugName(iconName) {
|
|
390
|
+
iconName = iconName.toLowerCase();
|
|
391
|
+
if (isAlternateName(iconName)) return alternateNames[iconName];
|
|
392
|
+
return iconName.replaceAll("+", "plus").replaceAll("#", "sharp").replaceAll("-", "");
|
|
393
|
+
}
|
|
394
|
+
function getSimpleIconColor(name) {
|
|
395
|
+
INFO(`checking ${name} for simple icon color`);
|
|
396
|
+
const slug = createSlugName(name);
|
|
397
|
+
const colorOverride = colorMapOverride[name]?.replace("#", "");
|
|
398
|
+
if (colorOverride) return [colorOverride, slug];
|
|
399
|
+
return [icons[`si${capitalize(slug.split("-").map((word) => capitalize(word)).join(""))}`]?.hex.replace("#", ""), slug];
|
|
400
|
+
}
|
|
401
|
+
function capitalize(word) {
|
|
402
|
+
return word.at(0)?.toUpperCase() + word.slice(1);
|
|
403
|
+
}
|
|
404
|
+
function isAlternateName(name) {
|
|
405
|
+
return typeof name === "string" && name in alternateNames;
|
|
406
|
+
}
|
|
407
|
+
//#endregion
|
|
311
408
|
//#region src/plugin.ts
|
|
312
409
|
function createHeading(headings, disableEmojis = false, emojis = defaultTemplates.emojis) {
|
|
313
410
|
return headings.map((h) => `${disableEmojis ? "" : emojis[h] + " "}${h?.at(0)?.toUpperCase() + h?.slice(1)}`);
|
|
@@ -326,6 +423,50 @@ const autoReadmeRemarkPlugin = (config, data) => (tree) => {
|
|
|
326
423
|
end
|
|
327
424
|
];
|
|
328
425
|
});
|
|
426
|
+
zone(tree, /.*BADGE.*/gi, function(start, _, end) {
|
|
427
|
+
const first = data.find((d) => d?.action === "BADGE");
|
|
428
|
+
const dependencyTypes = config.badgeOptions?.dependencyTypes || ["dependencies", "devDependencies"];
|
|
429
|
+
const allDependencies = Object.assign({}, ...dependencyTypes.map((dependencyType) => first?.pkgJson?.[dependencyType] || {}));
|
|
430
|
+
const templateBadges = !first?.parameters.includes(`--skip-templates`) && config.badgeOptions?.templates.map((template) => {
|
|
431
|
+
const compiledImage = Handlebars.compile(template.image);
|
|
432
|
+
const compiledUrl = Handlebars.compile(template.url);
|
|
433
|
+
const name = first?.pkgJson?.name || "";
|
|
434
|
+
const version = first?.pkgJson?.version;
|
|
435
|
+
const scope = first?.pkgJson?.name?.includes("@") && first.pkgJson.name.split("/").at(0) || "";
|
|
436
|
+
const context = {
|
|
437
|
+
escaped_name: encodeURIComponent(name),
|
|
438
|
+
key: name,
|
|
439
|
+
name,
|
|
440
|
+
scope,
|
|
441
|
+
unscoped_name: name?.replace(`${scope}/`, ""),
|
|
442
|
+
value: version,
|
|
443
|
+
version
|
|
444
|
+
};
|
|
445
|
+
const image = compiledImage(context);
|
|
446
|
+
const url = compiledUrl(context);
|
|
447
|
+
return `[](${url})`;
|
|
448
|
+
}) || [];
|
|
449
|
+
const packageBadges = new Array();
|
|
450
|
+
const md = String.raw;
|
|
451
|
+
INFO(JSON.stringify(allDependencies, void 0, 2));
|
|
452
|
+
for (const [key, version] of Object.entries(allDependencies)) {
|
|
453
|
+
const [color, slug] = getSimpleIconColor(key);
|
|
454
|
+
if (!color) continue;
|
|
455
|
+
const contrastText = getContrastText(color);
|
|
456
|
+
const linkUrl = `https://npmx.dev/package/${key}`;
|
|
457
|
+
const imageUrl = `https://img.shields.io/badge/${key.replaceAll("-", "--").replaceAll("_", "__")}-${resolveVersion({
|
|
458
|
+
catalogs: first?.catalogs,
|
|
459
|
+
name: key,
|
|
460
|
+
version
|
|
461
|
+
})}-${color}.svg?logo=${slug}&logoColor=${contrastText}&labelColor=${color}`;
|
|
462
|
+
packageBadges.push(md`[](${linkUrl})`);
|
|
463
|
+
}
|
|
464
|
+
return [
|
|
465
|
+
start,
|
|
466
|
+
fromMarkdown([templateBadges.filter(Boolean).join("\n"), packageBadges.filter(Boolean).join("\n")].join("\n\n")),
|
|
467
|
+
end
|
|
468
|
+
];
|
|
469
|
+
});
|
|
329
470
|
zone(tree, /.*ACTION.*/gi, function(start, _, end) {
|
|
330
471
|
const value = start.type === "html" && start.value;
|
|
331
472
|
const options = value && parseComment(value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stephansama/auto-readme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Generate lists and tables for your README automagically based on your repository and comments",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auto",
|
|
@@ -41,26 +41,31 @@
|
|
|
41
41
|
"auto-readme": "./dist/cli.mjs"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
|
-
"
|
|
44
|
+
"dist",
|
|
45
45
|
"skills"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
+
"@manypkg/find-root": "3.1.0",
|
|
48
49
|
"@manypkg/get-packages": "3.1.0",
|
|
50
|
+
"colord": "2.9.3",
|
|
49
51
|
"cosmiconfig": "9.0.0",
|
|
50
52
|
"deepmerge": "4.3.1",
|
|
51
53
|
"handlebars": "4.7.9",
|
|
54
|
+
"local-pkg": "1.1.2",
|
|
52
55
|
"markdown-table": "3.0.4",
|
|
53
56
|
"mdast": "3.0.0",
|
|
54
57
|
"mdast-comment-marker": "3.0.0",
|
|
55
58
|
"mdast-util-from-markdown": "2.0.2",
|
|
56
59
|
"mdast-zone": "github:stephansama/mdast-zone#1c5b08cd97240debeed4c9c6afad49df5877a132",
|
|
57
60
|
"obug": "2.1.1",
|
|
61
|
+
"picospinner": "3.0.0",
|
|
58
62
|
"pkg-types": "2.3.0",
|
|
59
63
|
"remark": "15.0.1",
|
|
60
64
|
"remark-code-import": "1.2.0",
|
|
61
65
|
"remark-collapse": "0.1.2",
|
|
62
66
|
"remark-toc": "9.0.0",
|
|
63
67
|
"remark-usage": "11.0.1",
|
|
68
|
+
"simple-icons": "16.19.0",
|
|
64
69
|
"smol-toml": "1.6.1",
|
|
65
70
|
"tinyglobby": "0.2.16",
|
|
66
71
|
"vfile": "6.0.3",
|
|
@@ -74,7 +79,6 @@
|
|
|
74
79
|
"@types/mdast": "4.0.4",
|
|
75
80
|
"@types/vfile": "4.0.0",
|
|
76
81
|
"@types/yargs": "17.0.35",
|
|
77
|
-
"picospinner": "3.0.0",
|
|
78
82
|
"tsdown": "0.21.10",
|
|
79
83
|
"unified": "11.0.5"
|
|
80
84
|
},
|
|
@@ -88,6 +92,7 @@
|
|
|
88
92
|
"scripts": {
|
|
89
93
|
"build": "tsdown",
|
|
90
94
|
"postbuild": "publint",
|
|
95
|
+
"build:snapshot": "tsdown -u",
|
|
91
96
|
"dev": "tsdown --watch",
|
|
92
97
|
"lint": "eslint ./src/ --pass-on-no-patterns --no-error-on-unmatched-pattern",
|
|
93
98
|
"lint:fix": "eslint ./src/ --pass-on-no-patterns --no-error-on-unmatched-pattern --fix"
|