@powerlines/plugin-automd 0.1.341 → 0.1.342

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +14 -16
  2. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -3
  3. package/dist/_virtual/_rolldown/runtime.mjs +3 -0
  4. package/dist/index.cjs +26 -27
  5. package/dist/index.d.cts +0 -1
  6. package/dist/index.d.cts.map +1 -1
  7. package/dist/index.d.mts +0 -1
  8. package/dist/index.d.mts.map +1 -1
  9. package/dist/index.mjs +5 -6
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/types/plugin.d.cts.map +1 -1
  12. package/dist/types/plugin.d.mts +1 -1
  13. package/dist/types/plugin.d.mts.map +1 -1
  14. package/dist/types/toc.d.cts.map +1 -1
  15. package/dist/types/toc.d.mts.map +1 -1
  16. package/package.json +20 -18
  17. package/dist/_virtual/rolldown_runtime.mjs +0 -32
  18. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +0 -78
  19. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -78
  20. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +0 -1
  21. package/dist/node_modules/.pnpm/acorn@8.16.0/node_modules/acorn/dist/acorn.cjs +0 -5089
  22. package/dist/node_modules/.pnpm/acorn@8.16.0/node_modules/acorn/dist/acorn.mjs +0 -5089
  23. package/dist/node_modules/.pnpm/acorn@8.16.0/node_modules/acorn/dist/acorn.mjs.map +0 -1
  24. package/dist/node_modules/.pnpm/automd@0.4.3_patch_hash_5b5d5334735dce5e1ae79d8924a5aa49e4139453056613d618786b961793a42b_magicast@0.5.2/node_modules/automd/dist/index.cjs +0 -654
  25. package/dist/node_modules/.pnpm/automd@0.4.3_patch_hash_5b5d5334735dce5e1ae79d8924a5aa49e4139453056613d618786b961793a42b_magicast@0.5.2/node_modules/automd/dist/index.mjs +0 -652
  26. package/dist/node_modules/.pnpm/automd@0.4.3_patch_hash_5b5d5334735dce5e1ae79d8924a5aa49e4139453056613d618786b961793a42b_magicast@0.5.2/node_modules/automd/dist/index.mjs.map +0 -1
  27. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.cjs +0 -23
  28. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs +0 -23
  29. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs.map +0 -1
  30. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.cjs +0 -10
  31. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs +0 -11
  32. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs.map +0 -1
  33. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.cjs +0 -388
  34. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs +0 -388
  35. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs.map +0 -1
  36. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.cjs +0 -11
  37. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs +0 -12
  38. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs.map +0 -1
  39. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +0 -46
  40. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +0 -46
  41. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs.map +0 -1
  42. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.cjs +0 -204
  43. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.mjs +0 -203
  44. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.mjs.map +0 -1
  45. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +0 -1013
  46. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +0 -1008
  47. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs.map +0 -1
  48. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.cjs +0 -128
  49. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.mjs +0 -124
  50. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.mjs.map +0 -1
  51. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.cjs +0 -41464
  52. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.mjs +0 -41462
  53. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.mjs.map +0 -1
  54. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.cjs +0 -4387
  55. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.mjs +0 -4385
  56. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.mjs.map +0 -1
  57. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.cjs +0 -26
  58. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.mjs +0 -27
  59. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.mjs.map +0 -1
  60. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.cjs +0 -370
  61. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.mjs +0 -368
  62. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.mjs.map +0 -1
  63. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs +0 -939
  64. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +0 -940
  65. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs.map +0 -1
  66. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.cjs +0 -67
  67. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.mjs +0 -65
  68. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.mjs.map +0 -1
  69. package/dist/node_modules/.pnpm/mlly@1.8.1/node_modules/mlly/dist/index.cjs +0 -1350
  70. package/dist/node_modules/.pnpm/mlly@1.8.1/node_modules/mlly/dist/index.mjs +0 -1343
  71. package/dist/node_modules/.pnpm/mlly@1.8.1/node_modules/mlly/dist/index.mjs.map +0 -1
  72. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -179
  73. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -178
  74. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs.map +0 -1
  75. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +0 -20
  76. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +0 -17
  77. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs.map +0 -1
  78. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs +0 -3975
  79. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs +0 -3962
  80. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs.map +0 -1
  81. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.cjs +0 -16
  82. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +0 -15
  83. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs.map +0 -1
  84. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.cjs +0 -36
  85. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs +0 -34
  86. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs.map +0 -1
  87. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.cjs +0 -227
  88. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs +0 -226
  89. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs.map +0 -1
  90. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +0 -139
  91. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -134
  92. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs.map +0 -1
  93. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +0 -78
  94. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +0 -78
  95. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs.map +0 -1
  96. package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.cjs +0 -72
  97. package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs +0 -70
  98. package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs.map +0 -1
  99. package/dist/node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.cjs +0 -181
  100. package/dist/node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.mjs +0 -179
  101. package/dist/node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.mjs.map +0 -1
  102. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.cjs +0 -12337
  103. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.mjs +0 -12338
  104. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.mjs.map +0 -1
  105. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.cjs +0 -19
  106. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.mjs +0 -19
  107. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.mjs.map +0 -1
  108. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.cjs +0 -71
  109. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.mjs +0 -72
  110. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.mjs.map +0 -1
  111. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.cjs +0 -110
  112. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.mjs +0 -101
  113. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.mjs.map +0 -1
