@powerlines/plugin-automd 0.1.248 → 0.1.249

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -18,7 +18,7 @@ import process$1 from "node:process";
18
18
  import path, { isAbsolute } from "node:path";
19
19
  import v8 from "node:v8";
20
20
  import { format as format$1, inspect } from "node:util";
21
- import { readFile } from "node:fs/promises";
21
+ import { readFile, readdir, stat } from "node:fs/promises";
22
22
  import defu, { defu as defu$1 } from "defu";
23
23
  import { loadConfig } from "c12";
24
24
  import toc from "markdown-toc";
@@ -6201,8 +6201,8 @@ function packageResolve$1(specifier, base, conditions) {
6201
6201
  /** @type {string} */
6202
6202
  let lastPath;
6203
6203
  do {
6204
- const stat = tryStatSync$1(packageJsonPath.slice(0, -13));
6205
- if (!stat || !stat.isDirectory()) {
6204
+ const stat$1 = tryStatSync$1(packageJsonPath.slice(0, -13));
6205
+ if (!stat$1 || !stat$1.isDirectory()) {
6206
6206
  lastPath = packageJsonPath;
6207
6207
  packageJsonUrl = new URL$1((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
6208
6208
  packageJsonPath = fileURLToPath(packageJsonUrl);
@@ -8652,8 +8652,8 @@ function packageResolve(specifier, base, conditions) {
8652
8652
  let packageJsonPath = fileURLToPath(packageJsonUrl);
8653
8653
  let lastPath;
8654
8654
  do {
8655
- const stat = tryStatSync(packageJsonPath.slice(0, -13));
8656
- if (!stat || !stat.isDirectory()) {
8655
+ const stat$1 = tryStatSync(packageJsonPath.slice(0, -13));
8656
+ if (!stat$1 || !stat$1.isDirectory()) {
8657
8657
  lastPath = packageJsonPath;
8658
8658
  packageJsonUrl = new URL$1((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
8659
8659
  packageJsonPath = fileURLToPath(packageJsonUrl);
@@ -8753,12 +8753,12 @@ function resolveModuleURL(input, options) {
8753
8753
  }
8754
8754
  }
8755
8755
  if (absolutePath) try {
8756
- const stat = lstatSync(absolutePath);
8757
- if (stat.isSymbolicLink()) {
8756
+ const stat$1 = lstatSync(absolutePath);
8757
+ if (stat$1.isSymbolicLink()) {
8758
8758
  absolutePath = realpathSync(absolutePath);
8759
8759
  url = pathToFileURL(absolutePath);
8760
8760
  }
8761
- if (stat.isFile()) {
8761
+ if (stat$1.isFile()) {
8762
8762
  if (cacheObj) cacheObj.set(cacheKey, url.href);
8763
8763
  return url.href;
8764
8764
  }
@@ -9019,7 +9019,7 @@ const render = {
9019
9019
  };
9020
9020
 
9021
9021
  //#endregion
9022
- //#region ../../node_modules/.pnpm/automd@0.4.2_patch_hash=0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/shared/automd.CjwUz8DJ.mjs
9022
+ //#region ../../node_modules/.pnpm/automd@0.4.3_patch_hash=0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/index.mjs
9023
9023
  function defineGenerator(generator) {
9024
9024
  return generator;
9025
9025
  }
@@ -9050,11 +9050,11 @@ function _getGitRepo(repo) {
9050
9050
  }
9051
9051
  const jsdocs = defineGenerator({
9052
9052
  name: "jsdocs",
9053
- async generate({ config: config$1, args, url }) {
9053
+ async generate({ config, args, url }) {
9054
9054
  const { loadSchema } = await import("./loader-BRhKFmUn.mjs");
9055
9055
  return { contents: _render(await loadSchema(resolvePath$1(args.src, {
9056
9056
  url,
9057
- dir: config$1.dir
9057
+ dir: config.dir
9058
9058
  }), { jiti: {
9059
9059
  fsCache: false,
9060
9060
  moduleCache: false
@@ -9062,7 +9062,7 @@ const jsdocs = defineGenerator({
9062
9062
  }
9063
9063
  });
9064
9064
  function _render(schema, opts, headingLevel) {
9065
- const sections = /* @__PURE__ */ Object.create(null);
9065
+ const sections = Object.create(null);
9066
9066
  for (const [key, keySchema] of Object.entries(schema.properties || {})) {
9067
9067
  const section = _renderSection(key, keySchema, opts, headingLevel + 1);
9068
9068
  if (!section) continue;
@@ -9076,14 +9076,10 @@ function _render(schema, opts, headingLevel) {
9076
9076
  return a.localeCompare(b);
9077
9077
  });
9078
9078
  for (const group of sortedGroups) {
9079
- if (group) lines.push(`
9080
- ${"#".repeat(headingLevel)} ${titleCase(group)}
9081
- `);
9079
+ if (group) lines.push(`\n${"#".repeat(headingLevel)} ${titleCase(group)}\n`);
9082
9080
  const sortedSections = sections[group].sort((a, b) => a[0].localeCompare(b[0]));
9083
9081
  for (const section of sortedSections) {
9084
- const heading$1 = `
9085
- ${"#".repeat(headingLevel + 1)} ${section[0]}
9086
- `;
9082
+ const heading$1 = `\n${"#".repeat(headingLevel + 1)} ${section[0]}\n`;
9087
9083
  lines.push(heading$1, ...section[1]);
9088
9084
  }
9089
9085
  }
@@ -9104,9 +9100,7 @@ function _renderSection(key, schema, opts, headingLevel) {
9104
9100
  }
9105
9101
  lines.push(..._renderBody(schema));
9106
9102
  for (const tag of tags) if (tag.tag === "@example") {
9107
- const codeBlock$1 = tag.contents.startsWith("`") ? tag.contents : `\`\`\`ts
9108
- ${tag.contents}
9109
- \`\`\``;
9103
+ const codeBlock$1 = tag.contents.startsWith("`") ? tag.contents : `\`\`\`ts\n${tag.contents}\n\`\`\``;
9110
9104
  lines.push("", "**Example:**", "", codeBlock$1);
9111
9105
  }
9112
9106
  if (schema.type === "object") lines.push(..._render(schema, opts, headingLevel));
@@ -9215,8 +9209,8 @@ const badgeProviders = {
9215
9209
  };
9216
9210
  const badges = defineGenerator({
9217
9211
  name: "badges",
9218
- async generate({ config: config$1, args }) {
9219
- const pkg = await getPkg(config$1.dir, args);
9212
+ async generate({ config, args }) {
9213
+ const pkg = await getPkg(config.dir, args);
9220
9214
  const ctx = {
9221
9215
  name: pkg.name,
9222
9216
  github: pkg.github,
@@ -9230,7 +9224,7 @@ const badges = defineGenerator({
9230
9224
  labelColor: args.labelColor,
9231
9225
  ...args.styleParams
9232
9226
  }).filter(([, value]) => value).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
9233
- const badges2 = {
9227
+ const badges$1 = {
9234
9228
  npmVersion: {
9235
9229
  enabled: ctx.name && args.npmVersion !== false,
9236
9230
  ...badgeTypes.npmVersion
@@ -9261,7 +9255,7 @@ const badges = defineGenerator({
9261
9255
  }
9262
9256
  };
9263
9257
  const md = [];
9264
- for (const [badgeType, badge] of Object.entries(badges2)) {
9258
+ for (const [badgeType, badge] of Object.entries(badges$1)) {
9265
9259
  if (!badge.enabled || !provider[badgeType]) continue;
9266
9260
  const to = fillStr(badge.to);
9267
9261
  const imgURL = fillStr(provider[badgeType]) + (providerParams ? `?${providerParams}` : "");
@@ -9291,26 +9285,24 @@ const RUN_COMMANDS = [
9291
9285
  ];
9292
9286
  const pmInstall = defineGenerator({
9293
9287
  name: "pm-install",
9294
- async generate({ config: config$1, args }) {
9295
- const { name, version: version$1 } = await getPkg(config$1.dir, args);
9288
+ async generate({ config, args }) {
9289
+ const { name, version: version$1 } = await getPkg(config.dir, args);
9296
9290
  if (!name) return { contents: "<!-- package name is unspecified -->" };
9297
9291
  let versionSuffix = "";
9298
9292
  if (args.version) versionSuffix = typeof args.version === "string" ? `@${args.version}` : `@^${version$1}`;
9299
- const contents = (args.auto === false ? INSTALL_COMMANDS : [NYPM_COMMAND, ...INSTALL_COMMANDS]).map(([cmd, install, dev = " -D", pkgPrefix = ""]) => `# ${cmd.includes("nypm") ? "✨ Auto-detect" : cmd}
9300
- ${cmd} ${install}${args.dev ? dev : args.global ? "g" : ""} ${pkgPrefix}${name}${versionSuffix}`);
9293
+ 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}`);
9301
9294
  if ((args.separate ?? false) === false) return { contents: render.codeBlock(contents.join("\n\n"), "sh") };
9302
9295
  return { contents: contents.map((cmd) => render.codeBlock(cmd, "sh")).join("\n\n") };
9303
9296
  }
9304
9297
  });
9305
9298
  const pmX = defineGenerator({
9306
9299
  name: "pm-x",
9307
- async generate({ config: config$1, args }) {
9308
- const { name, version: version$1 } = await getPkg(config$1.dir, args);
9300
+ async generate({ config, args }) {
9301
+ const { name, version: version$1 } = await getPkg(config.dir, args);
9309
9302
  if (!name) return { contents: "<!-- package name is unspecified -->" };
9310
9303
  let versionSuffix = "";
9311
9304
  if (args.version) versionSuffix = typeof args.version === "string" ? `@${args.version}` : `@${version$1}`;
9312
- const contents = RUN_COMMANDS.map(([pm, cmd]) => `# ${pm}
9313
- ${cmd}${name}${versionSuffix}${args.args ? ` ${args.args}` : ""}`);
9305
+ const contents = RUN_COMMANDS.map(([pm, cmd]) => `# ${pm}\n${cmd}${name}${versionSuffix}${args.args ? ` ${args.args}` : ""}`);
9314
9306
  if ((args.separate ?? false) === false) return { contents: render.codeBlock(contents.join("\n\n"), "sh") };
9315
9307
  return { contents: contents.map((cmd) => render.codeBlock(cmd, "sh")).join("\n\n") };
9316
9308
  }
@@ -9318,7 +9310,7 @@ ${cmd}${name}${versionSuffix}${args.args ? ` ${args.args}` : ""}`);
9318
9310
  const fetch = defineGenerator({
9319
9311
  name: "fetch",
9320
9312
  async generate({ args }) {
9321
- const { $fetch } = await import("./node-d_BpkPSt.mjs");
9313
+ const { $fetch } = await import("./node-D8lz5B3d.mjs");
9322
9314
  let url = args.url;
9323
9315
  if (!url) throw new Error("URL is required!");
9324
9316
  if (url.startsWith("gh:")) url = `https://raw.githubusercontent.com/${url.slice(3)}`;
@@ -9328,18 +9320,16 @@ const fetch = defineGenerator({
9328
9320
  const DEFAULT_CDN = "https://esm.sh/";
9329
9321
  const jsimport = defineGenerator({
9330
9322
  name: "jsimport",
9331
- async generate({ config: config$1, args }) {
9332
- const { name } = await getPkg(config$1.dir, args);
9323
+ async generate({ config, args }) {
9324
+ const { name } = await getPkg(config.dir, args);
9333
9325
  const importPath = name + (args.path || "");
9334
9326
  const importNames = [].concat(args.import, args.imports).filter(Boolean).flatMap((i$1) => i$1.split(/\s*,\s*/));
9335
9327
  if (args.src) {
9336
- const exportNames = findExportNames(await readFile(await resolvePath(args.src, { url: config$1.dir }), "utf8"));
9328
+ const exportNames = findExportNames(await readFile(await resolvePath(args.src, { url: config.dir }), "utf8"));
9337
9329
  if (exportNames && exportNames.length > 0) importNames.push(...exportNames);
9338
9330
  }
9339
9331
  const lines = [];
9340
- const fmtImports = importNames.length > 1 ? `
9341
- ${importNames.map((i$1) => " " + i$1 + ",").join("\n")}
9342
- ` : importNames[0] && ` ${importNames[0]} ` || "";
9332
+ const fmtImports = importNames.length > 1 ? `\n${importNames.map((i$1) => " " + i$1 + ",").join("\n")}\n` : importNames[0] && ` ${importNames[0]} ` || "";
9343
9333
  const formatMultiLine = (str) => {
9344
9334
  return str.length > (args.printWidth || 80) ? str : str.replace(/\n/g, "").replace(/,\s*}/, "}").replace(/(\w)}/, "$1 }").replace(/\s+/g, " ");
9345
9335
  };
@@ -9371,10 +9361,10 @@ const withAutomd = defineGenerator({
9371
9361
  });
9372
9362
  const file = defineGenerator({
9373
9363
  name: "file",
9374
- async generate({ args, config: config$1, url }) {
9364
+ async generate({ args, config, url }) {
9375
9365
  const fullPath = resolvePath$1(args.src, {
9376
9366
  url,
9377
- dir: config$1.dir
9367
+ dir: config.dir
9378
9368
  });
9379
9369
  let contents = await readFile(fullPath, "utf8");
9380
9370
  if (!args.noTrim) contents = contents.trim();
@@ -9397,13 +9387,13 @@ const PROVIDERS = {
9397
9387
  };
9398
9388
  const contributors = defineGenerator({
9399
9389
  name: "contributors",
9400
- async generate({ config: config$1, args }) {
9401
- const { github } = await getPkg(config$1.dir, args);
9390
+ async generate({ config, args }) {
9391
+ const { github } = await getPkg(config.dir, args);
9402
9392
  const provider = args.provider || PROVIDERS.CONTRIB_ROCKS;
9403
9393
  if (!github) throw new Error("`github` is required!");
9404
9394
  const lines = [];
9405
9395
  if (typeof args.license === "string") lines.push(`Published under the [${args.license.toUpperCase()}](https://github.com/${github}/blob/main/LICENSE) license.`);
9406
- let madeBy = `[community](https://github.com/${github}/graphs/contributors) \u{1F49B}`;
9396
+ let madeBy = `[community](https://github.com/${github}/graphs/contributors) 💛`;
9407
9397
  if (typeof args.author === "string") {
9408
9398
  const authors = args.author.split(",").map((author) => author.trim()).map((user) => `[@${user}](https://github.com/${user})`).join(", ");
9409
9399
  if (authors.length > 0) madeBy = `${authors} and ${madeBy}`;
@@ -9437,7 +9427,86 @@ const contributors = defineGenerator({
9437
9427
  return { contents: lines.join("\n") };
9438
9428
  }
9439
9429
  });
9440
- const builtinGenerators = {
9430
+ const DEFAULT_IGNORE = [
9431
+ "node_modules",
9432
+ ".git",
9433
+ ".DS_Store",
9434
+ ".nuxt",
9435
+ ".output",
9436
+ ".nitro",
9437
+ "dist",
9438
+ "coverage",
9439
+ ".cache",
9440
+ ".turbo"
9441
+ ];
9442
+ async function parseGitignore(dir) {
9443
+ try {
9444
+ return (await readFile(join(dir, ".gitignore"), "utf8")).split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
9445
+ } catch {
9446
+ return [];
9447
+ }
9448
+ }
9449
+ function shouldIgnore(name, ignorePatterns, defaultIgnore) {
9450
+ const allPatterns = [...defaultIgnore, ...ignorePatterns];
9451
+ for (const pattern of allPatterns) {
9452
+ if (name === pattern.replace(/^\//, "").replace(/\/$/, "")) return true;
9453
+ if (pattern.startsWith("*") && name.endsWith(pattern.slice(1))) return true;
9454
+ if (pattern.endsWith("*") && name.startsWith(pattern.slice(0, -1))) return true;
9455
+ }
9456
+ return false;
9457
+ }
9458
+ async function buildTree(dir, ignorePatterns, maxDepth, currentDepth = 0) {
9459
+ if (maxDepth > 0 && currentDepth >= maxDepth) return [];
9460
+ const entries = await readdir(dir);
9461
+ const result = [];
9462
+ for (const entry of entries) {
9463
+ if (shouldIgnore(entry, ignorePatterns, DEFAULT_IGNORE)) continue;
9464
+ const fullPath = join(dir, entry);
9465
+ const isDirectory$1 = (await stat(fullPath)).isDirectory();
9466
+ const treeEntry = {
9467
+ name: entry,
9468
+ isDirectory: isDirectory$1
9469
+ };
9470
+ if (isDirectory$1) treeEntry.children = await buildTree(fullPath, ignorePatterns, maxDepth, currentDepth + 1);
9471
+ result.push(treeEntry);
9472
+ }
9473
+ result.sort((a, b) => {
9474
+ if (a.isDirectory !== b.isDirectory) return a.isDirectory ? -1 : 1;
9475
+ return a.name.localeCompare(b.name);
9476
+ });
9477
+ return result;
9478
+ }
9479
+ function renderTree(entries, isLast = []) {
9480
+ const lines = [];
9481
+ for (let i$1 = 0; i$1 < entries.length; i$1++) {
9482
+ const entry = entries[i$1];
9483
+ const isLastEntry = i$1 === entries.length - 1;
9484
+ let linePrefix = "";
9485
+ for (const element_ of isLast) linePrefix += element_ ? " " : "│ ";
9486
+ const connector = isLastEntry ? "└── " : "├── ";
9487
+ const suffix = entry.isDirectory ? "/" : "";
9488
+ lines.push(`${linePrefix}${connector}${entry.name}${suffix}`);
9489
+ if (entry.children && entry.children.length > 0) {
9490
+ const childLines = renderTree(entry.children, [...isLast, isLastEntry]);
9491
+ lines.push(...childLines);
9492
+ }
9493
+ }
9494
+ return lines;
9495
+ }
9496
+ const dirTree = defineGenerator({
9497
+ name: "dir-tree",
9498
+ async generate({ args, config, url }) {
9499
+ const srcPath = args.src || ".";
9500
+ const fullPath = resolvePath$1(srcPath, {
9501
+ url,
9502
+ dir: config.dir
9503
+ });
9504
+ if (!(await stat(fullPath)).isDirectory()) throw new Error(`Path "${srcPath}" is not a directory`);
9505
+ const userIgnore = args.ignore ? String(args.ignore).split(",").map((s) => s.trim()) : [];
9506
+ return { contents: "```\n" + renderTree(await buildTree(fullPath, [...await parseGitignore(fullPath), ...userIgnore], args.maxDepth ? Number(args.maxDepth) : 0)).join("\n") + "\n```" };
9507
+ }
9508
+ });
9509
+ var generators_default = {
9441
9510
  jsdocs,
9442
9511
  badges,
9443
9512
  "pm-i": pmInstall,
@@ -9447,21 +9516,16 @@ const builtinGenerators = {
9447
9516
  file,
9448
9517
  jsimport,
9449
9518
  "with-automd": withAutomd,
9450
- contributors
9519
+ contributors,
9520
+ "dir-tree": dirTree
9451
9521
  };
9452
- function getPrefixes(config$1) {
9453
- return !config$1?.prefix || !Array.isArray(config$1.prefix) ? "automd" : config$1.prefix.length > 1 ? `(${config$1.prefix.join("|")})` : config$1.prefix;
9454
- }
9455
- function findBlocks(md, config$1) {
9522
+ function findBlocks(md) {
9456
9523
  const blocks = [];
9457
- const prefix = getPrefixes(config$1);
9458
- const AUTOMD_RE = new RegExp(`^(?<open><!--\\s*${prefix}:(?<generator>.+?)\\s+(?<args>.*?)\\s*-->)(?<contents>.+?)(?<close>^<!--\\s*\\/${prefix}\\s*-->)`, "gimsu");
9459
- for (const match of md.matchAll(AUTOMD_RE)) {
9524
+ for (const match of md.matchAll(/^(?<open><!--\s*automd:(?<generator>.+?)\s+(?<args>.*?)\s*-->)(?<contents>.+?)(?<close>^<!--\s*\/automd\s*-->)/gimsu)) {
9460
9525
  if (match.index === void 0 || !match.groups) continue;
9461
- const start = match.index + match.groups.open.length;
9526
+ const start = match.index + match.groups.open.length || 0;
9462
9527
  const end = start + match.groups.contents.length;
9463
9528
  blocks.push({
9464
- md,
9465
9529
  generator: match.groups.generator,
9466
9530
  rawArgs: match.groups.args,
9467
9531
  contents: match.groups.contents,
@@ -9478,11 +9542,10 @@ function findBlocks(md, config$1) {
9478
9542
  return blocks;
9479
9543
  }
9480
9544
  function containsAutomd(md) {
9481
- const prefix = getPrefixes(config);
9482
- return new RegExp(`^<!--\\s*${prefix}:`, "gimsu").test(md);
9545
+ return /^<!--\s*automd:/gimsu.test(md);
9483
9546
  }
9484
9547
  function parseRawArgs(rawArgs) {
9485
- const args = /* @__PURE__ */ Object.create(null);
9548
+ const args = Object.create(null);
9486
9549
  for (const part of rawArgs.split(/\s+/)) {
9487
9550
  const [_key, value] = part.split("=");
9488
9551
  const key = _key && camelCase(_key);
@@ -9493,25 +9556,23 @@ function parseRawArgs(rawArgs) {
9493
9556
  return args;
9494
9557
  }
9495
9558
  const RESOLVED_CONFIG_SYMBOL = Symbol("automdConfig");
9496
- function resolveConfig(config$1) {
9497
- if (config$1 && RESOLVED_CONFIG_SYMBOL in config$1) return config$1;
9559
+ function resolveConfig(config) {
9560
+ if (config && RESOLVED_CONFIG_SYMBOL in config) return config;
9498
9561
  const _config = {
9499
9562
  dir: ".",
9500
9563
  input: "README.md",
9501
9564
  generators: {},
9502
9565
  [RESOLVED_CONFIG_SYMBOL]: true,
9503
- ...config$1
9566
+ ...config
9504
9567
  };
9505
9568
  _config.dir = resolve(_config.dir);
9506
9569
  _config.input = (Array.isArray(_config.input) ? _config.input : [_config.input]).filter(Boolean);
9507
- _config.prefix = Array.isArray(_config.prefix) ? _config.prefix : [_config.prefix];
9508
- if (!_config.prefix.includes("automd")) _config.prefix.push("automd");
9509
9570
  return _config;
9510
9571
  }
9511
9572
  async function loadConfig$1(dir = ".", overrides) {
9512
- const { loadConfig: loadConfig2 } = await import("c12");
9573
+ const { loadConfig: loadConfig$2 } = await import("c12");
9513
9574
  dir = resolve(dir);
9514
- const { config: config$1 } = await loadConfig2({
9575
+ const { config } = await loadConfig$2({
9515
9576
  cwd: dir,
9516
9577
  name: "automd",
9517
9578
  dotenv: true,
@@ -9525,26 +9586,22 @@ async function loadConfig$1(dir = ".", overrides) {
9525
9586
  dir
9526
9587
  }
9527
9588
  });
9528
- return resolveConfig(config$1);
9589
+ return resolveConfig(config);
9529
9590
  }
9530
9591
  async function transform(contents, _config, url) {
9531
9592
  const start = performance.now();
9532
- const config$1 = resolveConfig(_config);
9593
+ const config = resolveConfig(_config);
9533
9594
  const editor = new MagicString(contents);
9534
9595
  const updates = [];
9535
9596
  const generators = {
9536
- ...builtinGenerators,
9537
- ...config$1.generators
9597
+ ...generators_default,
9598
+ ...config.generators
9538
9599
  };
9539
- const blocks = findBlocks(contents, config$1);
9600
+ const blocks = findBlocks(contents);
9540
9601
  for (const block of blocks) {
9541
- const result = await _transformBlock(block, config$1, generators, url);
9602
+ const result = await _transformBlock(block, config, generators, url);
9542
9603
  if (result.unwrap) editor.overwrite(block._loc.start, block._loc.end, `${result.contents.trim()}`);
9543
- else editor.overwrite(block.loc.start, block.loc.end, `
9544
-
9545
- ${result.contents.trim()}
9546
-
9547
- `);
9604
+ else editor.overwrite(block.loc.start, block.loc.end, `\n\n${result.contents.trim()}\n\n`);
9548
9605
  updates.push({
9549
9606
  block,
9550
9607
  result
@@ -9561,22 +9618,22 @@ ${result.contents.trim()}
9561
9618
  time
9562
9619
  };
9563
9620
  }
9564
- async function _transformBlock(block, config$1, generators, url) {
9621
+ async function _transformBlock(block, config, generators, url) {
9565
9622
  const args = parseRawArgs(block.rawArgs);
9566
9623
  const generator = generators[block.generator];
9567
9624
  if (!generator) {
9568
9625
  const suggestions = (await import("./dist-PXnBmevt.mjs").then((r$1) => r$1.default || r$1))(block.generator, Object.keys(generators));
9569
9626
  const error = `Unknown generator:\`${block.generator}\`.${suggestions ? ` Did you mean "generator:\`${suggestions}\`"?` : ""}`;
9570
9627
  return {
9571
- contents: `<!-- \u26A0\uFE0F ${error} -->`,
9628
+ contents: `<!-- ⚠️ ${error} -->`,
9572
9629
  issues: [error]
9573
9630
  };
9574
9631
  }
9575
9632
  const context = {
9576
9633
  args,
9577
- config: config$1,
9634
+ config,
9578
9635
  block,
9579
- transform: (contents) => transform(contents, config$1, url),
9636
+ transform: (contents) => transform(contents, config, url),
9580
9637
  url
9581
9638
  };
9582
9639
  try {
@@ -9590,7 +9647,7 @@ async function _transformBlock(block, config$1, generators, url) {
9590
9647
  return result;
9591
9648
  } catch (error) {
9592
9649
  return {
9593
- contents: `<!-- \u26A0\uFE0F (${block.generator}) ${error.message || error} -->`,
9650
+ contents: `<!-- ⚠️ (${block.generator}) ${error.message || error} -->`,
9594
9651
  issues: [error]
9595
9652
  };
9596
9653
  }
@@ -9613,11 +9670,11 @@ const plugin = (options = {}) => {
9613
9670
  return {
9614
9671
  name: "automd",
9615
9672
  async config() {
9616
- const config$1 = await loadConfig$1(joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot), options);
9617
- if (!config$1.prefix || !Array.isArray(config$1.prefix)) config$1.prefix = toArray(config$1.prefix ?? []);
9618
- if (!config$1.prefix.includes("automd")) config$1.prefix.push("automd");
9619
- if (!config$1.prefix.includes("powerlines")) config$1.prefix.push("powerlines");
9620
- return { automd: defu(config$1 ?? {}, {
9673
+ const config = await loadConfig$1(joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot), options);
9674
+ if (!config.prefix || !Array.isArray(config.prefix)) config.prefix = toArray(config.prefix ?? []);
9675
+ if (!config.prefix.includes("automd")) config.prefix.push("automd");
9676
+ if (!config.prefix.includes("powerlines")) config.prefix.push("powerlines");
9677
+ return { automd: defu(config ?? {}, {
9621
9678
  configFile: options.configFile,
9622
9679
  allowIssues: true,
9623
9680
  dir: this.config.projectRoot,
@@ -9632,7 +9689,7 @@ const plugin = (options = {}) => {
9632
9689
  async configResolved() {
9633
9690
  if (this.config.framework && !toArray(this.config.automd.prefix).includes(this.config.framework)) this.config.automd.prefix = toArray(this.config.automd.prefix).concat(this.config.framework);
9634
9691
  if (this.config.automd.configFile) {
9635
- const { config: config$1 } = await loadConfig({
9692
+ const { config } = await loadConfig({
9636
9693
  cwd: this.config.automd.dir,
9637
9694
  configFile: this.config.automd.configFile,
9638
9695
  defaults: {
@@ -9645,8 +9702,8 @@ const plugin = (options = {}) => {
9645
9702
  }
9646
9703
  });
9647
9704
  this.config.automd = resolveConfig(defu(this.config.automd, {
9648
- ...config$1,
9649
- prefix: toArray(config$1.prefix ?? [])
9705
+ ...config,
9706
+ prefix: toArray(config.prefix ?? [])
9650
9707
  }));
9651
9708
  }
9652
9709
  this.config.automd.input = (await Promise.all(toArray(this.config.automd.input).map(async (input) => {