@powerlines/plugin-nodejs 0.1.0 → 0.1.1
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/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/components/env.cjs +188 -2
- package/dist/components/env.d.cts +9 -2
- package/dist/components/env.d.mts +9 -2
- package/dist/components/env.mjs +185 -1
- package/dist/components/index.cjs +2 -3
- package/dist/components/index.d.cts +1 -3
- package/dist/components/index.d.mts +1 -3
- package/dist/components/index.mjs +1 -2
- package/dist/deepkit/schemas/reflection.cjs +3940 -0
- package/dist/{plugin-D7kBf19k.d.cts → deepkit/schemas/reflection.d.cts} +1 -1078
- package/dist/{plugin-JL1BtFku.d.mts → deepkit/schemas/reflection.d.mts} +59 -1136
- package/dist/deepkit/schemas/reflection.mjs +3938 -0
- package/dist/deepkit/schemas/reflection2.cjs +4112 -0
- package/dist/deepkit/schemas/reflection2.mjs +4110 -0
- package/dist/deepkit/src/capnp.cjs +913 -0
- package/dist/deepkit/src/capnp.mjs +911 -0
- package/dist/deepkit/src/esbuild-plugin.cjs +47 -0
- package/dist/deepkit/src/esbuild-plugin.mjs +46 -0
- package/dist/deepkit/src/reflect-type.cjs +22 -0
- package/dist/deepkit/src/reflect-type.mjs +20 -0
- package/dist/deepkit/src/resolve-reflections.cjs +16 -0
- package/dist/deepkit/src/resolve-reflections.mjs +15 -0
- package/dist/deepkit/src/transformer.cjs +52 -0
- package/dist/deepkit/src/transformer.mjs +49 -0
- package/dist/deepkit/src/transpile.cjs +29 -0
- package/dist/deepkit/src/transpile.mjs +27 -0
- package/dist/deepkit/src/types.d.cts +10 -0
- package/dist/deepkit/src/types.d.mts +10 -0
- package/dist/deepkit/src/utilities.cjs +66 -0
- package/dist/deepkit/src/utilities.mjs +65 -0
- package/dist/index.cjs +14 -813
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +11 -803
- package/dist/plugin-alloy/src/core/components/output.cjs +45 -0
- package/dist/plugin-alloy/src/core/components/output.mjs +44 -0
- package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +22 -0
- package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +21 -0
- package/dist/plugin-alloy/src/core/components/source-file.cjs +64 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.cts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.mts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.mjs +62 -0
- package/dist/plugin-alloy/src/core/contexts/context.cjs +60 -0
- package/dist/plugin-alloy/src/core/contexts/context.mjs +54 -0
- package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
- package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
- package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
- package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
- package/dist/plugin-alloy/src/index.cjs +93 -0
- package/dist/plugin-alloy/src/index.mjs +91 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +7 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +9 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +5 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +7 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +17 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
- package/dist/plugin-alloy/src/types/components.d.cts +22 -0
- package/dist/plugin-alloy/src/types/components.d.mts +24 -0
- package/dist/plugin-alloy/src/types/index.d.mts +2 -0
- package/dist/plugin-alloy/src/types/plugin.d.cts +37 -0
- package/dist/plugin-alloy/src/types/plugin.d.mts +37 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +57 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +25 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.mts +26 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +56 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +126 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +442 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +27 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +28 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +433 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +194 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +14 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +15 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +191 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +68 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.cts +1 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +4 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +67 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +123 -0
- package/dist/plugin-automd/src/index.cjs +101 -0
- package/dist/plugin-automd/src/index.mjs +98 -0
- package/dist/plugin-automd/src/types/plugin.d.cts +38 -0
- package/dist/plugin-automd/src/types/plugin.d.mts +40 -0
- package/dist/plugin-automd/src/types/toc.d.cts +33 -0
- package/dist/plugin-automd/src/types/toc.d.mts +33 -0
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -0
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -0
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -0
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -0
- package/dist/plugin-babel/src/helpers/filters.cjs +23 -0
- package/dist/plugin-babel/src/helpers/filters.mjs +21 -0
- package/dist/plugin-babel/src/helpers/index.cjs +5 -0
- package/dist/plugin-babel/src/helpers/index.mjs +7 -0
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -0
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -0
- package/dist/plugin-babel/src/helpers/options.cjs +50 -0
- package/dist/plugin-babel/src/helpers/options.mjs +47 -0
- package/dist/plugin-babel/src/index.cjs +91 -0
- package/dist/plugin-babel/src/index.mjs +89 -0
- package/dist/plugin-babel/src/types/index.d.mts +1 -0
- package/dist/plugin-babel/src/types/plugin.d.cts +15 -0
- package/dist/plugin-babel/src/types/plugin.d.mts +15 -0
- package/dist/plugin-env/src/babel/index.cjs +1 -0
- package/dist/plugin-env/src/babel/index.mjs +3 -0
- package/dist/plugin-env/src/babel/plugin.cjs +121 -0
- package/dist/plugin-env/src/babel/plugin.mjs +119 -0
- package/dist/plugin-env/src/components/docs.cjs +9 -0
- package/dist/plugin-env/src/components/docs.mjs +11 -0
- package/dist/plugin-env/src/components/env.cjs +575 -0
- package/dist/plugin-env/src/components/env.d.cts +11 -0
- package/dist/plugin-env/src/components/env.d.mts +11 -0
- package/dist/plugin-env/src/components/env.mjs +572 -0
- package/dist/plugin-env/src/components/index.cjs +2 -0
- package/dist/plugin-env/src/components/index.mjs +4 -0
- package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -0
- package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -0
- package/dist/plugin-env/src/helpers/index.cjs +6 -0
- package/dist/plugin-env/src/helpers/index.mjs +8 -0
- package/dist/plugin-env/src/helpers/load.cjs +83 -0
- package/dist/plugin-env/src/helpers/load.mjs +80 -0
- package/dist/plugin-env/src/helpers/persistence.cjs +199 -0
- package/dist/plugin-env/src/helpers/persistence.mjs +188 -0
- package/dist/plugin-env/src/helpers/reflect.cjs +111 -0
- package/dist/plugin-env/src/helpers/reflect.mjs +103 -0
- package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -0
- package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -0
- package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -0
- package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -0
- package/dist/plugin-env/src/index.cjs +175 -0
- package/dist/plugin-env/src/index.mjs +173 -0
- package/dist/plugin-env/src/types/plugin.d.cts +151 -0
- package/dist/plugin-env/src/types/plugin.d.mts +153 -0
- package/dist/plugin-env/src/types/runtime.d.cts +792 -0
- package/dist/plugin-env/src/types/runtime.d.mts +792 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +102 -0
- package/dist/powerlines/src/lib/build/esbuild.mjs +100 -0
- package/dist/powerlines/src/lib/entry.cjs +12 -0
- package/dist/powerlines/src/lib/entry.mjs +14 -0
- package/dist/powerlines/src/lib/logger.cjs +41 -0
- package/dist/powerlines/src/lib/logger.mjs +39 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -0
- package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -0
- package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -0
- package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -0
- package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +3 -0
- package/dist/powerlines/src/types/babel.d.cts +22 -0
- package/dist/powerlines/src/types/babel.d.mts +22 -0
- package/dist/powerlines/src/types/build.d.cts +145 -0
- package/dist/powerlines/src/types/build.d.mts +145 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +9 -0
- package/dist/powerlines/src/types/config.d.cts +387 -0
- package/dist/powerlines/src/types/config.d.mts +388 -0
- package/dist/powerlines/src/types/context.d.cts +414 -0
- package/dist/powerlines/src/types/context.d.mts +416 -0
- package/dist/powerlines/src/types/fs.d.cts +486 -0
- package/dist/powerlines/src/types/fs.d.mts +486 -0
- package/dist/powerlines/src/types/hooks.d.mts +2 -0
- package/dist/powerlines/src/types/plugin.d.cts +231 -0
- package/dist/powerlines/src/types/plugin.d.mts +231 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +82 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -3
- package/dist/types/index.d.mts +1 -3
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +22 -2
- package/dist/types/plugin.d.mts +22 -2
- package/dist/types/plugin.mjs +0 -2
- package/package.json +6 -6
- package/dist/components-BWLXb7a2.cjs +0 -0
- package/dist/components-CXZYcH4q.d.mts +0 -1816
- package/dist/components-kh0CpIG2.mjs +0 -1
- package/dist/env-CAhIy_H3.cjs +0 -11713
- package/dist/env-CUyFiniR.d.cts +0 -107
- package/dist/env-IF4XhMjG.mjs +0 -11570
- package/dist/env-sRb-Y8mJ.d.mts +0 -89
- package/dist/index-CUbWeWHc.d.mts +0 -1
- package/dist/index-D6CnpA_r.d.cts +0 -1
- package/dist/index-DL0uimUT.d.mts +0 -1
- package/dist/index-DWPDThxu.d.cts +0 -1
- package/dist/plugin-ifZVa20V.mjs +0 -1
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/resolved-zsx09G03.d.cts +0 -1795
- package/dist/types-U3zd8PTP.mjs +0 -1
- package/dist/types-o3zWarRp.cjs +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let defu = require("defu");
|
|
3
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
4
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
5
|
+
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
6
|
+
let __stryke_fs_is_file = require("@stryke/fs/is-file");
|
|
7
|
+
let __stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
8
|
+
let __stryke_path_append = require("@stryke/path/append");
|
|
9
|
+
let __stryke_path_is_type = require("@stryke/path/is-type");
|
|
10
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
11
|
+
let automd = require("automd");
|
|
12
|
+
let c12 = require("c12");
|
|
13
|
+
let markdown_toc = require("markdown-toc");
|
|
14
|
+
markdown_toc = require_rolldown_runtime.__toESM(markdown_toc);
|
|
15
|
+
|
|
16
|
+
//#region ../plugin-automd/src/index.ts
|
|
17
|
+
/**
|
|
18
|
+
* AutoMD Plugin
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* A Powerlines plugin to use the AutoMD markdown transformer during the prepare task.
|
|
22
|
+
*
|
|
23
|
+
* @see https://automd.unjs.io/
|
|
24
|
+
*
|
|
25
|
+
* @param options - The plugin options.
|
|
26
|
+
* @returns A Powerlines plugin instance.
|
|
27
|
+
*/
|
|
28
|
+
const plugin = (options = {}) => {
|
|
29
|
+
return {
|
|
30
|
+
name: "automd",
|
|
31
|
+
async config() {
|
|
32
|
+
const config = await (0, automd.loadConfig)((0, __stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot), options);
|
|
33
|
+
if (!config.prefix || !Array.isArray(config.prefix)) config.prefix = (0, __stryke_convert_to_array.toArray)(config.prefix ?? []);
|
|
34
|
+
if (!config.prefix.includes("automd")) config.prefix.push("automd");
|
|
35
|
+
if (!config.prefix.includes("powerlines")) config.prefix.push("powerlines");
|
|
36
|
+
return { automd: (0, defu.default)(config ?? {}, {
|
|
37
|
+
configFile: options.configFile,
|
|
38
|
+
allowIssues: true,
|
|
39
|
+
dir: this.config.projectRoot,
|
|
40
|
+
watch: false,
|
|
41
|
+
input: "README.md",
|
|
42
|
+
toc: {
|
|
43
|
+
maxDepth: 6,
|
|
44
|
+
bullets: "-"
|
|
45
|
+
}
|
|
46
|
+
}) };
|
|
47
|
+
},
|
|
48
|
+
async configResolved() {
|
|
49
|
+
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);
|
|
50
|
+
if (this.config.automd.configFile) {
|
|
51
|
+
const { config } = await (0, c12.loadConfig)({
|
|
52
|
+
cwd: this.config.automd.dir,
|
|
53
|
+
configFile: this.config.automd.configFile,
|
|
54
|
+
defaults: {
|
|
55
|
+
ignore: [
|
|
56
|
+
"**/node_modules",
|
|
57
|
+
"**/dist",
|
|
58
|
+
"**/.*"
|
|
59
|
+
],
|
|
60
|
+
dir: this.config.automd.dir
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
this.config.automd = (0, automd.resolveConfig)((0, defu.default)(this.config.automd, {
|
|
64
|
+
...config,
|
|
65
|
+
prefix: (0, __stryke_convert_to_array.toArray)(config.prefix ?? [])
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
this.config.automd.input = (await Promise.all((0, __stryke_convert_to_array.toArray)(this.config.automd.input).map(async (input) => {
|
|
69
|
+
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.projectRoot), { ignore: this.config.automd.ignore });
|
|
70
|
+
return (0, __stryke_path_is_type.isAbsolutePath)(input) ? input : (0, __stryke_path_append.appendPath)(input, this.config.projectRoot);
|
|
71
|
+
}))).flat();
|
|
72
|
+
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.projectRoot);
|
|
73
|
+
this.config.automd.generators ??= {};
|
|
74
|
+
if (this.config.automd.toc !== false) this.config.automd.generators.toc ??= {
|
|
75
|
+
name: "toc",
|
|
76
|
+
generate: (ctx) => {
|
|
77
|
+
const opts = this.config.automd.toc ?? {};
|
|
78
|
+
return { contents: (0, markdown_toc.default)(ctx.block.md, {
|
|
79
|
+
...opts,
|
|
80
|
+
maxdepth: opts.maxDepth,
|
|
81
|
+
first1: opts.firstH1
|
|
82
|
+
}).content };
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
async docs() {
|
|
87
|
+
await Promise.all((0, __stryke_convert_to_array.toArray)(this.config.automd.input).map(async (input) => {
|
|
88
|
+
const contents = await this.fs.read(input);
|
|
89
|
+
if (contents) {
|
|
90
|
+
const result = await (0, automd.transform)(contents, this.config.automd);
|
|
91
|
+
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.`);
|
|
92
|
+
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.projectRoot), result.contents);
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
var src_default = plugin;
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
exports.default = src_default;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import defu from "defu";
|
|
2
|
+
import { replacePath } from "@stryke/path/replace";
|
|
3
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
4
|
+
import { isDirectory } from "@stryke/fs/is-file";
|
|
5
|
+
import { listFiles } from "@stryke/fs/list-files";
|
|
6
|
+
import { appendPath } from "@stryke/path/append";
|
|
7
|
+
import { isAbsolutePath } from "@stryke/path/is-type";
|
|
8
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
9
|
+
import { loadConfig, resolveConfig, transform } from "automd";
|
|
10
|
+
import { loadConfig as loadConfig$1 } from "c12";
|
|
11
|
+
import toc from "markdown-toc";
|
|
12
|
+
|
|
13
|
+
//#region ../plugin-automd/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.workspaceConfig.workspaceRoot, this.config.projectRoot), 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.projectRoot,
|
|
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.projectRoot), { ignore: this.config.automd.ignore });
|
|
67
|
+
return isAbsolutePath(input) ? input : appendPath(input, this.config.projectRoot);
|
|
68
|
+
}))).flat();
|
|
69
|
+
if (this.config.automd.output && !isAbsolutePath(this.config.automd.output)) this.config.automd.output = appendPath(this.config.automd.output, this.config.projectRoot);
|
|
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.md, {
|
|
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.projectRoot), result.contents);
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
var src_default = plugin;
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
export { src_default as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TOCOptions } from "./toc.cjs";
|
|
2
|
+
import { Config } from "automd";
|
|
3
|
+
|
|
4
|
+
//#region ../plugin-automd/src/types/plugin.d.ts
|
|
5
|
+
|
|
6
|
+
type AutoMDPluginOptions = Omit<Config, "dir" | "watch" | "onWatch" | "prefix"> & {
|
|
7
|
+
/**
|
|
8
|
+
* Path to the AutoMD configuration file.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* If not provided, the plugin will use the default AutoMD configuration resolution mechanism.
|
|
12
|
+
*/
|
|
13
|
+
configFile?: string;
|
|
14
|
+
/**
|
|
15
|
+
* An indicator specifying whether or not issues found by AutoMD during the prepare task are considered fatal.
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue true
|
|
18
|
+
*/
|
|
19
|
+
allowIssues?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Alternate prefix strings to use for finding generators
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* By default, AutoMD looks for generators with the "automd" prefix, so that any `<!-- automd:generator [...args] --> ... <!-- /automd -->` comments will be picked up. If you want to use different prefixes (for example, to avoid conflicts with other tools), you would provide a value like "myPrefix" and AutoMD would also look for `<!-- myPrefix:generator [...args] --> ... <!-- /myPrefix -->` comments.
|
|
25
|
+
*
|
|
26
|
+
* @defaultValue ["automd", "powerlines", "\{framework\}"]
|
|
27
|
+
*/
|
|
28
|
+
prefix?: string | string[];
|
|
29
|
+
/**
|
|
30
|
+
* Table of Contents generator options
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* If set to `false`, the built-in Table of Contents generator will be disabled.
|
|
34
|
+
*/
|
|
35
|
+
toc?: false | TOCOptions;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { AutoMDPluginOptions };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "../../../powerlines/src/types/context.mjs";
|
|
2
|
+
import "../../../powerlines/src/types/config.mjs";
|
|
3
|
+
import "../../../powerlines/src/types/resolved.mjs";
|
|
4
|
+
import { TOCOptions } from "./toc.mjs";
|
|
5
|
+
import { Config } from "automd";
|
|
6
|
+
|
|
7
|
+
//#region ../plugin-automd/src/types/plugin.d.ts
|
|
8
|
+
type AutoMDPluginOptions = Omit<Config, "dir" | "watch" | "onWatch" | "prefix"> & {
|
|
9
|
+
/**
|
|
10
|
+
* Path to the AutoMD configuration file.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* If not provided, the plugin will use the default AutoMD configuration resolution mechanism.
|
|
14
|
+
*/
|
|
15
|
+
configFile?: string;
|
|
16
|
+
/**
|
|
17
|
+
* An indicator specifying whether or not issues found by AutoMD during the prepare task are considered fatal.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue true
|
|
20
|
+
*/
|
|
21
|
+
allowIssues?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Alternate prefix strings to use for finding generators
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* By default, AutoMD looks for generators with the "automd" prefix, so that any `<!-- automd:generator [...args] --> ... <!-- /automd -->` comments will be picked up. If you want to use different prefixes (for example, to avoid conflicts with other tools), you would provide a value like "myPrefix" and AutoMD would also look for `<!-- myPrefix:generator [...args] --> ... <!-- /myPrefix -->` comments.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue ["automd", "powerlines", "\{framework\}"]
|
|
29
|
+
*/
|
|
30
|
+
prefix?: string | string[];
|
|
31
|
+
/**
|
|
32
|
+
* Table of Contents generator options
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* If set to `false`, the built-in Table of Contents generator will be disabled.
|
|
36
|
+
*/
|
|
37
|
+
toc?: false | TOCOptions;
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { AutoMDPluginOptions };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region ../plugin-automd/src/types/toc.d.ts
|
|
2
|
+
interface TOCOptions {
|
|
3
|
+
/**
|
|
4
|
+
* A slugify function to generate slugs for the headings.
|
|
5
|
+
*/
|
|
6
|
+
slugify?: (str: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* The maximum depth of headings to include in the TOC.
|
|
9
|
+
*
|
|
10
|
+
* @defaultValue 6
|
|
11
|
+
*/
|
|
12
|
+
maxDepth?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to include the first H1 heading in the TOC.
|
|
15
|
+
*/
|
|
16
|
+
firstH1?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The bullet character to use for list items in the TOC.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue "-"
|
|
21
|
+
*/
|
|
22
|
+
bullets?: string;
|
|
23
|
+
/**
|
|
24
|
+
* A prefix to add to each heading in the TOC.
|
|
25
|
+
*/
|
|
26
|
+
prefix?: string;
|
|
27
|
+
/**
|
|
28
|
+
* A filter function to determine which headings to include in the TOC.
|
|
29
|
+
*/
|
|
30
|
+
filter?: (str: string, level: number) => boolean;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TOCOptions };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region ../plugin-automd/src/types/toc.d.ts
|
|
2
|
+
interface TOCOptions {
|
|
3
|
+
/**
|
|
4
|
+
* A slugify function to generate slugs for the headings.
|
|
5
|
+
*/
|
|
6
|
+
slugify?: (str: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* The maximum depth of headings to include in the TOC.
|
|
9
|
+
*
|
|
10
|
+
* @defaultValue 6
|
|
11
|
+
*/
|
|
12
|
+
maxDepth?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to include the first H1 heading in the TOC.
|
|
15
|
+
*/
|
|
16
|
+
firstH1?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The bullet character to use for list items in the TOC.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue "-"
|
|
21
|
+
*/
|
|
22
|
+
bullets?: string;
|
|
23
|
+
/**
|
|
24
|
+
* A prefix to add to each heading in the TOC.
|
|
25
|
+
*/
|
|
26
|
+
prefix?: string;
|
|
27
|
+
/**
|
|
28
|
+
* A filter function to determine which headings to include in the TOC.
|
|
29
|
+
*/
|
|
30
|
+
filter?: (str: string, level: number) => boolean;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TOCOptions };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __babel_generator = require("@babel/generator");
|
|
3
|
+
__babel_generator = require_rolldown_runtime.__toESM(__babel_generator);
|
|
4
|
+
require("@babel/parser");
|
|
5
|
+
|
|
6
|
+
//#region ../plugin-babel/src/helpers/ast-utils.ts
|
|
7
|
+
let generate = __babel_generator.default;
|
|
8
|
+
if ("default" in generate) generate = generate.default;
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_logger = require('../../../powerlines/src/lib/logger.cjs');
|
|
3
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
4
|
+
let chalk = require("chalk");
|
|
5
|
+
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
6
|
+
let __babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
|
|
7
|
+
|
|
8
|
+
//#region ../plugin-babel/src/helpers/create-plugin.ts
|
|
9
|
+
/**
|
|
10
|
+
* Create a Babel plugin using the provided builder function.
|
|
11
|
+
*
|
|
12
|
+
* @param name - The name of the plugin.
|
|
13
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
14
|
+
* @returns A Babel plugin declaration.
|
|
15
|
+
*/
|
|
16
|
+
function createBabelPlugin(name, builder) {
|
|
17
|
+
const plugin = (context) => {
|
|
18
|
+
return (0, __babel_helper_plugin_utils.declare)((api, options, dirname) => {
|
|
19
|
+
api.cache.using(() => context.meta.checksum);
|
|
20
|
+
api.assertVersion("^7.0.0-0");
|
|
21
|
+
const log = require_logger.extendLog(context.log, name);
|
|
22
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
23
|
+
const result = builder({
|
|
24
|
+
log,
|
|
25
|
+
name,
|
|
26
|
+
api,
|
|
27
|
+
options,
|
|
28
|
+
context,
|
|
29
|
+
dirname
|
|
30
|
+
});
|
|
31
|
+
result.name = name;
|
|
32
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Completed initialization of the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
33
|
+
return result;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
plugin.$$name = name;
|
|
37
|
+
return plugin;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.createBabelPlugin = createBabelPlugin;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { extendLog } from "../../../powerlines/src/lib/logger.mjs";
|
|
2
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { declare } from "@babel/helper-plugin-utils";
|
|
5
|
+
|
|
6
|
+
//#region ../plugin-babel/src/helpers/create-plugin.ts
|
|
7
|
+
/**
|
|
8
|
+
* Create a Babel plugin using the provided builder function.
|
|
9
|
+
*
|
|
10
|
+
* @param name - The name of the plugin.
|
|
11
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
12
|
+
* @returns A Babel plugin declaration.
|
|
13
|
+
*/
|
|
14
|
+
function createBabelPlugin(name, builder) {
|
|
15
|
+
const plugin = (context) => {
|
|
16
|
+
return declare((api, options, dirname) => {
|
|
17
|
+
api.cache.using(() => context.meta.checksum);
|
|
18
|
+
api.assertVersion("^7.0.0-0");
|
|
19
|
+
const log = extendLog(context.log, name);
|
|
20
|
+
log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
21
|
+
const result = builder({
|
|
22
|
+
log,
|
|
23
|
+
name,
|
|
24
|
+
api,
|
|
25
|
+
options,
|
|
26
|
+
context,
|
|
27
|
+
dirname
|
|
28
|
+
});
|
|
29
|
+
result.name = name;
|
|
30
|
+
log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
31
|
+
return result;
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
plugin.$$name = name;
|
|
35
|
+
return plugin;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { createBabelPlugin };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
3
|
+
require("@stryke/type-checks/is-object");
|
|
4
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
5
|
+
|
|
6
|
+
//#region ../plugin-babel/src/helpers/filters.ts
|
|
7
|
+
function getPluginName(plugin) {
|
|
8
|
+
return (0, __stryke_type_checks_is_set_string.isSetString)(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
12
|
+
*
|
|
13
|
+
* @param plugins - The list of existing Babel plugins.
|
|
14
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
15
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
function isDuplicatePlugin(plugins, plugin) {
|
|
18
|
+
return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.getPluginName = getPluginName;
|
|
23
|
+
exports.isDuplicatePlugin = isDuplicatePlugin;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
2
|
+
import "@stryke/type-checks/is-object";
|
|
3
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-babel/src/helpers/filters.ts
|
|
6
|
+
function getPluginName(plugin) {
|
|
7
|
+
return isSetString(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
11
|
+
*
|
|
12
|
+
* @param plugins - The list of existing Babel plugins.
|
|
13
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
14
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
15
|
+
*/
|
|
16
|
+
function isDuplicatePlugin(plugins, plugin) {
|
|
17
|
+
return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getPluginName, isDuplicatePlugin };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getPluginName, isDuplicatePlugin } from "./filters.mjs";
|
|
2
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./options.mjs";
|
|
3
|
+
import "./ast-utils.mjs";
|
|
4
|
+
import { createBabelPlugin } from "./create-plugin.mjs";
|
|
5
|
+
import { addImport, addImportsToProgram } from "./module-helpers.mjs";
|
|
6
|
+
|
|
7
|
+
export { };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
require('./ast-utils.cjs');
|
|
3
|
+
let __babel_types = require("@babel/types");
|
|
4
|
+
__babel_types = require_rolldown_runtime.__toESM(__babel_types);
|
|
5
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
6
|
+
|
|
7
|
+
//#region ../plugin-babel/src/helpers/module-helpers.ts
|
|
8
|
+
/**
|
|
9
|
+
* Adds an import to the program if it doesn't already exist.
|
|
10
|
+
*
|
|
11
|
+
* @param path - The current NodePath in the AST.
|
|
12
|
+
* @param specifier - The import specifier.
|
|
13
|
+
*/
|
|
14
|
+
function addImport(path, specifier) {
|
|
15
|
+
addImportsToProgram(path.scope.getProgramParent().path, specifier);
|
|
16
|
+
}
|
|
17
|
+
function isNonNamespacedImport(importDeclPath) {
|
|
18
|
+
return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
|
19
|
+
}
|
|
20
|
+
function getExistingImports(program) {
|
|
21
|
+
const existingImports = /* @__PURE__ */ new Map();
|
|
22
|
+
program.traverse({ ImportDeclaration(path) {
|
|
23
|
+
if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
|
|
24
|
+
} });
|
|
25
|
+
return existingImports;
|
|
26
|
+
}
|
|
27
|
+
function addImportsToProgram(path, specifier) {
|
|
28
|
+
/**
|
|
29
|
+
* If an existing import of this module exists (ie \`import \{ ... \} from
|
|
30
|
+
* '<moduleName>'\`), inject new imported specifiers into the list of
|
|
31
|
+
* destructured variables.
|
|
32
|
+
*/
|
|
33
|
+
if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", __babel_types.importDeclaration([__babel_types.importSpecifier(__babel_types.identifier(specifier.name || specifier.imported), __babel_types.identifier(specifier.imported))], __babel_types.stringLiteral(specifier.module)));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.addImport = addImport;
|
|
38
|
+
exports.addImportsToProgram = addImportsToProgram;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "./ast-utils.mjs";
|
|
2
|
+
import * as t from "@babel/types";
|
|
3
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-babel/src/helpers/module-helpers.ts
|
|
6
|
+
/**
|
|
7
|
+
* Adds an import to the program if it doesn't already exist.
|
|
8
|
+
*
|
|
9
|
+
* @param path - The current NodePath in the AST.
|
|
10
|
+
* @param specifier - The import specifier.
|
|
11
|
+
*/
|
|
12
|
+
function addImport(path, specifier) {
|
|
13
|
+
addImportsToProgram(path.scope.getProgramParent().path, specifier);
|
|
14
|
+
}
|
|
15
|
+
function isNonNamespacedImport(importDeclPath) {
|
|
16
|
+
return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
|
17
|
+
}
|
|
18
|
+
function getExistingImports(program) {
|
|
19
|
+
const existingImports = /* @__PURE__ */ new Map();
|
|
20
|
+
program.traverse({ ImportDeclaration(path) {
|
|
21
|
+
if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
|
|
22
|
+
} });
|
|
23
|
+
return existingImports;
|
|
24
|
+
}
|
|
25
|
+
function addImportsToProgram(path, specifier) {
|
|
26
|
+
/**
|
|
27
|
+
* If an existing import of this module exists (ie \`import \{ ... \} from
|
|
28
|
+
* '<moduleName>'\`), inject new imported specifiers into the list of
|
|
29
|
+
* destructured variables.
|
|
30
|
+
*/
|
|
31
|
+
if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(t.identifier(specifier.name || specifier.imported), t.identifier(specifier.imported))], t.stringLiteral(specifier.module)));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { addImport, addImportsToProgram };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_filters = require('./filters.cjs');
|
|
3
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
4
|
+
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
5
|
+
let chalk = require("chalk");
|
|
6
|
+
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
7
|
+
|
|
8
|
+
//#region ../plugin-babel/src/helpers/options.ts
|
|
9
|
+
function resolvePluginFunction(context, plugin) {
|
|
10
|
+
try {
|
|
11
|
+
return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? (0, __stryke_type_checks_is_function.isFunction)(plugin[0]) ? plugin[0](context) : plugin[0] : (0, __stryke_type_checks_is_function.isFunction)(plugin) ? plugin(context) : plugin;
|
|
12
|
+
} catch {
|
|
13
|
+
return plugin[0];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
18
|
+
*
|
|
19
|
+
* @param context - The context for the transformation.
|
|
20
|
+
* @param code - The code to be transformed.
|
|
21
|
+
* @param id - The ID of the source file.
|
|
22
|
+
* @param plugin - The Babel plugin to resolve.
|
|
23
|
+
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
24
|
+
*/
|
|
25
|
+
function resolveBabelPlugin(context, code, id, plugin) {
|
|
26
|
+
if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
|
|
27
|
+
if (plugin.length > 2 && plugin[2] && (0, __stryke_type_checks_is_function.isFunction)(plugin[2]) && !plugin[2](code, id)) {
|
|
28
|
+
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping filtered Babel plugin ${chalk.default.bold.cyanBright(require_filters.getPluginName(plugin) || "unnamed")} for ${id}`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
return plugin.length > 2 ? [
|
|
32
|
+
resolvePluginFunction(context, plugin),
|
|
33
|
+
plugin[1],
|
|
34
|
+
plugin[2]
|
|
35
|
+
] : [
|
|
36
|
+
resolvePluginFunction(context, plugin),
|
|
37
|
+
plugin[1],
|
|
38
|
+
null
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
return [
|
|
42
|
+
resolvePluginFunction(context, plugin),
|
|
43
|
+
{},
|
|
44
|
+
null
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.resolveBabelPlugin = resolveBabelPlugin;
|
|
50
|
+
exports.resolvePluginFunction = resolvePluginFunction;
|