@@ -1,654 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
2
- const require_pathe_M_eThtNZ = require('../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs');
3
- const require_index = require('../../../../mlly@1.8.1/node_modules/mlly/dist/index.cjs');
4
- const require_magic_string_es = require('../../../../magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs');
5
- const require_index$1 = require('../../../../scule@1.3.0/node_modules/scule/dist/index.cjs');
6
- const require_index$2 = require('../../../../pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs');
7
- const require_index$3 = require('../../../../mdbox@0.1.1/node_modules/mdbox/dist/index.cjs');
8
- const require_index$4 = require('../../../../destr@2.0.5/node_modules/destr/dist/index.cjs');
9
- let node_fs = require("node:fs");
10
- let node_fs_promises = require("node:fs/promises");
11
- let defu = require("defu");
12
-
13
- //#region ../../node_modules/.pnpm/automd@0.4.3_patch_hash=5b5d5334735dce5e1ae79d8924a5aa49e4139453056613d618786b961793a42b_magicast@0.5.2/node_modules/automd/dist/index.mjs
14
- function defineGenerator(generator) {
15
- return generator;
16
- }
17
- function resolvePath$1(path, { url, dir }) {
18
- if (path.startsWith("/")) return require_pathe_M_eThtNZ.join(dir, path);
19
- return url ? require_index.fileURLToPath(new URL(path, url)) : require_pathe_M_eThtNZ.resolve(dir, path);
20
- }
21
- async function getPkg(dir, input = {}) {
22
- const pkg = await require_index$2.readPackageJSON(dir).catch(() => void 0);
23
- return (0, defu.defu)({
24
- name: input.name,
25
- version: typeof input.version === "string" ? input.version : void 0,
26
- github: input.github || input.gh
27
- }, {
28
- name: pkg?.name,
29
- version: pkg?.version,
30
- github: _getGitRepo(pkg?.repository)
31
- }, {
32
- name: process.env.npm_package_name,
33
- version: process.env.npm_package_version
34
- });
35
- }
36
- function _getGitRepo(repo) {
37
- const url = typeof repo === "string" ? repo : repo?.url;
38
- if (!url || typeof url !== "string") return;
39
- const match = /(?:https:\/\/github\.com\/|gh:|github:|)([\w-]+)\/([\w-]+)/.exec(url);
40
- if (match && match[1] && match[2]) return `${match[1]}/${match[2]}`;
41
- }
42
- const jsdocs = defineGenerator({
43
- name: "jsdocs",
44
- async generate({ config, args, url }) {
45
- const { loadSchema } = await Promise.resolve().then(() => require("../../../../untyped@2.0.0/node_modules/untyped/dist/loader/loader.cjs"));
46
- return { contents: _render(await loadSchema(resolvePath$1(args.src, {
47
- url,
48
- dir: config.dir
49
- }), { jiti: {
50
- fsCache: false,
51
- moduleCache: false
52
- } }), args, Number.parseInt(args.headingLevel) || 2).join("\n").replace(/\n{3,}/g, "\n\n") };
53
- }
54
- });
55
- function _render(schema, opts, headingLevel) {
56
- const sections = Object.create(null);
57
- for (const [key, keySchema] of Object.entries(schema.properties || {})) {
58
- const section = _renderSection(key, keySchema, opts, headingLevel + 1);
59
- if (!section) continue;
60
- sections[section.group] = sections[section.group] || [];
61
- sections[section.group].push([section.heading, section.lines]);
62
- }
63
- const lines = [];
64
- const sortedGroups = Object.keys(sections).sort((a, b) => {
65
- if (a === "") return 1;
66
- if (b === "") return -1;
67
- return a.localeCompare(b);
68
- });
69
- for (const group of sortedGroups) {
70
- if (group) lines.push(`\n${"#".repeat(headingLevel)} ${require_index$1.titleCase(group)}\n`);
71
- const sortedSections = sections[group].sort((a, b) => a[0].localeCompare(b[0]));
72
- for (const section of sortedSections) {
73
- const heading = `\n${"#".repeat(headingLevel + 1)} ${section[0]}\n`;
74
- lines.push(heading, ...section[1]);
75
- }
76
- }
77
- return lines;
78
- }
79
- function _renderSection(key, schema, opts, headingLevel) {
80
- const tags = _parseTags(schema.tags);
81
- if (tags.some((t) => t.tag === "@deprecated" || t.tag === "@internal")) return;
82
- const group = tags.find((t) => t.tag === "@group")?.contents || opts.defaultGroup || "";
83
- if (opts.group && (typeof opts.group === "string" ? group !== opts.group : !opts.group.includes(group))) return;
84
- let heading = `\`${key}\``;
85
- const lines = [];
86
- if (schema.type === "function") heading = `\`${_generateFunctionSig(key, schema)}\``;
87
- else if (schema.type !== "object") {
88
- lines.push(`- **Type**: \`${schema.markdownType || schema.tsType || schema.type}\``);
89
- if ("default" in schema) lines.push(`- **Default**: \`${JSON.stringify(schema.default)}\``);
90
- lines.push("");
91
- }
92
- lines.push(..._renderBody(schema));
93
- for (const tag of tags) if (tag.tag === "@example") {
94
- const codeBlock = tag.contents.startsWith("`") ? tag.contents : `\`\`\`ts\n${tag.contents}\n\`\`\``;
95
- lines.push("", "**Example:**", "", codeBlock);
96
- }
97
- if (schema.type === "object") lines.push(..._render(schema, opts, headingLevel));
98
- return {
99
- heading,
100
- lines,
101
- group
102
- };
103
- }
104
- function _renderBody(schema) {
105
- const lines = [];
106
- if (schema.title) lines.push(schema.title.trim());
107
- if (schema.title && schema.description) lines.push("");
108
- if (schema.description) lines.push(...schema.description.split("\n").map((line) => line.trim()).join("\n\n").split("\n"));
109
- return lines;
110
- }
111
- function _parseTags(lines = []) {
112
- const parsedTags = [];
113
- let tag = "";
114
- let contentLines = [];
115
- for (const line of lines.join("\n").split("\n")) if (line.startsWith("@")) {
116
- if (tag) parsedTags.push({
117
- tag,
118
- contents: contentLines.join("\n")
119
- });
120
- const [_tag, ...rest] = line.split(" ");
121
- tag = _tag;
122
- contentLines = rest;
123
- } else contentLines.push(line);
124
- if (tag) parsedTags.push({
125
- tag,
126
- contents: contentLines.join("\n")
127
- });
128
- return parsedTags;
129
- }
130
- function _generateFunctionSig(name, meta) {
131
- return `${name}(${(meta.args || []).map((arg) => {
132
- let str = arg.name;
133
- if (arg.optional) str += "?";
134
- const tsType = _simpleArgType(arg.tsType);
135
- if (tsType) str += `: ${tsType}`;
136
- return str;
137
- }).join(", ")})`;
138
- }
139
- function _simpleArgType(tsType = "") {
140
- return tsType.split(/\s*\|\s*/).filter((t) => t && t !== "object" && t.startsWith("{")).map((ot) => ot.split(/\s*[,;]\s*/g).map((p) => p.replaceAll(/\s*:\s*(string|boolean|number)/g, "")).join(", ")).join(" | ");
141
- }
142
- const badgeTypes = {
143
- npmVersion: {
144
- name: "npm version",
145
- to: "https://npmjs.com/package/{name}"
146
- },
147
- npmDownloads: {
148
- name: "npm downloads",
149
- to: "https://npm.chart.dev/{name}"
150
- },
151
- bundlephobia: {
152
- name: "bundle size",
153
- to: "https://bundlephobia.com/package/{name}"
154
- },
155
- bundlejs: {
156
- name: "bundle size",
157
- to: "https://bundlejs.com/?q={name}"
158
- },
159
- packagephobia: {
160
- name: "install size",
161
- to: "https://packagephobia.com/result?p={name}"
162
- },
163
- codecov: {
164
- name: "codecov",
165
- to: "https://codecov.io/gh/{github}"
166
- },
167
- license: {
168
- name: "license",
169
- to: "https://github.com/{github}/blob/{licenseBranch}/LICENSE"
170
- }
171
- };
172
- const badgeProviders = {
173
- shields: {
174
- npmVersion: "https://img.shields.io/npm/v/{name}",
175
- npmDownloads: "https://img.shields.io/npm/dm/{name}",
176
- bundlephobia: "https://img.shields.io/bundlephobia/minzip/{name}",
177
- packagephobia: "https://badgen.net/packagephobia/install/{name}",
178
- bundlejs: "https://img.shields.io/bundlejs/size/{name}",
179
- codecov: "https://img.shields.io/codecov/c/gh/{github}",
180
- license: "https://img.shields.io/github/license/{github}"
181
- },
182
- badgen: {
183
- npmVersion: "https://flat.badgen.net/npm/v/{name}",
184
- npmDownloads: "https://flat.badgen.net/npm/dm/{name}",
185
- bundlephobia: "https://flat.badgen.net/bundlephobia/minzip/{name}",
186
- bundlejs: false,
187
- packagephobia: "https://flat.badgen.net/packagephobia/install/{name}",
188
- codecov: "https://flat.badgen.net/codecov/c/github/{github}",
189
- license: "https://flat.badgen.net/github/license/{github}"
190
- },
191
- badgenClassic: {
192
- npmVersion: "https://badgen.net/npm/v/{name}",
193
- npmDownloads: "https://badgen.net/npm/dm/{name}",
194
- bundlephobia: "https://badgen.net/bundlephobia/minzip/{name}",
195
- bundlejs: false,
196
- packagephobia: "https://badgen.net/packagephobia/install/{name}",
197
- codecov: "https://badgen.net/codecov/c/github/{github}",
198
- license: "https://badgen.net/github/license/{github}"
199
- }
200
- };
201
- const badges = defineGenerator({
202
- name: "badges",
203
- async generate({ config, args }) {
204
- const pkg = await getPkg(config.dir, args);
205
- const ctx = {
206
- name: pkg.name,
207
- github: pkg.github,
208
- licenseBranch: "main",
209
- ...args
210
- };
211
- const fillStr = (str) => str.replace(/{(\w+)}/g, (_, key) => ctx[key] || "");
212
- const provider = badgeProviders[args.provider] || badgeProviders.shields;
213
- const providerParams = Object.entries({
214
- color: args.color,
215
- labelColor: args.labelColor,
216
- ...args.styleParams
217
- }).filter(([, value]) => value).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
218
- const badges$1 = {
219
- npmVersion: {
220
- enabled: ctx.name && args.npmVersion !== false,
221
- ...badgeTypes.npmVersion
222
- },
223
- npmDownloads: {
224
- enabled: ctx.name && args.npmDownloads !== false,
225
- ...badgeTypes.npmDownloads
226
- },
227
- bundlephobia: {
228
- enabled: args.bundlephobia && ctx.name,
229
- ...badgeTypes.bundlephobia
230
- },
231
- bundlejs: {
232
- enabled: args.bundlejs && ctx.name,
233
- ...badgeTypes.bundlejs
234
- },
235
- packagephobia: {
236
- enabled: args.packagephobia && ctx.name,
237
- ...badgeTypes.packagephobia
238
- },
239
- codecov: {
240
- enabled: args.codecov && ctx.github,
241
- ...badgeTypes.codecov
242
- },
243
- license: {
244
- enabled: args.license && ctx.github,
245
- ...badgeTypes.license
246
- }
247
- };
248
- const md = [];
249
- for (const [badgeType, badge] of Object.entries(badges$1)) {
250
- if (!badge.enabled || !provider[badgeType]) continue;
251
- const to = fillStr(badge.to);
252
- const imgURL = fillStr(provider[badgeType]) + (providerParams ? `?${providerParams}` : "");
253
- md.push(require_index$3.link(to, require_index$3.image(imgURL, badge.name)));
254
- }
255
- return { contents: md.join("\n") };
256
- }
257
- });
258
- const INSTALL_COMMANDS = [
259
- ["npm", "install"],
260
- ["yarn", "add"],
261
- ["pnpm", "add"],
262
- ["bun", "install"],
263
- [
264
- "deno",
265
- "install",
266
- " --dev",
267
- "npm:"
268
- ]
269
- ];
270
- const NYPM_COMMAND = ["npx nypm", "install"];
271
- const RUN_COMMANDS = [
272
- ["npm", "npx "],
273
- ["pnpm", "pnpm dlx "],
274
- ["bun", "bunx "],
275
- ["deno", "deno run -A npm:"]
276
- ];
277
- const pmInstall = defineGenerator({
278
- name: "pm-install",
279
- async generate({ config, args }) {
280
- const { name, version } = await getPkg(config.dir, args);
281
- if (!name) return { contents: "<!-- package name is unspecified -->" };
282
- let versionSuffix = "";
283
- if (args.version) versionSuffix = typeof args.version === "string" ? `@${args.version}` : `@^${version}`;
284
- const contents = (args.auto === false ? INSTALL_COMMANDS : [NYPM_COMMAND, ...INSTALL_COMMANDS]).map(([cmd, install, dev = " -D", pkgPrefix = ""]) => `# ${cmd.includes("nypm") ? "✨ Auto-detect" : cmd}\n${cmd} ${install}${args.dev ? dev : args.global ? "g" : ""} ${pkgPrefix}${name}${versionSuffix}`);
285
- if ((args.separate ?? false) === false) return { contents: require_index$3.render.codeBlock(contents.join("\n\n"), "sh") };
286
- return { contents: contents.map((cmd) => require_index$3.render.codeBlock(cmd, "sh")).join("\n\n") };
287
- }
288
- });
289
- const pmX = defineGenerator({
290
- name: "pm-x",
291
- async generate({ config, args }) {
292
- const { name, version } = await getPkg(config.dir, args);
293
- if (!name) return { contents: "<!-- package name is unspecified -->" };
294
- let versionSuffix = "";
295
- if (args.version) versionSuffix = typeof args.version === "string" ? `@${args.version}` : `@${version}`;
296
- const contents = RUN_COMMANDS.map(([pm, cmd]) => `# ${pm}\n${cmd}${name}${versionSuffix}${args.args ? ` ${args.args}` : ""}`);
297
- if ((args.separate ?? false) === false) return { contents: require_index$3.render.codeBlock(contents.join("\n\n"), "sh") };
298
- return { contents: contents.map((cmd) => require_index$3.render.codeBlock(cmd, "sh")).join("\n\n") };
299
- }
300
- });
301
- const fetch = defineGenerator({
302
- name: "fetch",
303
- async generate({ args }) {
304
- const { $fetch } = await Promise.resolve().then(() => require("../../../../ofetch@1.5.1/node_modules/ofetch/dist/node.cjs"));
305
- let url = args.url;
306
- if (!url) throw new Error("URL is required!");
307
- if (url.startsWith("gh:")) url = `https://raw.githubusercontent.com/${url.slice(3)}`;
308
- return { contents: await $fetch(url) };
309
- }
310
- });
311
- const DEFAULT_CDN = "https://esm.sh/";
312
- const jsimport = defineGenerator({
313
- name: "jsimport",
314
- async generate({ config, args }) {
315
- const { name } = await getPkg(config.dir, args);
316
- const importPath = name + (args.path || "");
317
- const importNames = [].concat(args.import, args.imports).filter(Boolean).flatMap((i) => i.split(/\s*,\s*/));
318
- if (args.src) {
319
- const exportNames = require_index.findExportNames(await (0, node_fs_promises.readFile)(await require_index.resolvePath(args.src, { url: config.dir }), "utf8"));
320
- if (exportNames && exportNames.length > 0) importNames.push(...exportNames);
321
- }
322
- const lines = [];
323
- const fmtImports = importNames.length > 1 ? `\n${importNames.map((i) => " " + i + ",").join("\n")}\n` : importNames[0] && ` ${importNames[0]} ` || "";
324
- const formatMultiLine = (str) => {
325
- return str.length > (args.printWidth || 80) ? str : str.replace(/\n/g, "").replace(/,\s*}/, "}").replace(/(\w)}/, "$1 }").replace(/\s+/g, " ");
326
- };
327
- if (args.esm !== false) {
328
- const code = formatMultiLine(`import {${fmtImports}} from "${importPath}";`);
329
- lines.push("**ESM** (Node.js, Bun, Deno)", require_index$3.render.codeBlock(code, "js"));
330
- }
331
- if (args.cjs) {
332
- const code = formatMultiLine(`const {${fmtImports}} = require("${importPath}");`);
333
- lines.push("**CommonJS** (Legacy Node.js)", require_index$3.render.codeBlock(code, "js"));
334
- }
335
- if (args.cdn) {
336
- const code = formatMultiLine(`import {${fmtImports}} from "${typeof args.cdn === "string" ? args.cdn : DEFAULT_CDN}${importPath}";`);
337
- lines.push("**CDN** (Deno and Browsers)", require_index$3.render.codeBlock(code, "js"));
338
- }
339
- return { contents: lines.join("\n\n") };
340
- }
341
- });
342
- const withAutomd = defineGenerator({
343
- name: "with-automd",
344
- generate({ args }) {
345
- const lastUpdate = args.lastUpdate ? ` (last updated: ${typeof args.lastUpdate === "string" ? args.lastUpdate : (/* @__PURE__ */ new Date()).toDateString()})` : "";
346
- const emoji = args.emoji === false ? "" : "🤖 ";
347
- const lines = [];
348
- if (args.separator !== false) lines.push("---", "");
349
- lines.push(`_${emoji}auto updated with [automd](https://automd.unjs.io)${lastUpdate}_`);
350
- return { contents: lines.join("\n") };
351
- }
352
- });
353
- const file = defineGenerator({
354
- name: "file",
355
- async generate({ args, config, url }) {
356
- const fullPath = resolvePath$1(args.src, {
357
- url,
358
- dir: config.dir
359
- });
360
- let contents = await (0, node_fs_promises.readFile)(fullPath, "utf8");
361
- if (!args.noTrim) contents = contents.trim();
362
- if (args.lines) {
363
- const groups = /^(?<startLine>\d+)?:(?<endLine>\d+)?$/.exec(args.lines)?.groups;
364
- if (!groups) throw new Error("invalid lines format");
365
- const lines = contents.split("\n");
366
- const startLine = Number(groups.startLine) || 1;
367
- const endLine = Number(groups.endLine) || lines.length;
368
- if (startLine < 1) throw new Error("first line's index can not be smaller than 1");
369
- contents = lines.slice(startLine - 1, endLine).join("\n");
370
- }
371
- if (args.code) contents = require_index$3.render.codeBlock(contents, args.lang || require_pathe_M_eThtNZ.extname(fullPath).slice(1), { ext: args.name === false ? void 0 : typeof args.name === "string" ? args.name : `[${require_pathe_M_eThtNZ.basename(fullPath)}]` });
372
- return { contents };
373
- }
374
- });
375
- const PROVIDERS = {
376
- CONTRIB_ROCKS: "contrib.rocks",
377
- MARKUPGO: "markupgo"
378
- };
379
- const contributors = defineGenerator({
380
- name: "contributors",
381
- async generate({ config, args }) {
382
- const { github } = await getPkg(config.dir, args);
383
- const provider = args.provider || PROVIDERS.CONTRIB_ROCKS;
384
- if (!github) throw new Error("`github` is required!");
385
- const lines = [];
386
- if (typeof args.license === "string") lines.push(`Published under the [${args.license.toUpperCase()}](https://github.com/${github}/blob/main/LICENSE) license.`);
387
- let madeBy = `[community](https://github.com/${github}/graphs/contributors) 💛`;
388
- if (typeof args.author === "string") {
389
- const authors = args.author.split(",").map((author) => author.trim()).map((user) => `[@${user}](https://github.com/${user})`).join(", ");
390
- if (authors.length > 0) madeBy = `${authors} and ${madeBy}`;
391
- }
392
- lines.push(`Made by ${madeBy}`);
393
- if (provider === PROVIDERS.MARKUPGO) {
394
- const params = [];
395
- args = {
396
- circleSize: "64",
397
- center: "true",
398
- ...args
399
- };
400
- if (Number(args.max) >= 0) params.push(["count", args.max]);
401
- if (Number(args.width)) params.push(["width", args.width]);
402
- if (Number(args.circleSize)) params.push(["circleSize", args.circleSize]);
403
- if (Number(args.circleRadius)) params.push(["circleRadius", args.circleRadius]);
404
- if (Number(args.circleSpacing)) params.push(["circleSpacing", args.circleSpacing]);
405
- if (args.center) params.push(["center", Boolean(args.center).toString()]);
406
- if (!args.markupGoLogo) params.push(["removeLogo", "true"]);
407
- if (args.anon) params.push(["anon", Boolean(args.anon).toString()]);
408
- let paramsStr = params.map(([k, v]) => `${k}=${v}`).join("&");
409
- paramsStr = paramsStr ? `?${paramsStr}` : "";
410
- lines.push(`<br><br>`, `<a href="https://github.com/${github}/graphs/contributors">`, `<img src="https://markupgo.com/github/${github}/contributors${paramsStr}" />`, `</a>`);
411
- } else {
412
- const params = [["repo", github]];
413
- if (args.max) params.push(["max", args.max]);
414
- if (args.anon) params.push(["anon", args.anon]);
415
- const paramsStr = params.map(([k, v]) => `${k}=${v}`).join("&");
416
- lines.push(`<br><br>`, `<a href="https://github.com/${github}/graphs/contributors">`, `<img src="https://contrib.rocks/image?${paramsStr}" />`, `</a>`);
417
- }
418
- return { contents: lines.join("\n") };
419
- }
420
- });
421
- const DEFAULT_IGNORE = [
422
- "node_modules",
423
- ".git",
424
- ".DS_Store",
425
- ".nuxt",
426
- ".output",
427
- ".nitro",
428
- "dist",
429
- "coverage",
430
- ".cache",
431
- ".turbo"
432
- ];
433
- async function parseGitignore(dir) {
434
- try {
435
- return (await (0, node_fs_promises.readFile)(require_pathe_M_eThtNZ.join(dir, ".gitignore"), "utf8")).split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
436
- } catch {
437
- return [];
438
- }
439
- }
440
- function shouldIgnore(name, ignorePatterns, defaultIgnore) {
441
- const allPatterns = [...defaultIgnore, ...ignorePatterns];
442
- for (const pattern of allPatterns) {
443
- if (name === pattern.replace(/^\//, "").replace(/\/$/, "")) return true;
444
- if (pattern.startsWith("*") && name.endsWith(pattern.slice(1))) return true;
445
- if (pattern.endsWith("*") && name.startsWith(pattern.slice(0, -1))) return true;
446
- }
447
- return false;
448
- }
449
- async function buildTree(dir, ignorePatterns, maxDepth, currentDepth = 0) {
450
- if (maxDepth > 0 && currentDepth >= maxDepth) return [];
451
- const entries = await (0, node_fs_promises.readdir)(dir);
452
- const result = [];
453
- for (const entry of entries) {
454
- if (shouldIgnore(entry, ignorePatterns, DEFAULT_IGNORE)) continue;
455
- const fullPath = require_pathe_M_eThtNZ.join(dir, entry);
456
- const isDirectory = (await (0, node_fs_promises.stat)(fullPath)).isDirectory();
457
- const treeEntry = {
458
- name: entry,
459
- isDirectory
460
- };
461
- if (isDirectory) treeEntry.children = await buildTree(fullPath, ignorePatterns, maxDepth, currentDepth + 1);
462
- result.push(treeEntry);
463
- }
464
- result.sort((a, b) => {
465
- if (a.isDirectory !== b.isDirectory) return a.isDirectory ? -1 : 1;
466
- return a.name.localeCompare(b.name);
467
- });
468
- return result;
469
- }
470
- function renderTree(entries, isLast = []) {
471
- const lines = [];
472
- for (let i = 0; i < entries.length; i++) {
473
- const entry = entries[i];
474
- const isLastEntry = i === entries.length - 1;
475
- let linePrefix = "";
476
- for (const element_ of isLast) linePrefix += element_ ? " " : "│ ";
477
- const connector = isLastEntry ? "└── " : "├── ";
478
- const suffix = entry.isDirectory ? "/" : "";
479
- lines.push(`${linePrefix}${connector}${entry.name}${suffix}`);
480
- if (entry.children && entry.children.length > 0) {
481
- const childLines = renderTree(entry.children, [...isLast, isLastEntry]);
482
- lines.push(...childLines);
483
- }
484
- }
485
- return lines;
486
- }
487
- const dirTree = defineGenerator({
488
- name: "dir-tree",
489
- async generate({ args, config, url }) {
490
- const srcPath = args.src || ".";
491
- const fullPath = resolvePath$1(srcPath, {
492
- url,
493
- dir: config.dir
494
- });
495
- if (!(await (0, node_fs_promises.stat)(fullPath)).isDirectory()) throw new Error(`Path "${srcPath}" is not a directory`);
496
- const userIgnore = args.ignore ? String(args.ignore).split(",").map((s) => s.trim()) : [];
497
- return { contents: "```\n" + renderTree(await buildTree(fullPath, [...await parseGitignore(fullPath), ...userIgnore], args.maxDepth ? Number(args.maxDepth) : 0)).join("\n") + "\n```" };
498
- }
499
- });
500
- var generators_default = {
501
- jsdocs,
502
- badges,
503
- "pm-i": pmInstall,
504
- "pm-install": pmInstall,
505
- "pm-x": pmX,
506
- fetch,
507
- file,
508
- jsimport,
509
- "with-automd": withAutomd,
510
- contributors,
511
- "dir-tree": dirTree
512
- };
513
- function findBlocks(md, config = {}) {
514
- const blocks = [];
515
- for (const match of md.matchAll(new RegExp(`^(?<open><!--\\s*(${config.prefix.join("|")}):(?<generator>.+?)\\s+(?<args>.*?)\\s*-->)(?<contents>.+?)(?<close>^<!--\\s*\\/(${config.prefix.join("|")})\\s*-->)`, "gimsu"))) {
516
- if (match.index === void 0 || !match.groups) continue;
517
- const start = match.index + match.groups.open.length || 0;
518
- const end = start + match.groups.contents.length;
519
- blocks.push({
520
- generator: match.groups.generator,
521
- rawArgs: match.groups.args,
522
- contents: match.groups.contents,
523
- loc: {
524
- start,
525
- end
526
- },
527
- _loc: {
528
- start: match.index,
529
- end: match.index + match[0].length
530
- }
531
- });
532
- }
533
- return blocks;
534
- }
535
- function containsAutomd(md, config = {}) {
536
- return new RegExp(`^<!--\\s*(${config.prefix.join("|")}):`, "gimsu").test(md);
537
- }
538
- function parseRawArgs(rawArgs) {
539
- const args = Object.create(null);
540
- for (const part of rawArgs.split(/\s+/)) {
541
- const [_key, value] = part.split("=");
542
- const key = _key && require_index$1.camelCase(_key);
543
- if (key && value) args[key] = require_index$4.destr(value);
544
- else if (part.startsWith("no-")) args[part.slice(3)] = false;
545
- else args[part] = true;
546
- }
547
- return args;
548
- }
549
- const RESOLVED_CONFIG_SYMBOL = Symbol("automdConfig");
550
- function resolveConfig(config) {
551
- if (config && RESOLVED_CONFIG_SYMBOL in config) return config;
552
- const _config = {
553
- dir: ".",
554
- input: "README.md",
555
- generators: {},
556
- [RESOLVED_CONFIG_SYMBOL]: true,
557
- ...config
558
- };
559
- _config.prefix = _config.prefix || [];
560
- if (typeof _config.prefix === "string") _config.prefix = [_config.prefix];
561
- if (!_config.prefix.includes("automd")) _config.prefix.push("automd");
562
- if (!_config.prefix.includes("powerlines")) _config.prefix.push("powerlines");
563
- _config.dir = require_pathe_M_eThtNZ.resolve(_config.dir);
564
- _config.input = (Array.isArray(_config.input) ? _config.input : [_config.input]).filter(Boolean);
565
- return _config;
566
- }
567
- async function loadConfig(dir = ".", overrides) {
568
- const { loadConfig: loadConfig$1 } = await import("c12");
569
- dir = require_pathe_M_eThtNZ.resolve(dir);
570
- const { config } = await loadConfig$1({
571
- cwd: dir,
572
- name: "automd",
573
- dotenv: true,
574
- overrides,
575
- defaults: {
576
- ignore: [
577
- "**/node_modules",
578
- "**/dist",
579
- "**/.*"
580
- ],
581
- dir
582
- }
583
- });
584
- return resolveConfig(config);
585
- }
586
- async function transform(contents, _config, url) {
587
- const start = performance.now();
588
- const config = resolveConfig(_config);
589
- const editor = new require_magic_string_es.MagicString(contents);
590
- const updates = [];
591
- const generators = {
592
- ...generators_default,
593
- ...config.generators
594
- };
595
- const blocks = findBlocks(contents, config);
596
- for (const block of blocks) {
597
- const result = await _transformBlock(block, config, generators, url);
598
- if (result.unwrap) editor.overwrite(block._loc.start, block._loc.end, `${result.contents.trim()}`);
599
- else editor.overwrite(block.loc.start, block.loc.end, `\n\n${result.contents.trim()}\n\n`);
600
- updates.push({
601
- block,
602
- result
603
- });
604
- }
605
- const hasChanged = editor.hasChanged();
606
- const hasIssues = updates.some((u) => u.result.issues?.filter(Boolean).length);
607
- const time = performance.now() - start;
608
- return {
609
- hasChanged,
610
- hasIssues,
611
- contents: hasChanged ? editor.toString() : contents,
612
- updates,
613
- time
614
- };
615
- }
616
- async function _transformBlock(block, config, generators, url) {
617
- const args = parseRawArgs(block.rawArgs);
618
- const generator = generators[block.generator];
619
- if (!generator) {
620
- const suggestions = (await Promise.resolve().then(() => require("../../../../didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.cjs")).then((r) => r.default || r))(block.generator, Object.keys(generators));
621
- const error = `Unknown generator:\`${block.generator}\`.${suggestions ? ` Did you mean "generator:\`${suggestions}\`"?` : ""}`;
622
- return {
623
- contents: `<!-- ⚠️ ${error} -->`,
624
- issues: [error]
625
- };
626
- }
627
- const context = {
628
- args,
629
- config,
630
- block,
631
- transform: (contents) => transform(contents, config, url),
632
- url
633
- };
634
- try {
635
- const result = await generator.generate(context);
636
- if (!result.unwrap && containsAutomd(result.contents, config)) result.unwrap = true;
637
- if (result.unwrap) {
638
- const nestedRes = await context.transform(result.contents);
639
- result.contents = nestedRes.contents;
640
- if (nestedRes.hasIssues) result.issues = [...result.issues || [], ...nestedRes.updates.flatMap((u) => u.result.issues || [])].filter(Boolean);
641
- }
642
- return result;
643
- } catch (error) {
644
- return {
645
- contents: `<!-- ⚠️ (${block.generator}) ${error.message || error} -->`,
646
- issues: [error]
647
- };
648
- }
649
- }
650
-
651
- //#endregion
652
- exports.loadConfig = loadConfig;
653
- exports.resolveConfig = resolveConfig;
654
- exports.transform = transform;