@powerlines/plugin-automd 0.1.222 → 0.1.224

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