@powerlines/plugin-automd 0.1.456 → 0.1.458

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.
@@ -1 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
package/dist/index.cjs CHANGED
@@ -1 +1,102 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`);let t=require(`@stryke/convert/to-array`),n=require(`@stryke/fs/is-file`),r=require(`@stryke/fs/list-files`),i=require(`@stryke/path/append`),a=require(`@stryke/path/is-type`),o=require(`@stryke/path/join-paths`),s=require(`@stryke/path/replace`),c=require(`automd`),l=require(`c12`),u=require(`defu`);u=e.__toESM(u,1);let d=require(`markdown-toc`);d=e.__toESM(d,1);const f=(e={})=>({name:`automd`,async config(){let n=await(0,c.loadConfig)((0,o.joinPaths)(this.config.cwd||process.cwd(),this.config.root),e);return(!n.prefix||!Array.isArray(n.prefix))&&(n.prefix=(0,t.toArray)(n.prefix??[])),n.prefix.includes(`automd`)||n.prefix.push(`automd`),n.prefix.includes(`powerlines`)||n.prefix.push(`powerlines`),{automd:(0,u.default)(n??{},{configFile:e.configFile,allowIssues:!0,dir:this.config.root,watch:!1,input:`README.md`,toc:{maxDepth:6,bullets:`-`}})}},async configResolved(){if(this.config.framework&&!(0,t.toArray)(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=(0,t.toArray)(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:e}=await(0,l.loadConfig)({cwd:this.config.automd.dir,configFile:this.config.automd.configFile,defaults:{ignore:[`**/node_modules`,`**/dist`,`**/.*`],dir:this.config.automd.dir}});this.config.automd=(0,c.resolveConfig)((0,u.default)(this.config.automd,{...e,prefix:(0,t.toArray)(e.prefix??[])}))}this.config.automd.input=(await Promise.all((0,t.toArray)(this.config.automd.input).map(async e=>e.includes(`*`)?(0,r.listFiles)((0,a.isAbsolutePath)(e)?e:(0,i.appendPath)(e,this.config.root),{ignore:this.config.automd.ignore}):(0,a.isAbsolutePath)(e)?e:(0,i.appendPath)(e,this.config.root)))).flat(),this.config.automd.output&&!(0,a.isAbsolutePath)(this.config.automd.output)&&(this.config.automd.output=(0,i.appendPath)(this.config.automd.output,this.config.root)),this.config.automd.generators??={},this.config.automd.toc!==!1&&(this.config.automd.generators.toc??={name:`toc`,generate:e=>{let t=this.config.automd.toc??{};return{contents:(0,d.default)(e.block.contents,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all((0,t.toArray)(this.config.automd.input).map(async e=>{let t=await this.fs.read(e);if(t){let r=await(0,c.transform)(t,this.config.automd);if(r.hasIssues&&this.config.automd.allowIssues===!1)throw Error(`AutoMD found issues in file "${e}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);r.hasChanged&&await this.fs.write((0,i.appendPath)(this.config.automd.output?(0,n.isDirectory)(this.config.automd.output)?(0,s.replacePath)(e,this.config.automd.output):this.config.automd.output:e,this.config.root),r.contents)}}))}});exports.default=f,exports.plugin=f;
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ let _stryke_convert_to_array = require("@stryke/convert/to-array");
4
+ let _stryke_fs_is_file = require("@stryke/fs/is-file");
5
+ let _stryke_fs_list_files = require("@stryke/fs/list-files");
6
+ let _stryke_path_append = require("@stryke/path/append");
7
+ let _stryke_path_is_type = require("@stryke/path/is-type");
8
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
9
+ let _stryke_path_replace = require("@stryke/path/replace");
10
+ let automd = require("automd");
11
+ let c12 = require("c12");
12
+ let defu = require("defu");
13
+ defu = require_runtime.__toESM(defu, 1);
14
+ let markdown_toc = require("markdown-toc");
15
+ markdown_toc = require_runtime.__toESM(markdown_toc, 1);
16
+
17
+ //#region src/index.ts
18
+ /**
19
+ * AutoMD Plugin
20
+ *
21
+ * @remarks
22
+ * A Powerlines plugin to use the AutoMD markdown transformer during the prepare task.
23
+ *
24
+ * @see https://automd.unjs.io/
25
+ *
26
+ * @param options - The plugin options.
27
+ * @returns A Powerlines plugin instance.
28
+ */
29
+ const plugin = (options = {}) => {
30
+ return {
31
+ name: "automd",
32
+ async config() {
33
+ const config = await (0, automd.loadConfig)((0, _stryke_path_join_paths.joinPaths)(this.config.cwd || process.cwd(), this.config.root), options);
34
+ if (!config.prefix || !Array.isArray(config.prefix)) config.prefix = (0, _stryke_convert_to_array.toArray)(config.prefix ?? []);
35
+ if (!config.prefix.includes("automd")) config.prefix.push("automd");
36
+ if (!config.prefix.includes("powerlines")) config.prefix.push("powerlines");
37
+ return { automd: (0, defu.default)(config ?? {}, {
38
+ configFile: options.configFile,
39
+ allowIssues: true,
40
+ dir: this.config.root,
41
+ watch: false,
42
+ input: "README.md",
43
+ toc: {
44
+ maxDepth: 6,
45
+ bullets: "-"
46
+ }
47
+ }) };
48
+ },
49
+ async configResolved() {
50
+ 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);
51
+ if (this.config.automd.configFile) {
52
+ const { config } = await (0, c12.loadConfig)({
53
+ cwd: this.config.automd.dir,
54
+ configFile: this.config.automd.configFile,
55
+ defaults: {
56
+ ignore: [
57
+ "**/node_modules",
58
+ "**/dist",
59
+ "**/.*"
60
+ ],
61
+ dir: this.config.automd.dir
62
+ }
63
+ });
64
+ this.config.automd = (0, automd.resolveConfig)((0, defu.default)(this.config.automd, {
65
+ ...config,
66
+ prefix: (0, _stryke_convert_to_array.toArray)(config.prefix ?? [])
67
+ }));
68
+ }
69
+ this.config.automd.input = (await Promise.all((0, _stryke_convert_to_array.toArray)(this.config.automd.input).map(async (input) => {
70
+ if (input.includes("*")) return (0, _stryke_fs_list_files.listFiles)((0, _stryke_path_is_type.isAbsolutePath)(input) ? input : (0, _stryke_path_append.appendPath)(input, this.config.root), { ignore: this.config.automd.ignore });
71
+ return (0, _stryke_path_is_type.isAbsolutePath)(input) ? input : (0, _stryke_path_append.appendPath)(input, this.config.root);
72
+ }))).flat();
73
+ if (this.config.automd.output && !(0, _stryke_path_is_type.isAbsolutePath)(this.config.automd.output)) this.config.automd.output = (0, _stryke_path_append.appendPath)(this.config.automd.output, this.config.root);
74
+ this.config.automd.generators ??= {};
75
+ if (this.config.automd.toc !== false) this.config.automd.generators.toc ??= {
76
+ name: "toc",
77
+ generate: (ctx) => {
78
+ const opts = this.config.automd.toc ?? {};
79
+ return { contents: (0, markdown_toc.default)(ctx.block.contents, {
80
+ ...opts,
81
+ maxdepth: opts.maxDepth,
82
+ first1: opts.firstH1
83
+ }).content };
84
+ }
85
+ };
86
+ },
87
+ async docs() {
88
+ await Promise.all((0, _stryke_convert_to_array.toArray)(this.config.automd.input).map(async (input) => {
89
+ const contents = await this.fs.read(input);
90
+ if (contents) {
91
+ const result = await (0, automd.transform)(contents, this.config.automd);
92
+ if (result.hasIssues && this.config.automd.allowIssues === false) throw new Error(`AutoMD found issues in file "${input}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);
93
+ if (result.hasChanged) await this.fs.write((0, _stryke_path_append.appendPath)(this.config.automd.output ? (0, _stryke_fs_is_file.isDirectory)(this.config.automd.output) ? (0, _stryke_path_replace.replacePath)(input, this.config.automd.output) : this.config.automd.output : input, this.config.root), result.contents);
94
+ }
95
+ }));
96
+ }
97
+ };
98
+ };
99
+
100
+ //#endregion
101
+ exports.default = plugin;
102
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1,2 +1,98 @@
1
- import{toArray as e}from"@stryke/convert/to-array";import{isDirectory as t}from"@stryke/fs/is-file";import{listFiles as n}from"@stryke/fs/list-files";import{appendPath as r}from"@stryke/path/append";import{isAbsolutePath as i}from"@stryke/path/is-type";import{joinPaths as a}from"@stryke/path/join-paths";import{replacePath as o}from"@stryke/path/replace";import{loadConfig as s,resolveConfig as c,transform as l}from"automd";import{loadConfig as u}from"c12";import d from"defu";import f from"markdown-toc";const p=(p={})=>({name:`automd`,async config(){let t=await s(a(this.config.cwd||process.cwd(),this.config.root),p);return(!t.prefix||!Array.isArray(t.prefix))&&(t.prefix=e(t.prefix??[])),t.prefix.includes(`automd`)||t.prefix.push(`automd`),t.prefix.includes(`powerlines`)||t.prefix.push(`powerlines`),{automd:d(t??{},{configFile:p.configFile,allowIssues:!0,dir:this.config.root,watch:!1,input:`README.md`,toc:{maxDepth:6,bullets:`-`}})}},async configResolved(){if(this.config.framework&&!e(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=e(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:t}=await u({cwd:this.config.automd.dir,configFile:this.config.automd.configFile,defaults:{ignore:[`**/node_modules`,`**/dist`,`**/.*`],dir:this.config.automd.dir}});this.config.automd=c(d(this.config.automd,{...t,prefix:e(t.prefix??[])}))}this.config.automd.input=(await Promise.all(e(this.config.automd.input).map(async e=>e.includes(`*`)?n(i(e)?e:r(e,this.config.root),{ignore:this.config.automd.ignore}):i(e)?e:r(e,this.config.root)))).flat(),this.config.automd.output&&!i(this.config.automd.output)&&(this.config.automd.output=r(this.config.automd.output,this.config.root)),this.config.automd.generators??={},this.config.automd.toc!==!1&&(this.config.automd.generators.toc??={name:`toc`,generate:e=>{let t=this.config.automd.toc??{};return{contents:f(e.block.contents,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all(e(this.config.automd.input).map(async e=>{let n=await this.fs.read(e);if(n){let i=await l(n,this.config.automd);if(i.hasIssues&&this.config.automd.allowIssues===!1)throw Error(`AutoMD found issues in file "${e}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);i.hasChanged&&await this.fs.write(r(this.config.automd.output?t(this.config.automd.output)?o(e,this.config.automd.output):this.config.automd.output:e,this.config.root),i.contents)}}))}});export{p as default,p as plugin};
1
+ import { toArray } from "@stryke/convert/to-array";
2
+ import { isDirectory } from "@stryke/fs/is-file";
3
+ import { listFiles } from "@stryke/fs/list-files";
4
+ import { appendPath } from "@stryke/path/append";
5
+ import { isAbsolutePath } from "@stryke/path/is-type";
6
+ import { joinPaths } from "@stryke/path/join-paths";
7
+ import { replacePath } from "@stryke/path/replace";
8
+ import { loadConfig, resolveConfig, transform } from "automd";
9
+ import { loadConfig as loadConfig$1 } from "c12";
10
+ import defu from "defu";
11
+ import toc from "markdown-toc";
12
+
13
+ //#region src/index.ts
14
+ /**
15
+ * AutoMD Plugin
16
+ *
17
+ * @remarks
18
+ * A Powerlines plugin to use the AutoMD markdown transformer during the prepare task.
19
+ *
20
+ * @see https://automd.unjs.io/
21
+ *
22
+ * @param options - The plugin options.
23
+ * @returns A Powerlines plugin instance.
24
+ */
25
+ const plugin = (options = {}) => {
26
+ return {
27
+ name: "automd",
28
+ async config() {
29
+ const config = await loadConfig(joinPaths(this.config.cwd || process.cwd(), this.config.root), options);
30
+ if (!config.prefix || !Array.isArray(config.prefix)) config.prefix = toArray(config.prefix ?? []);
31
+ if (!config.prefix.includes("automd")) config.prefix.push("automd");
32
+ if (!config.prefix.includes("powerlines")) config.prefix.push("powerlines");
33
+ return { automd: defu(config ?? {}, {
34
+ configFile: options.configFile,
35
+ allowIssues: true,
36
+ dir: this.config.root,
37
+ watch: false,
38
+ input: "README.md",
39
+ toc: {
40
+ maxDepth: 6,
41
+ bullets: "-"
42
+ }
43
+ }) };
44
+ },
45
+ async configResolved() {
46
+ 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);
47
+ if (this.config.automd.configFile) {
48
+ const { config } = await loadConfig$1({
49
+ cwd: this.config.automd.dir,
50
+ configFile: this.config.automd.configFile,
51
+ defaults: {
52
+ ignore: [
53
+ "**/node_modules",
54
+ "**/dist",
55
+ "**/.*"
56
+ ],
57
+ dir: this.config.automd.dir
58
+ }
59
+ });
60
+ this.config.automd = resolveConfig(defu(this.config.automd, {
61
+ ...config,
62
+ prefix: toArray(config.prefix ?? [])
63
+ }));
64
+ }
65
+ this.config.automd.input = (await Promise.all(toArray(this.config.automd.input).map(async (input) => {
66
+ if (input.includes("*")) return listFiles(isAbsolutePath(input) ? input : appendPath(input, this.config.root), { ignore: this.config.automd.ignore });
67
+ return isAbsolutePath(input) ? input : appendPath(input, this.config.root);
68
+ }))).flat();
69
+ if (this.config.automd.output && !isAbsolutePath(this.config.automd.output)) this.config.automd.output = appendPath(this.config.automd.output, this.config.root);
70
+ this.config.automd.generators ??= {};
71
+ if (this.config.automd.toc !== false) this.config.automd.generators.toc ??= {
72
+ name: "toc",
73
+ generate: (ctx) => {
74
+ const opts = this.config.automd.toc ?? {};
75
+ return { contents: toc(ctx.block.contents, {
76
+ ...opts,
77
+ maxdepth: opts.maxDepth,
78
+ first1: opts.firstH1
79
+ }).content };
80
+ }
81
+ };
82
+ },
83
+ async docs() {
84
+ await Promise.all(toArray(this.config.automd.input).map(async (input) => {
85
+ const contents = await this.fs.read(input);
86
+ if (contents) {
87
+ const result = await transform(contents, this.config.automd);
88
+ if (result.hasIssues && this.config.automd.allowIssues === false) throw new Error(`AutoMD found issues in file "${input}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);
89
+ if (result.hasChanged) await this.fs.write(appendPath(this.config.automd.output ? isDirectory(this.config.automd.output) ? replacePath(input, this.config.automd.output) : this.config.automd.output : input, this.config.root), result.contents);
90
+ }
91
+ }));
92
+ }
93
+ };
94
+ };
95
+
96
+ //#endregion
97
+ export { plugin as default, plugin };
2
98
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["loadConfigFile"],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isDirectory } from \"@stryke/fs/is-file\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport {\n Config,\n GenerateContext,\n GenerateResult,\n loadConfig,\n resolveConfig,\n transform\n} from \"automd\";\nimport { loadConfig as loadConfigFile } from \"c12\";\nimport defu from \"defu\";\nimport toc from \"markdown-toc\";\nimport type { Plugin } from \"powerlines\";\nimport { AutoMDPluginContext, AutoMDPluginOptions } from \"./types/plugin\";\nimport { TOCOptions } from \"./types/toc\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n automd?: AutoMDPluginOptions;\n }\n}\n\n/**\n * AutoMD Plugin\n *\n * @remarks\n * A Powerlines plugin to use the AutoMD markdown transformer during the prepare task.\n *\n * @see https://automd.unjs.io/\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends AutoMDPluginContext = AutoMDPluginContext\n>(\n options: AutoMDPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"automd\",\n async config() {\n const config = await loadConfig(\n joinPaths(this.config.cwd || process.cwd(), this.config.root),\n options\n );\n\n if (!config.prefix || !Array.isArray(config.prefix)) {\n config.prefix = toArray(config.prefix ?? []);\n }\n\n if (!config.prefix.includes(\"automd\")) {\n config.prefix.push(\"automd\");\n }\n if (!config.prefix.includes(\"powerlines\")) {\n config.prefix.push(\"powerlines\");\n }\n\n return {\n automd: defu(config ?? {}, {\n configFile: options.configFile,\n allowIssues: true,\n dir: this.config.root,\n watch: false,\n input: \"README.md\",\n toc: {\n maxDepth: 6,\n bullets: \"-\"\n }\n })\n };\n },\n async configResolved() {\n if (\n this.config.framework &&\n !toArray(this.config.automd.prefix).includes(this.config.framework)\n ) {\n this.config.automd.prefix = toArray(this.config.automd.prefix).concat(\n this.config.framework\n );\n }\n\n if (this.config.automd.configFile) {\n const { config } = await loadConfigFile<Config>({\n cwd: this.config.automd.dir,\n configFile: this.config.automd.configFile,\n defaults: {\n ignore: [\"**/node_modules\", \"**/dist\", \"**/.*\"],\n dir: this.config.automd.dir\n }\n });\n\n this.config.automd = resolveConfig(\n defu(this.config.automd, {\n ...config,\n prefix: toArray(config.prefix ?? [])\n }) as Config\n );\n }\n\n this.config.automd.input = (\n await Promise.all(\n toArray(this.config.automd.input).map(async input => {\n if (input.includes(\"*\")) {\n return listFiles(\n isAbsolutePath(input)\n ? input\n : appendPath(input, this.config.root),\n {\n ignore: this.config.automd.ignore\n }\n );\n }\n\n return isAbsolutePath(input)\n ? input\n : appendPath(input, this.config.root);\n })\n )\n ).flat();\n\n if (\n this.config.automd.output &&\n !isAbsolutePath(this.config.automd.output)\n ) {\n this.config.automd.output = appendPath(\n this.config.automd.output,\n this.config.root\n );\n }\n\n this.config.automd.generators ??= {};\n\n if (this.config.automd.toc !== false) {\n this.config.automd.generators.toc ??= {\n name: \"toc\",\n generate: (ctx: GenerateContext): GenerateResult => {\n const opts = (this.config.automd.toc ?? {}) as TOCOptions;\n\n return {\n contents: toc(ctx.block.contents, {\n ...opts,\n maxdepth: opts.maxDepth,\n first1: opts.firstH1\n }).content\n };\n }\n };\n }\n },\n async docs() {\n await Promise.all(\n toArray(this.config.automd.input).map(async input => {\n const contents = await this.fs.read(input);\n if (contents) {\n const result = await transform(contents, this.config.automd);\n if (result.hasIssues && this.config.automd.allowIssues === false) {\n throw new Error(\n `AutoMD found issues in file \"${\n input\n }\". Please resolve the issues or set \\`allowIssues\\` to true in the plugin configuration to ignore them.`\n );\n }\n\n if (result.hasChanged) {\n await this.fs.write(\n appendPath(\n this.config.automd.output\n ? isDirectory(this.config.automd.output)\n ? replacePath(input, this.config.automd.output)\n : this.config.automd.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AAO,OACrB,EACJ,KAAK,OAAO,KACb,CACD,EAAO,SACR,GAGL,CACH,EAEJ"}
1
+ {"version":3,"file":"index.mjs","names":["loadConfigFile"],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isDirectory } from \"@stryke/fs/is-file\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport {\n Config,\n GenerateContext,\n GenerateResult,\n loadConfig,\n resolveConfig,\n transform\n} from \"automd\";\nimport { loadConfig as loadConfigFile } from \"c12\";\nimport defu from \"defu\";\nimport toc from \"markdown-toc\";\nimport type { Plugin } from \"powerlines\";\nimport { AutoMDPluginContext, AutoMDPluginOptions } from \"./types/plugin\";\nimport { TOCOptions } from \"./types/toc\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n automd?: AutoMDPluginOptions;\n }\n}\n\n/**\n * AutoMD Plugin\n *\n * @remarks\n * A Powerlines plugin to use the AutoMD markdown transformer during the prepare task.\n *\n * @see https://automd.unjs.io/\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends AutoMDPluginContext = AutoMDPluginContext\n>(\n options: AutoMDPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"automd\",\n async config() {\n const config = await loadConfig(\n joinPaths(this.config.cwd || process.cwd(), this.config.root),\n options\n );\n\n if (!config.prefix || !Array.isArray(config.prefix)) {\n config.prefix = toArray(config.prefix ?? []);\n }\n\n if (!config.prefix.includes(\"automd\")) {\n config.prefix.push(\"automd\");\n }\n if (!config.prefix.includes(\"powerlines\")) {\n config.prefix.push(\"powerlines\");\n }\n\n return {\n automd: defu(config ?? {}, {\n configFile: options.configFile,\n allowIssues: true,\n dir: this.config.root,\n watch: false,\n input: \"README.md\",\n toc: {\n maxDepth: 6,\n bullets: \"-\"\n }\n })\n };\n },\n async configResolved() {\n if (\n this.config.framework &&\n !toArray(this.config.automd.prefix).includes(this.config.framework)\n ) {\n this.config.automd.prefix = toArray(this.config.automd.prefix).concat(\n this.config.framework\n );\n }\n\n if (this.config.automd.configFile) {\n const { config } = await loadConfigFile<Config>({\n cwd: this.config.automd.dir,\n configFile: this.config.automd.configFile,\n defaults: {\n ignore: [\"**/node_modules\", \"**/dist\", \"**/.*\"],\n dir: this.config.automd.dir\n }\n });\n\n this.config.automd = resolveConfig(\n defu(this.config.automd, {\n ...config,\n prefix: toArray(config.prefix ?? [])\n }) as Config\n );\n }\n\n this.config.automd.input = (\n await Promise.all(\n toArray(this.config.automd.input).map(async input => {\n if (input.includes(\"*\")) {\n return listFiles(\n isAbsolutePath(input)\n ? input\n : appendPath(input, this.config.root),\n {\n ignore: this.config.automd.ignore\n }\n );\n }\n\n return isAbsolutePath(input)\n ? input\n : appendPath(input, this.config.root);\n })\n )\n ).flat();\n\n if (\n this.config.automd.output &&\n !isAbsolutePath(this.config.automd.output)\n ) {\n this.config.automd.output = appendPath(\n this.config.automd.output,\n this.config.root\n );\n }\n\n this.config.automd.generators ??= {};\n\n if (this.config.automd.toc !== false) {\n this.config.automd.generators.toc ??= {\n name: \"toc\",\n generate: (ctx: GenerateContext): GenerateResult => {\n const opts = (this.config.automd.toc ?? {}) as TOCOptions;\n\n return {\n contents: toc(ctx.block.contents, {\n ...opts,\n maxdepth: opts.maxDepth,\n first1: opts.firstH1\n }).content\n };\n }\n };\n }\n },\n async docs() {\n await Promise.all(\n toArray(this.config.automd.input).map(async input => {\n const contents = await this.fs.read(input);\n if (contents) {\n const result = await transform(contents, this.config.automd);\n if (result.hasIssues && this.config.automd.allowIssues === false) {\n throw new Error(\n `AutoMD found issues in file \"${\n input\n }\". Please resolve the issues or set \\`allowIssues\\` to true in the plugin configuration to ignore them.`\n );\n }\n\n if (result.hasChanged) {\n await this.fs.write(\n appendPath(\n this.config.automd.output\n ? isDirectory(this.config.automd.output)\n ? replacePath(input, this.config.automd.output)\n : this.config.automd.output\n : input,\n this.config.root\n ),\n result.contents\n );\n }\n }\n })\n );\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAa,UAGX,UAA+B,EAAE,KACZ;AACrB,QAAO;EACL,MAAM;EACN,MAAM,SAAS;GACb,MAAM,SAAS,MAAM,WACnB,UAAU,KAAK,OAAO,OAAO,QAAQ,KAAK,EAAE,KAAK,OAAO,KAAK,EAC7D,QACD;AAED,OAAI,CAAC,OAAO,UAAU,CAAC,MAAM,QAAQ,OAAO,OAAO,CACjD,QAAO,SAAS,QAAQ,OAAO,UAAU,EAAE,CAAC;AAG9C,OAAI,CAAC,OAAO,OAAO,SAAS,SAAS,CACnC,QAAO,OAAO,KAAK,SAAS;AAE9B,OAAI,CAAC,OAAO,OAAO,SAAS,aAAa,CACvC,QAAO,OAAO,KAAK,aAAa;AAGlC,UAAO,EACL,QAAQ,KAAK,UAAU,EAAE,EAAE;IACzB,YAAY,QAAQ;IACpB,aAAa;IACb,KAAK,KAAK,OAAO;IACjB,OAAO;IACP,OAAO;IACP,KAAK;KACH,UAAU;KACV,SAAS;KACV;IACF,CAAC,EACH;;EAEH,MAAM,iBAAiB;AACrB,OACE,KAAK,OAAO,aACZ,CAAC,QAAQ,KAAK,OAAO,OAAO,OAAO,CAAC,SAAS,KAAK,OAAO,UAAU,C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MACd,CAAC,CAAC,SACJ;;IAEJ;;EAGL,MAAM,OAAO;AACX,SAAM,QAAQ,IACZ,QAAQ,KAAK,OAAO,OAAO,MAAM,CAAC,IAAI,OAAM,UAAS;IACnD,MAAM,WAAW,MAAM,KAAK,GAAG,KAAK,MAAM;AAC1C,QAAI,UAAU;KACZ,MAAM,SAAS,MAAM,UAAU,UAAU,KAAK,OAAO,OAAO;AAC5D,SAAI,OAAO,aAAa,KAAK,OAAO,OAAO,gBAAgB,MACzD,OAAM,IAAI,MACR,gCACE,MACD,yGACF;AAGH,SAAI,OAAO,WACT,OAAM,KAAK,GAAG,MACZ,WACE,KAAK,OAAO,OAAO,SACf,YAAY,KAAK,OAAO,OAAO,OAAO,GACpC,YAAY,OAAO,KAAK,OAAO,OAAO,OAAO,GAC7C,KAAK,OAAO,OAAO,SACrB,OACJ,KAAK,OAAO,KACb,EACD,OAAO,SACR;;KAGL,CACH;;EAEJ"}
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1 @@
1
- export{};
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-automd",
3
- "version": "0.1.456",
3
+ "version": "0.1.458",
4
4
  "private": false,
5
5
  "description": "A Powerlines plugin to maintain a project's markdown files using AutoMD generators.",
6
6
  "keywords": ["automd", "powerlines", "storm-software", "powerlines-plugin"],
@@ -114,10 +114,10 @@
114
114
  "markdown-toc": "^1.2.0"
115
115
  },
116
116
  "devDependencies": {
117
- "@powerlines/plugin-plugin": "^0.12.407",
117
+ "@powerlines/plugin-plugin": "^0.12.409",
118
118
  "@types/node": "^25.6.0",
119
119
  "automd": "^0.4.3"
120
120
  },
121
121
  "publishConfig": { "access": "public" },
122
- "gitHead": "9a51041e0817e438c49db05bb757b3bdbaf497ef"
122
+ "gitHead": "9af888c54e58a82744cc334a6b80da52429fa0ac"
123
123
  }