@powerlines/plugin-automd 0.1.128 → 0.1.129

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