@powerlines/plugin-automd 0.1.248 → 0.1.250
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.cjs +145 -88
- package/dist/index.mjs +147 -90
- package/dist/index.mjs.map +1 -1
- package/dist/{multipart-parser-CelMRf5R.mjs → multipart-parser-Dtmz_axo.mjs} +2 -3
- package/dist/{multipart-parser-CelMRf5R.mjs.map → multipart-parser-Dtmz_axo.mjs.map} +1 -1
- package/dist/{node-BE0IsiNO.mjs → node-D8lz5B3d.mjs} +2 -3
- package/dist/{node-BE0IsiNO.mjs.map → node-D8lz5B3d.mjs.map} +1 -1
- package/dist/{node-C4Zezo2l.mjs → node-FGT1CWpL.mjs} +2 -2
- package/dist/{node-C4Zezo2l.mjs.map → node-FGT1CWpL.mjs.map} +1 -1
- package/package.json +5 -5
- package/dist/multipart-parser-CglOohoL.mjs +0 -179
- package/dist/multipart-parser-CglOohoL.mjs.map +0 -1
- package/dist/node-Du1vi9nA.mjs +0 -3974
- package/dist/node-Du1vi9nA.mjs.map +0 -1
- package/dist/node-d_BpkPSt.mjs +0 -267
- package/dist/node-d_BpkPSt.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -6210,8 +6210,8 @@ function packageResolve$1(specifier, base, conditions) {
|
|
|
6210
6210
|
/** @type {string} */
|
|
6211
6211
|
let lastPath;
|
|
6212
6212
|
do {
|
|
6213
|
-
const stat = tryStatSync$1(packageJsonPath.slice(0, -13));
|
|
6214
|
-
if (!stat || !stat.isDirectory()) {
|
|
6213
|
+
const stat$1 = tryStatSync$1(packageJsonPath.slice(0, -13));
|
|
6214
|
+
if (!stat$1 || !stat$1.isDirectory()) {
|
|
6215
6215
|
lastPath = packageJsonPath;
|
|
6216
6216
|
packageJsonUrl = new node_url.URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
|
|
6217
6217
|
packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
|
|
@@ -8661,8 +8661,8 @@ function packageResolve(specifier, base, conditions) {
|
|
|
8661
8661
|
let packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
|
|
8662
8662
|
let lastPath;
|
|
8663
8663
|
do {
|
|
8664
|
-
const stat = tryStatSync(packageJsonPath.slice(0, -13));
|
|
8665
|
-
if (!stat || !stat.isDirectory()) {
|
|
8664
|
+
const stat$1 = tryStatSync(packageJsonPath.slice(0, -13));
|
|
8665
|
+
if (!stat$1 || !stat$1.isDirectory()) {
|
|
8666
8666
|
lastPath = packageJsonPath;
|
|
8667
8667
|
packageJsonUrl = new node_url.URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
|
|
8668
8668
|
packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
|
|
@@ -8762,12 +8762,12 @@ function resolveModuleURL(input, options) {
|
|
|
8762
8762
|
}
|
|
8763
8763
|
}
|
|
8764
8764
|
if (absolutePath) try {
|
|
8765
|
-
const stat = (0, node_fs.lstatSync)(absolutePath);
|
|
8766
|
-
if (stat.isSymbolicLink()) {
|
|
8765
|
+
const stat$1 = (0, node_fs.lstatSync)(absolutePath);
|
|
8766
|
+
if (stat$1.isSymbolicLink()) {
|
|
8767
8767
|
absolutePath = (0, node_fs.realpathSync)(absolutePath);
|
|
8768
8768
|
url = (0, node_url.pathToFileURL)(absolutePath);
|
|
8769
8769
|
}
|
|
8770
|
-
if (stat.isFile()) {
|
|
8770
|
+
if (stat$1.isFile()) {
|
|
8771
8771
|
if (cacheObj) cacheObj.set(cacheKey, url.href);
|
|
8772
8772
|
return url.href;
|
|
8773
8773
|
}
|
|
@@ -9028,7 +9028,7 @@ const render = {
|
|
|
9028
9028
|
};
|
|
9029
9029
|
|
|
9030
9030
|
//#endregion
|
|
9031
|
-
//#region ../../node_modules/.pnpm/automd@0.4.
|
|
9031
|
+
//#region ../../node_modules/.pnpm/automd@0.4.3_patch_hash=0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/index.mjs
|
|
9032
9032
|
function defineGenerator(generator) {
|
|
9033
9033
|
return generator;
|
|
9034
9034
|
}
|
|
@@ -9059,11 +9059,11 @@ function _getGitRepo(repo) {
|
|
|
9059
9059
|
}
|
|
9060
9060
|
const jsdocs = defineGenerator({
|
|
9061
9061
|
name: "jsdocs",
|
|
9062
|
-
async generate({ config
|
|
9062
|
+
async generate({ config, args, url }) {
|
|
9063
9063
|
const { loadSchema } = await Promise.resolve().then(() => require("./loader-DNEbMIIe.cjs"));
|
|
9064
9064
|
return { contents: _render(await loadSchema(resolvePath$1(args.src, {
|
|
9065
9065
|
url,
|
|
9066
|
-
dir: config
|
|
9066
|
+
dir: config.dir
|
|
9067
9067
|
}), { jiti: {
|
|
9068
9068
|
fsCache: false,
|
|
9069
9069
|
moduleCache: false
|
|
@@ -9071,7 +9071,7 @@ const jsdocs = defineGenerator({
|
|
|
9071
9071
|
}
|
|
9072
9072
|
});
|
|
9073
9073
|
function _render(schema, opts, headingLevel) {
|
|
9074
|
-
const sections =
|
|
9074
|
+
const sections = Object.create(null);
|
|
9075
9075
|
for (const [key, keySchema] of Object.entries(schema.properties || {})) {
|
|
9076
9076
|
const section = _renderSection(key, keySchema, opts, headingLevel + 1);
|
|
9077
9077
|
if (!section) continue;
|
|
@@ -9085,14 +9085,10 @@ function _render(schema, opts, headingLevel) {
|
|
|
9085
9085
|
return a.localeCompare(b);
|
|
9086
9086
|
});
|
|
9087
9087
|
for (const group of sortedGroups) {
|
|
9088
|
-
if (group) lines.push(`
|
|
9089
|
-
${"#".repeat(headingLevel)} ${require_dist$1.titleCase(group)}
|
|
9090
|
-
`);
|
|
9088
|
+
if (group) lines.push(`\n${"#".repeat(headingLevel)} ${require_dist$1.titleCase(group)}\n`);
|
|
9091
9089
|
const sortedSections = sections[group].sort((a, b) => a[0].localeCompare(b[0]));
|
|
9092
9090
|
for (const section of sortedSections) {
|
|
9093
|
-
const heading$1 =
|
|
9094
|
-
${"#".repeat(headingLevel + 1)} ${section[0]}
|
|
9095
|
-
`;
|
|
9091
|
+
const heading$1 = `\n${"#".repeat(headingLevel + 1)} ${section[0]}\n`;
|
|
9096
9092
|
lines.push(heading$1, ...section[1]);
|
|
9097
9093
|
}
|
|
9098
9094
|
}
|
|
@@ -9113,9 +9109,7 @@ function _renderSection(key, schema, opts, headingLevel) {
|
|
|
9113
9109
|
}
|
|
9114
9110
|
lines.push(..._renderBody(schema));
|
|
9115
9111
|
for (const tag of tags) if (tag.tag === "@example") {
|
|
9116
|
-
const codeBlock$1 = tag.contents.startsWith("`") ? tag.contents : `\`\`\`ts
|
|
9117
|
-
${tag.contents}
|
|
9118
|
-
\`\`\``;
|
|
9112
|
+
const codeBlock$1 = tag.contents.startsWith("`") ? tag.contents : `\`\`\`ts\n${tag.contents}\n\`\`\``;
|
|
9119
9113
|
lines.push("", "**Example:**", "", codeBlock$1);
|
|
9120
9114
|
}
|
|
9121
9115
|
if (schema.type === "object") lines.push(..._render(schema, opts, headingLevel));
|
|
@@ -9224,8 +9218,8 @@ const badgeProviders = {
|
|
|
9224
9218
|
};
|
|
9225
9219
|
const badges = defineGenerator({
|
|
9226
9220
|
name: "badges",
|
|
9227
|
-
async generate({ config
|
|
9228
|
-
const pkg = await getPkg(config
|
|
9221
|
+
async generate({ config, args }) {
|
|
9222
|
+
const pkg = await getPkg(config.dir, args);
|
|
9229
9223
|
const ctx = {
|
|
9230
9224
|
name: pkg.name,
|
|
9231
9225
|
github: pkg.github,
|
|
@@ -9239,7 +9233,7 @@ const badges = defineGenerator({
|
|
|
9239
9233
|
labelColor: args.labelColor,
|
|
9240
9234
|
...args.styleParams
|
|
9241
9235
|
}).filter(([, value]) => value).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
|
|
9242
|
-
const
|
|
9236
|
+
const badges$1 = {
|
|
9243
9237
|
npmVersion: {
|
|
9244
9238
|
enabled: ctx.name && args.npmVersion !== false,
|
|
9245
9239
|
...badgeTypes.npmVersion
|
|
@@ -9270,7 +9264,7 @@ const badges = defineGenerator({
|
|
|
9270
9264
|
}
|
|
9271
9265
|
};
|
|
9272
9266
|
const md = [];
|
|
9273
|
-
for (const [badgeType, badge] of Object.entries(
|
|
9267
|
+
for (const [badgeType, badge] of Object.entries(badges$1)) {
|
|
9274
9268
|
if (!badge.enabled || !provider[badgeType]) continue;
|
|
9275
9269
|
const to = fillStr(badge.to);
|
|
9276
9270
|
const imgURL = fillStr(provider[badgeType]) + (providerParams ? `?${providerParams}` : "");
|
|
@@ -9300,26 +9294,24 @@ const RUN_COMMANDS = [
|
|
|
9300
9294
|
];
|
|
9301
9295
|
const pmInstall = defineGenerator({
|
|
9302
9296
|
name: "pm-install",
|
|
9303
|
-
async generate({ config
|
|
9304
|
-
const { name, version: version$1 } = await getPkg(config
|
|
9297
|
+
async generate({ config, args }) {
|
|
9298
|
+
const { name, version: version$1 } = await getPkg(config.dir, args);
|
|
9305
9299
|
if (!name) return { contents: "<!-- package name is unspecified -->" };
|
|
9306
9300
|
let versionSuffix = "";
|
|
9307
9301
|
if (args.version) versionSuffix = typeof args.version === "string" ? `@${args.version}` : `@^${version$1}`;
|
|
9308
|
-
const contents = (args.auto === false ? INSTALL_COMMANDS : [NYPM_COMMAND, ...INSTALL_COMMANDS]).map(([cmd, install, dev = " -D", pkgPrefix = ""]) => `# ${cmd.includes("nypm") ? "✨ Auto-detect" : cmd}
|
|
9309
|
-
${cmd} ${install}${args.dev ? dev : args.global ? "g" : ""} ${pkgPrefix}${name}${versionSuffix}`);
|
|
9302
|
+
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}`);
|
|
9310
9303
|
if ((args.separate ?? false) === false) return { contents: render.codeBlock(contents.join("\n\n"), "sh") };
|
|
9311
9304
|
return { contents: contents.map((cmd) => render.codeBlock(cmd, "sh")).join("\n\n") };
|
|
9312
9305
|
}
|
|
9313
9306
|
});
|
|
9314
9307
|
const pmX = defineGenerator({
|
|
9315
9308
|
name: "pm-x",
|
|
9316
|
-
async generate({ config
|
|
9317
|
-
const { name, version: version$1 } = await getPkg(config
|
|
9309
|
+
async generate({ config, args }) {
|
|
9310
|
+
const { name, version: version$1 } = await getPkg(config.dir, args);
|
|
9318
9311
|
if (!name) return { contents: "<!-- package name is unspecified -->" };
|
|
9319
9312
|
let versionSuffix = "";
|
|
9320
9313
|
if (args.version) versionSuffix = typeof args.version === "string" ? `@${args.version}` : `@${version$1}`;
|
|
9321
|
-
const contents = RUN_COMMANDS.map(([pm, cmd]) => `# ${pm}
|
|
9322
|
-
${cmd}${name}${versionSuffix}${args.args ? ` ${args.args}` : ""}`);
|
|
9314
|
+
const contents = RUN_COMMANDS.map(([pm, cmd]) => `# ${pm}\n${cmd}${name}${versionSuffix}${args.args ? ` ${args.args}` : ""}`);
|
|
9323
9315
|
if ((args.separate ?? false) === false) return { contents: render.codeBlock(contents.join("\n\n"), "sh") };
|
|
9324
9316
|
return { contents: contents.map((cmd) => render.codeBlock(cmd, "sh")).join("\n\n") };
|
|
9325
9317
|
}
|
|
@@ -9337,18 +9329,16 @@ const fetch = defineGenerator({
|
|
|
9337
9329
|
const DEFAULT_CDN = "https://esm.sh/";
|
|
9338
9330
|
const jsimport = defineGenerator({
|
|
9339
9331
|
name: "jsimport",
|
|
9340
|
-
async generate({ config
|
|
9341
|
-
const { name } = await getPkg(config
|
|
9332
|
+
async generate({ config, args }) {
|
|
9333
|
+
const { name } = await getPkg(config.dir, args);
|
|
9342
9334
|
const importPath = name + (args.path || "");
|
|
9343
9335
|
const importNames = [].concat(args.import, args.imports).filter(Boolean).flatMap((i$1) => i$1.split(/\s*,\s*/));
|
|
9344
9336
|
if (args.src) {
|
|
9345
|
-
const exportNames = findExportNames(await (0, node_fs_promises.readFile)(await resolvePath(args.src, { url: config
|
|
9337
|
+
const exportNames = findExportNames(await (0, node_fs_promises.readFile)(await resolvePath(args.src, { url: config.dir }), "utf8"));
|
|
9346
9338
|
if (exportNames && exportNames.length > 0) importNames.push(...exportNames);
|
|
9347
9339
|
}
|
|
9348
9340
|
const lines = [];
|
|
9349
|
-
const fmtImports = importNames.length > 1 ? `
|
|
9350
|
-
${importNames.map((i$1) => " " + i$1 + ",").join("\n")}
|
|
9351
|
-
` : importNames[0] && ` ${importNames[0]} ` || "";
|
|
9341
|
+
const fmtImports = importNames.length > 1 ? `\n${importNames.map((i$1) => " " + i$1 + ",").join("\n")}\n` : importNames[0] && ` ${importNames[0]} ` || "";
|
|
9352
9342
|
const formatMultiLine = (str) => {
|
|
9353
9343
|
return str.length > (args.printWidth || 80) ? str : str.replace(/\n/g, "").replace(/,\s*}/, "}").replace(/(\w)}/, "$1 }").replace(/\s+/g, " ");
|
|
9354
9344
|
};
|
|
@@ -9380,10 +9370,10 @@ const withAutomd = defineGenerator({
|
|
|
9380
9370
|
});
|
|
9381
9371
|
const file = defineGenerator({
|
|
9382
9372
|
name: "file",
|
|
9383
|
-
async generate({ args, config
|
|
9373
|
+
async generate({ args, config, url }) {
|
|
9384
9374
|
const fullPath = resolvePath$1(args.src, {
|
|
9385
9375
|
url,
|
|
9386
|
-
dir: config
|
|
9376
|
+
dir: config.dir
|
|
9387
9377
|
});
|
|
9388
9378
|
let contents = await (0, node_fs_promises.readFile)(fullPath, "utf8");
|
|
9389
9379
|
if (!args.noTrim) contents = contents.trim();
|
|
@@ -9406,13 +9396,13 @@ const PROVIDERS = {
|
|
|
9406
9396
|
};
|
|
9407
9397
|
const contributors = defineGenerator({
|
|
9408
9398
|
name: "contributors",
|
|
9409
|
-
async generate({ config
|
|
9410
|
-
const { github } = await getPkg(config
|
|
9399
|
+
async generate({ config, args }) {
|
|
9400
|
+
const { github } = await getPkg(config.dir, args);
|
|
9411
9401
|
const provider = args.provider || PROVIDERS.CONTRIB_ROCKS;
|
|
9412
9402
|
if (!github) throw new Error("`github` is required!");
|
|
9413
9403
|
const lines = [];
|
|
9414
9404
|
if (typeof args.license === "string") lines.push(`Published under the [${args.license.toUpperCase()}](https://github.com/${github}/blob/main/LICENSE) license.`);
|
|
9415
|
-
let madeBy = `[community](https://github.com/${github}/graphs/contributors)
|
|
9405
|
+
let madeBy = `[community](https://github.com/${github}/graphs/contributors) 💛`;
|
|
9416
9406
|
if (typeof args.author === "string") {
|
|
9417
9407
|
const authors = args.author.split(",").map((author) => author.trim()).map((user) => `[@${user}](https://github.com/${user})`).join(", ");
|
|
9418
9408
|
if (authors.length > 0) madeBy = `${authors} and ${madeBy}`;
|
|
@@ -9446,7 +9436,86 @@ const contributors = defineGenerator({
|
|
|
9446
9436
|
return { contents: lines.join("\n") };
|
|
9447
9437
|
}
|
|
9448
9438
|
});
|
|
9449
|
-
const
|
|
9439
|
+
const DEFAULT_IGNORE = [
|
|
9440
|
+
"node_modules",
|
|
9441
|
+
".git",
|
|
9442
|
+
".DS_Store",
|
|
9443
|
+
".nuxt",
|
|
9444
|
+
".output",
|
|
9445
|
+
".nitro",
|
|
9446
|
+
"dist",
|
|
9447
|
+
"coverage",
|
|
9448
|
+
".cache",
|
|
9449
|
+
".turbo"
|
|
9450
|
+
];
|
|
9451
|
+
async function parseGitignore(dir) {
|
|
9452
|
+
try {
|
|
9453
|
+
return (await (0, node_fs_promises.readFile)(join(dir, ".gitignore"), "utf8")).split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
9454
|
+
} catch {
|
|
9455
|
+
return [];
|
|
9456
|
+
}
|
|
9457
|
+
}
|
|
9458
|
+
function shouldIgnore(name, ignorePatterns, defaultIgnore) {
|
|
9459
|
+
const allPatterns = [...defaultIgnore, ...ignorePatterns];
|
|
9460
|
+
for (const pattern of allPatterns) {
|
|
9461
|
+
if (name === pattern.replace(/^\//, "").replace(/\/$/, "")) return true;
|
|
9462
|
+
if (pattern.startsWith("*") && name.endsWith(pattern.slice(1))) return true;
|
|
9463
|
+
if (pattern.endsWith("*") && name.startsWith(pattern.slice(0, -1))) return true;
|
|
9464
|
+
}
|
|
9465
|
+
return false;
|
|
9466
|
+
}
|
|
9467
|
+
async function buildTree(dir, ignorePatterns, maxDepth, currentDepth = 0) {
|
|
9468
|
+
if (maxDepth > 0 && currentDepth >= maxDepth) return [];
|
|
9469
|
+
const entries = await (0, node_fs_promises.readdir)(dir);
|
|
9470
|
+
const result = [];
|
|
9471
|
+
for (const entry of entries) {
|
|
9472
|
+
if (shouldIgnore(entry, ignorePatterns, DEFAULT_IGNORE)) continue;
|
|
9473
|
+
const fullPath = join(dir, entry);
|
|
9474
|
+
const isDirectory$1 = (await (0, node_fs_promises.stat)(fullPath)).isDirectory();
|
|
9475
|
+
const treeEntry = {
|
|
9476
|
+
name: entry,
|
|
9477
|
+
isDirectory: isDirectory$1
|
|
9478
|
+
};
|
|
9479
|
+
if (isDirectory$1) treeEntry.children = await buildTree(fullPath, ignorePatterns, maxDepth, currentDepth + 1);
|
|
9480
|
+
result.push(treeEntry);
|
|
9481
|
+
}
|
|
9482
|
+
result.sort((a, b) => {
|
|
9483
|
+
if (a.isDirectory !== b.isDirectory) return a.isDirectory ? -1 : 1;
|
|
9484
|
+
return a.name.localeCompare(b.name);
|
|
9485
|
+
});
|
|
9486
|
+
return result;
|
|
9487
|
+
}
|
|
9488
|
+
function renderTree(entries, isLast = []) {
|
|
9489
|
+
const lines = [];
|
|
9490
|
+
for (let i$1 = 0; i$1 < entries.length; i$1++) {
|
|
9491
|
+
const entry = entries[i$1];
|
|
9492
|
+
const isLastEntry = i$1 === entries.length - 1;
|
|
9493
|
+
let linePrefix = "";
|
|
9494
|
+
for (const element_ of isLast) linePrefix += element_ ? " " : "│ ";
|
|
9495
|
+
const connector = isLastEntry ? "└── " : "├── ";
|
|
9496
|
+
const suffix = entry.isDirectory ? "/" : "";
|
|
9497
|
+
lines.push(`${linePrefix}${connector}${entry.name}${suffix}`);
|
|
9498
|
+
if (entry.children && entry.children.length > 0) {
|
|
9499
|
+
const childLines = renderTree(entry.children, [...isLast, isLastEntry]);
|
|
9500
|
+
lines.push(...childLines);
|
|
9501
|
+
}
|
|
9502
|
+
}
|
|
9503
|
+
return lines;
|
|
9504
|
+
}
|
|
9505
|
+
const dirTree = defineGenerator({
|
|
9506
|
+
name: "dir-tree",
|
|
9507
|
+
async generate({ args, config, url }) {
|
|
9508
|
+
const srcPath = args.src || ".";
|
|
9509
|
+
const fullPath = resolvePath$1(srcPath, {
|
|
9510
|
+
url,
|
|
9511
|
+
dir: config.dir
|
|
9512
|
+
});
|
|
9513
|
+
if (!(await (0, node_fs_promises.stat)(fullPath)).isDirectory()) throw new Error(`Path "${srcPath}" is not a directory`);
|
|
9514
|
+
const userIgnore = args.ignore ? String(args.ignore).split(",").map((s) => s.trim()) : [];
|
|
9515
|
+
return { contents: "```\n" + renderTree(await buildTree(fullPath, [...await parseGitignore(fullPath), ...userIgnore], args.maxDepth ? Number(args.maxDepth) : 0)).join("\n") + "\n```" };
|
|
9516
|
+
}
|
|
9517
|
+
});
|
|
9518
|
+
var generators_default = {
|
|
9450
9519
|
jsdocs,
|
|
9451
9520
|
badges,
|
|
9452
9521
|
"pm-i": pmInstall,
|
|
@@ -9456,21 +9525,16 @@ const builtinGenerators = {
|
|
|
9456
9525
|
file,
|
|
9457
9526
|
jsimport,
|
|
9458
9527
|
"with-automd": withAutomd,
|
|
9459
|
-
contributors
|
|
9528
|
+
contributors,
|
|
9529
|
+
"dir-tree": dirTree
|
|
9460
9530
|
};
|
|
9461
|
-
function
|
|
9462
|
-
return !config$1?.prefix || !Array.isArray(config$1.prefix) ? "automd" : config$1.prefix.length > 1 ? `(${config$1.prefix.join("|")})` : config$1.prefix;
|
|
9463
|
-
}
|
|
9464
|
-
function findBlocks(md, config$1) {
|
|
9531
|
+
function findBlocks(md) {
|
|
9465
9532
|
const blocks = [];
|
|
9466
|
-
const
|
|
9467
|
-
const AUTOMD_RE = new RegExp(`^(?<open><!--\\s*${prefix}:(?<generator>.+?)\\s+(?<args>.*?)\\s*-->)(?<contents>.+?)(?<close>^<!--\\s*\\/${prefix}\\s*-->)`, "gimsu");
|
|
9468
|
-
for (const match of md.matchAll(AUTOMD_RE)) {
|
|
9533
|
+
for (const match of md.matchAll(/^(?<open><!--\s*automd:(?<generator>.+?)\s+(?<args>.*?)\s*-->)(?<contents>.+?)(?<close>^<!--\s*\/automd\s*-->)/gimsu)) {
|
|
9469
9534
|
if (match.index === void 0 || !match.groups) continue;
|
|
9470
|
-
const start = match.index + match.groups.open.length;
|
|
9535
|
+
const start = match.index + match.groups.open.length || 0;
|
|
9471
9536
|
const end = start + match.groups.contents.length;
|
|
9472
9537
|
blocks.push({
|
|
9473
|
-
md,
|
|
9474
9538
|
generator: match.groups.generator,
|
|
9475
9539
|
rawArgs: match.groups.args,
|
|
9476
9540
|
contents: match.groups.contents,
|
|
@@ -9487,11 +9551,10 @@ function findBlocks(md, config$1) {
|
|
|
9487
9551
|
return blocks;
|
|
9488
9552
|
}
|
|
9489
9553
|
function containsAutomd(md) {
|
|
9490
|
-
|
|
9491
|
-
return new RegExp(`^<!--\\s*${prefix}:`, "gimsu").test(md);
|
|
9554
|
+
return /^<!--\s*automd:/gimsu.test(md);
|
|
9492
9555
|
}
|
|
9493
9556
|
function parseRawArgs(rawArgs) {
|
|
9494
|
-
const args =
|
|
9557
|
+
const args = Object.create(null);
|
|
9495
9558
|
for (const part of rawArgs.split(/\s+/)) {
|
|
9496
9559
|
const [_key, value] = part.split("=");
|
|
9497
9560
|
const key = _key && require_dist$1.camelCase(_key);
|
|
@@ -9502,25 +9565,23 @@ function parseRawArgs(rawArgs) {
|
|
|
9502
9565
|
return args;
|
|
9503
9566
|
}
|
|
9504
9567
|
const RESOLVED_CONFIG_SYMBOL = Symbol("automdConfig");
|
|
9505
|
-
function resolveConfig(config
|
|
9506
|
-
if (config
|
|
9568
|
+
function resolveConfig(config) {
|
|
9569
|
+
if (config && RESOLVED_CONFIG_SYMBOL in config) return config;
|
|
9507
9570
|
const _config = {
|
|
9508
9571
|
dir: ".",
|
|
9509
9572
|
input: "README.md",
|
|
9510
9573
|
generators: {},
|
|
9511
9574
|
[RESOLVED_CONFIG_SYMBOL]: true,
|
|
9512
|
-
...config
|
|
9575
|
+
...config
|
|
9513
9576
|
};
|
|
9514
9577
|
_config.dir = resolve(_config.dir);
|
|
9515
9578
|
_config.input = (Array.isArray(_config.input) ? _config.input : [_config.input]).filter(Boolean);
|
|
9516
|
-
_config.prefix = Array.isArray(_config.prefix) ? _config.prefix : [_config.prefix];
|
|
9517
|
-
if (!_config.prefix.includes("automd")) _config.prefix.push("automd");
|
|
9518
9579
|
return _config;
|
|
9519
9580
|
}
|
|
9520
9581
|
async function loadConfig(dir = ".", overrides) {
|
|
9521
|
-
const { loadConfig:
|
|
9582
|
+
const { loadConfig: loadConfig$1 } = await import("c12");
|
|
9522
9583
|
dir = resolve(dir);
|
|
9523
|
-
const { config
|
|
9584
|
+
const { config } = await loadConfig$1({
|
|
9524
9585
|
cwd: dir,
|
|
9525
9586
|
name: "automd",
|
|
9526
9587
|
dotenv: true,
|
|
@@ -9534,26 +9595,22 @@ async function loadConfig(dir = ".", overrides) {
|
|
|
9534
9595
|
dir
|
|
9535
9596
|
}
|
|
9536
9597
|
});
|
|
9537
|
-
return resolveConfig(config
|
|
9598
|
+
return resolveConfig(config);
|
|
9538
9599
|
}
|
|
9539
9600
|
async function transform(contents, _config, url) {
|
|
9540
9601
|
const start = performance.now();
|
|
9541
|
-
const config
|
|
9602
|
+
const config = resolveConfig(_config);
|
|
9542
9603
|
const editor = new MagicString(contents);
|
|
9543
9604
|
const updates = [];
|
|
9544
9605
|
const generators = {
|
|
9545
|
-
...
|
|
9546
|
-
...config
|
|
9606
|
+
...generators_default,
|
|
9607
|
+
...config.generators
|
|
9547
9608
|
};
|
|
9548
|
-
const blocks = findBlocks(contents
|
|
9609
|
+
const blocks = findBlocks(contents);
|
|
9549
9610
|
for (const block of blocks) {
|
|
9550
|
-
const result = await _transformBlock(block, config
|
|
9611
|
+
const result = await _transformBlock(block, config, generators, url);
|
|
9551
9612
|
if (result.unwrap) editor.overwrite(block._loc.start, block._loc.end, `${result.contents.trim()}`);
|
|
9552
|
-
else editor.overwrite(block.loc.start, block.loc.end, `
|
|
9553
|
-
|
|
9554
|
-
${result.contents.trim()}
|
|
9555
|
-
|
|
9556
|
-
`);
|
|
9613
|
+
else editor.overwrite(block.loc.start, block.loc.end, `\n\n${result.contents.trim()}\n\n`);
|
|
9557
9614
|
updates.push({
|
|
9558
9615
|
block,
|
|
9559
9616
|
result
|
|
@@ -9570,22 +9627,22 @@ ${result.contents.trim()}
|
|
|
9570
9627
|
time
|
|
9571
9628
|
};
|
|
9572
9629
|
}
|
|
9573
|
-
async function _transformBlock(block, config
|
|
9630
|
+
async function _transformBlock(block, config, generators, url) {
|
|
9574
9631
|
const args = parseRawArgs(block.rawArgs);
|
|
9575
9632
|
const generator = generators[block.generator];
|
|
9576
9633
|
if (!generator) {
|
|
9577
9634
|
const suggestions = (await Promise.resolve().then(() => require("./dist-BavrV299.cjs")).then((r$1) => r$1.default || r$1))(block.generator, Object.keys(generators));
|
|
9578
9635
|
const error = `Unknown generator:\`${block.generator}\`.${suggestions ? ` Did you mean "generator:\`${suggestions}\`"?` : ""}`;
|
|
9579
9636
|
return {
|
|
9580
|
-
contents: `<!--
|
|
9637
|
+
contents: `<!-- ⚠️ ${error} -->`,
|
|
9581
9638
|
issues: [error]
|
|
9582
9639
|
};
|
|
9583
9640
|
}
|
|
9584
9641
|
const context = {
|
|
9585
9642
|
args,
|
|
9586
|
-
config
|
|
9643
|
+
config,
|
|
9587
9644
|
block,
|
|
9588
|
-
transform: (contents) => transform(contents, config
|
|
9645
|
+
transform: (contents) => transform(contents, config, url),
|
|
9589
9646
|
url
|
|
9590
9647
|
};
|
|
9591
9648
|
try {
|
|
@@ -9599,7 +9656,7 @@ async function _transformBlock(block, config$1, generators, url) {
|
|
|
9599
9656
|
return result;
|
|
9600
9657
|
} catch (error) {
|
|
9601
9658
|
return {
|
|
9602
|
-
contents: `<!--
|
|
9659
|
+
contents: `<!-- ⚠️ (${block.generator}) ${error.message || error} -->`,
|
|
9603
9660
|
issues: [error]
|
|
9604
9661
|
};
|
|
9605
9662
|
}
|
|
@@ -9622,11 +9679,11 @@ const plugin = (options = {}) => {
|
|
|
9622
9679
|
return {
|
|
9623
9680
|
name: "automd",
|
|
9624
9681
|
async config() {
|
|
9625
|
-
const config
|
|
9626
|
-
if (!config
|
|
9627
|
-
if (!config
|
|
9628
|
-
if (!config
|
|
9629
|
-
return { automd: (0, defu.default)(config
|
|
9682
|
+
const config = await loadConfig((0, __stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot), options);
|
|
9683
|
+
if (!config.prefix || !Array.isArray(config.prefix)) config.prefix = (0, __stryke_convert_to_array.toArray)(config.prefix ?? []);
|
|
9684
|
+
if (!config.prefix.includes("automd")) config.prefix.push("automd");
|
|
9685
|
+
if (!config.prefix.includes("powerlines")) config.prefix.push("powerlines");
|
|
9686
|
+
return { automd: (0, defu.default)(config ?? {}, {
|
|
9630
9687
|
configFile: options.configFile,
|
|
9631
9688
|
allowIssues: true,
|
|
9632
9689
|
dir: this.config.projectRoot,
|
|
@@ -9641,7 +9698,7 @@ const plugin = (options = {}) => {
|
|
|
9641
9698
|
async configResolved() {
|
|
9642
9699
|
if (this.config.framework && !(0, __stryke_convert_to_array.toArray)(this.config.automd.prefix).includes(this.config.framework)) this.config.automd.prefix = (0, __stryke_convert_to_array.toArray)(this.config.automd.prefix).concat(this.config.framework);
|
|
9643
9700
|
if (this.config.automd.configFile) {
|
|
9644
|
-
const { config
|
|
9701
|
+
const { config } = await (0, c12.loadConfig)({
|
|
9645
9702
|
cwd: this.config.automd.dir,
|
|
9646
9703
|
configFile: this.config.automd.configFile,
|
|
9647
9704
|
defaults: {
|
|
@@ -9654,8 +9711,8 @@ const plugin = (options = {}) => {
|
|
|
9654
9711
|
}
|
|
9655
9712
|
});
|
|
9656
9713
|
this.config.automd = resolveConfig((0, defu.default)(this.config.automd, {
|
|
9657
|
-
...config
|
|
9658
|
-
prefix: (0, __stryke_convert_to_array.toArray)(config
|
|
9714
|
+
...config,
|
|
9715
|
+
prefix: (0, __stryke_convert_to_array.toArray)(config.prefix ?? [])
|
|
9659
9716
|
}));
|
|
9660
9717
|
}
|
|
9661
9718
|
this.config.automd.input = (await Promise.all((0, __stryke_convert_to_array.toArray)(this.config.automd.input).map(async (input) => {
|