@powerlines/plugin-webpack 0.5.130 → 0.5.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/helpers/index.cjs +3 -2
  2. package/dist/helpers/index.d.cts +3 -1
  3. package/dist/helpers/index.d.mts +3 -1
  4. package/dist/helpers/index.mjs +2 -1
  5. package/dist/helpers/unplugin.cjs +2 -11
  6. package/dist/helpers/unplugin.d.cts +2 -6
  7. package/dist/helpers/unplugin.d.mts +2 -6
  8. package/dist/helpers/unplugin.mjs +1 -9
  9. package/dist/helpers-B15z10jN.mjs +1 -0
  10. package/dist/helpers-LF26RHol.cjs +0 -0
  11. package/dist/index-9iG2qHLe.d.mts +1 -0
  12. package/dist/index-D4ELpJXS.d.cts +1 -0
  13. package/dist/index-D6CnpA_r.d.cts +1 -0
  14. package/dist/index-DL0uimUT.d.mts +1 -0
  15. package/dist/index.cjs +50 -8
  16. package/dist/index.d.cts +4 -3
  17. package/dist/index.d.mts +5 -5
  18. package/dist/index.mjs +46 -3
  19. package/dist/plugin-C5bG6Zu0.d.mts +1772 -0
  20. package/dist/plugin-Cl1J-dKa.d.cts +1769 -0
  21. package/dist/plugin-ifZVa20V.mjs +1 -0
  22. package/dist/plugin-pBKbb5K9.cjs +0 -0
  23. package/dist/types/index.cjs +2 -0
  24. package/dist/types/index.d.cts +2 -1
  25. package/dist/types/index.d.mts +2 -1
  26. package/dist/types/index.mjs +3 -0
  27. package/dist/types/plugin.cjs +1 -0
  28. package/dist/types/plugin.d.cts +1 -12
  29. package/dist/types/plugin.d.mts +1 -12
  30. package/dist/types/plugin.mjs +2 -0
  31. package/dist/types-U3zd8PTP.mjs +1 -0
  32. package/dist/types-o3zWarRp.cjs +0 -0
  33. package/dist/unplugin-Bo9KoKSB.d.cts +7 -0
  34. package/dist/unplugin-Ct4wZxE5.d.mts +7 -0
  35. package/dist/unplugin-GJmHohOE.mjs +4617 -0
  36. package/dist/unplugin-bKYETUU8.cjs +4661 -0
  37. package/package.json +5 -5
  38. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  39. package/dist/powerlines/schemas/fs.cjs +0 -226
  40. package/dist/powerlines/schemas/fs.mjs +0 -224
  41. package/dist/powerlines/src/api.cjs +0 -580
  42. package/dist/powerlines/src/api.mjs +0 -578
  43. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
  44. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
  45. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
  46. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
  47. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
  48. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
  49. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -63
  50. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -61
  51. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
  52. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
  53. package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
  54. package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
  55. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
  56. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
  57. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  58. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  59. package/dist/powerlines/src/lib/build/webpack.cjs +0 -47
  60. package/dist/powerlines/src/lib/build/webpack.mjs +0 -45
  61. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  62. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  63. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  64. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  65. package/dist/powerlines/src/lib/contexts/context.cjs +0 -931
  66. package/dist/powerlines/src/lib/contexts/context.mjs +0 -929
  67. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -160
  68. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -159
  69. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
  70. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
  71. package/dist/powerlines/src/lib/entry.cjs +0 -69
  72. package/dist/powerlines/src/lib/entry.mjs +0 -67
  73. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  74. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  75. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  76. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  77. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  78. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  79. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  80. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  81. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
  82. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
  83. package/dist/powerlines/src/lib/logger.cjs +0 -58
  84. package/dist/powerlines/src/lib/logger.mjs +0 -55
  85. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
  86. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
  87. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  88. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  89. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  90. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  91. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -17
  92. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -16
  93. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
  94. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
  95. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
  96. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
  97. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  98. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  99. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
  100. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
  101. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  102. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  103. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -148
  104. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -138
  105. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  106. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  107. package/dist/powerlines/src/types/babel.d.mts +0 -4
  108. package/dist/powerlines/src/types/build.cjs +0 -15
  109. package/dist/powerlines/src/types/build.d.cts +0 -149
  110. package/dist/powerlines/src/types/build.d.mts +0 -149
  111. package/dist/powerlines/src/types/build.mjs +0 -14
  112. package/dist/powerlines/src/types/commands.cjs +0 -16
  113. package/dist/powerlines/src/types/commands.d.cts +0 -8
  114. package/dist/powerlines/src/types/commands.d.mts +0 -9
  115. package/dist/powerlines/src/types/commands.mjs +0 -15
  116. package/dist/powerlines/src/types/config.d.cts +0 -370
  117. package/dist/powerlines/src/types/config.d.mts +0 -372
  118. package/dist/powerlines/src/types/context.d.cts +0 -403
  119. package/dist/powerlines/src/types/context.d.mts +0 -405
  120. package/dist/powerlines/src/types/fs.d.cts +0 -486
  121. package/dist/powerlines/src/types/fs.d.mts +0 -486
  122. package/dist/powerlines/src/types/hooks.d.mts +0 -2
  123. package/dist/powerlines/src/types/plugin.cjs +0 -32
  124. package/dist/powerlines/src/types/plugin.d.cts +0 -231
  125. package/dist/powerlines/src/types/plugin.d.mts +0 -231
  126. package/dist/powerlines/src/types/plugin.mjs +0 -31
  127. package/dist/powerlines/src/types/resolved.d.cts +0 -82
  128. package/dist/powerlines/src/types/resolved.d.mts +0 -83
  129. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  130. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
@@ -1,160 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- const require_plugin = require('../../types/plugin.cjs');
3
- const require_helpers = require('../../plugin-utils/helpers.cjs');
4
- const require_context = require('./context.cjs');
5
- const require_plugin_context = require('./plugin-context.cjs');
6
- let __stryke_fs_resolve = require("@stryke/fs/resolve");
7
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
8
- let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
9
-
10
- //#region ../powerlines/src/lib/contexts/environment-context.ts
11
- var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends require_context.PowerlinesContext {
12
- /**
13
- * The hooks registered by plugins in this environment
14
- */
15
- #hooks = {};
16
- /**
17
- * Create a new Storm context from the workspace root and user config.
18
- *
19
- * @param workspaceConfig - The root directory of the workspace.
20
- * @param config - The user configuration options.
21
- * @returns A promise that resolves to the new context.
22
- */
23
- static async fromConfig(workspaceConfig, config) {
24
- const context = new PowerlinesEnvironmentContext(config, workspaceConfig);
25
- await context.init();
26
- const powerlinesPath = await (0, __stryke_fs_resolve.resolvePackage)("powerlines");
27
- if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
28
- context.powerlinesPath = powerlinesPath;
29
- return context;
30
- }
31
- /**
32
- * The resolved environment configuration
33
- */
34
- environment;
35
- /**
36
- * The list of plugins applied to this environment
37
- */
38
- plugins = [];
39
- /**
40
- * The resolved configuration options
41
- */
42
- get config() {
43
- return super.config;
44
- }
45
- get hooks() {
46
- return this.#hooks;
47
- }
48
- async addPlugin(plugin) {
49
- let resolvedPlugin = plugin;
50
- if ((0, __stryke_type_checks_is_function.isFunction)(plugin.applyToEnvironment)) {
51
- const result = await Promise.resolve(plugin.applyToEnvironment(this.environment));
52
- if (!result || (0, __stryke_type_checks_is_object.isObject)(result) && Object.keys(result).length === 0) return;
53
- if (require_helpers.isPluginConfig(result)) return this.$$internal.addPlugin(result);
54
- resolvedPlugin = require_helpers.isPlugin(result) ? result : plugin;
55
- }
56
- const context = require_plugin_context.createPluginContext(resolvedPlugin, this);
57
- this.plugins.push({
58
- plugin: resolvedPlugin,
59
- context
60
- });
61
- this.#hooks = Object.keys(resolvedPlugin).filter((key) => !require_plugin.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => {
62
- const hook = key;
63
- const pluginHook = resolvedPlugin[hook];
64
- if (!require_helpers.isPluginHook(pluginHook)) return ret;
65
- if (!require_helpers.isHookExternal(hook)) {
66
- ret[hook] ??= {};
67
- if (resolvedPlugin.enforce) {
68
- ret[hook][`${resolvedPlugin.enforce}Enforced`] ??= [];
69
- require_helpers.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${resolvedPlugin.enforce}Enforced`]);
70
- return ret;
71
- }
72
- if ((0, __stryke_type_checks_is_function.isFunction)(pluginHook) || !pluginHook.order) {
73
- ret[hook].normal ??= [];
74
- require_helpers.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook].normal);
75
- return ret;
76
- }
77
- ret[hook][`${pluginHook.order}Ordered`] ??= [];
78
- require_helpers.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${pluginHook.order}Ordered`]);
79
- } else {
80
- ret[hook] ??= [];
81
- ret[hook].push({
82
- plugin: resolvedPlugin,
83
- hook: require_helpers.getHookHandler(pluginHook).bind(context)
84
- });
85
- }
86
- return ret;
87
- }, this.hooks);
88
- }
89
- /**
90
- * Retrieves the hook handlers for a specific hook name
91
- */
92
- selectHooks(hook, options) {
93
- const result = [];
94
- if (this.hooks[hook]) if (!require_helpers.isHookExternal(hook)) {
95
- const hooks = this.hooks[hook];
96
- if (options?.order) if (options?.order === "pre") {
97
- result.push(...(hooks.preOrdered ?? []).map((h) => {
98
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
99
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
100
- return {
101
- handle: h.handler,
102
- context: plugin.context
103
- };
104
- }));
105
- result.push(...(hooks.preEnforced ?? []).map((h) => {
106
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
107
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
108
- return {
109
- handle: h.handler,
110
- context: plugin.context
111
- };
112
- }));
113
- } else if (options?.order === "post") {
114
- result.push(...(hooks.postOrdered ?? []).map((h) => {
115
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
116
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
117
- return {
118
- handle: h.handler,
119
- context: plugin.context
120
- };
121
- }));
122
- result.push(...(hooks.postEnforced ?? []).map((h) => {
123
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
124
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
125
- return {
126
- handle: h.handler,
127
- context: plugin.context
128
- };
129
- }));
130
- } else result.push(...(hooks.normal ?? []).map((h) => {
131
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
132
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
133
- return {
134
- handle: h.handler,
135
- context: plugin.context
136
- };
137
- }));
138
- else {
139
- result.push(...this.selectHooks(hook, { order: "pre" }));
140
- result.push(...this.selectHooks(hook, { order: "normal" }));
141
- result.push(...this.selectHooks(hook, { order: "post" }));
142
- }
143
- } else result.push(...this.hooks[hook].map((h) => {
144
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
145
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
146
- return {
147
- handle: h.handler,
148
- context: plugin.context
149
- };
150
- }));
151
- return result;
152
- }
153
- constructor(config, workspaceConfig) {
154
- super(workspaceConfig);
155
- this.resolvedConfig = config;
156
- }
157
- };
158
-
159
- //#endregion
160
- exports.PowerlinesEnvironmentContext = PowerlinesEnvironmentContext;
@@ -1,159 +0,0 @@
1
- import { PLUGIN_NON_HOOK_FIELDS } from "../../types/plugin.mjs";
2
- import { addPluginHook, getHookHandler, isHookExternal, isPlugin, isPluginConfig, isPluginHook } from "../../plugin-utils/helpers.mjs";
3
- import { PowerlinesContext } from "./context.mjs";
4
- import { createPluginContext } from "./plugin-context.mjs";
5
- import { resolvePackage } from "@stryke/fs/resolve";
6
- import { isFunction } from "@stryke/type-checks/is-function";
7
- import { isObject } from "@stryke/type-checks/is-object";
8
-
9
- //#region ../powerlines/src/lib/contexts/environment-context.ts
10
- var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends PowerlinesContext {
11
- /**
12
- * The hooks registered by plugins in this environment
13
- */
14
- #hooks = {};
15
- /**
16
- * Create a new Storm context from the workspace root and user config.
17
- *
18
- * @param workspaceConfig - The root directory of the workspace.
19
- * @param config - The user configuration options.
20
- * @returns A promise that resolves to the new context.
21
- */
22
- static async fromConfig(workspaceConfig, config) {
23
- const context = new PowerlinesEnvironmentContext(config, workspaceConfig);
24
- await context.init();
25
- const powerlinesPath = await resolvePackage("powerlines");
26
- if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
27
- context.powerlinesPath = powerlinesPath;
28
- return context;
29
- }
30
- /**
31
- * The resolved environment configuration
32
- */
33
- environment;
34
- /**
35
- * The list of plugins applied to this environment
36
- */
37
- plugins = [];
38
- /**
39
- * The resolved configuration options
40
- */
41
- get config() {
42
- return super.config;
43
- }
44
- get hooks() {
45
- return this.#hooks;
46
- }
47
- async addPlugin(plugin) {
48
- let resolvedPlugin = plugin;
49
- if (isFunction(plugin.applyToEnvironment)) {
50
- const result = await Promise.resolve(plugin.applyToEnvironment(this.environment));
51
- if (!result || isObject(result) && Object.keys(result).length === 0) return;
52
- if (isPluginConfig(result)) return this.$$internal.addPlugin(result);
53
- resolvedPlugin = isPlugin(result) ? result : plugin;
54
- }
55
- const context = createPluginContext(resolvedPlugin, this);
56
- this.plugins.push({
57
- plugin: resolvedPlugin,
58
- context
59
- });
60
- this.#hooks = Object.keys(resolvedPlugin).filter((key) => !PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => {
61
- const hook = key;
62
- const pluginHook = resolvedPlugin[hook];
63
- if (!isPluginHook(pluginHook)) return ret;
64
- if (!isHookExternal(hook)) {
65
- ret[hook] ??= {};
66
- if (resolvedPlugin.enforce) {
67
- ret[hook][`${resolvedPlugin.enforce}Enforced`] ??= [];
68
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${resolvedPlugin.enforce}Enforced`]);
69
- return ret;
70
- }
71
- if (isFunction(pluginHook) || !pluginHook.order) {
72
- ret[hook].normal ??= [];
73
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook].normal);
74
- return ret;
75
- }
76
- ret[hook][`${pluginHook.order}Ordered`] ??= [];
77
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${pluginHook.order}Ordered`]);
78
- } else {
79
- ret[hook] ??= [];
80
- ret[hook].push({
81
- plugin: resolvedPlugin,
82
- hook: getHookHandler(pluginHook).bind(context)
83
- });
84
- }
85
- return ret;
86
- }, this.hooks);
87
- }
88
- /**
89
- * Retrieves the hook handlers for a specific hook name
90
- */
91
- selectHooks(hook, options) {
92
- const result = [];
93
- if (this.hooks[hook]) if (!isHookExternal(hook)) {
94
- const hooks = this.hooks[hook];
95
- if (options?.order) if (options?.order === "pre") {
96
- result.push(...(hooks.preOrdered ?? []).map((h) => {
97
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
98
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
99
- return {
100
- handle: h.handler,
101
- context: plugin.context
102
- };
103
- }));
104
- result.push(...(hooks.preEnforced ?? []).map((h) => {
105
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
106
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
107
- return {
108
- handle: h.handler,
109
- context: plugin.context
110
- };
111
- }));
112
- } else if (options?.order === "post") {
113
- result.push(...(hooks.postOrdered ?? []).map((h) => {
114
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
115
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
116
- return {
117
- handle: h.handler,
118
- context: plugin.context
119
- };
120
- }));
121
- result.push(...(hooks.postEnforced ?? []).map((h) => {
122
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
123
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
124
- return {
125
- handle: h.handler,
126
- context: plugin.context
127
- };
128
- }));
129
- } else result.push(...(hooks.normal ?? []).map((h) => {
130
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
131
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
132
- return {
133
- handle: h.handler,
134
- context: plugin.context
135
- };
136
- }));
137
- else {
138
- result.push(...this.selectHooks(hook, { order: "pre" }));
139
- result.push(...this.selectHooks(hook, { order: "normal" }));
140
- result.push(...this.selectHooks(hook, { order: "post" }));
141
- }
142
- } else result.push(...this.hooks[hook].map((h) => {
143
- const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
144
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
145
- return {
146
- handle: h.handler,
147
- context: plugin.context
148
- };
149
- }));
150
- return result;
151
- }
152
- constructor(config, workspaceConfig) {
153
- super(workspaceConfig);
154
- this.resolvedConfig = config;
155
- }
156
- };
157
-
158
- //#endregion
159
- export { PowerlinesEnvironmentContext };
@@ -1,75 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
3
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
4
-
5
- //#region ../powerlines/src/lib/contexts/plugin-context.ts
6
- /**
7
- * Create a Proxy-based PluginContext
8
- *
9
- * @param plugin - The plugin instance
10
- * @param environment - The environment context
11
- * @returns The proxied plugin context
12
- */
13
- function createPluginContext(plugin, environment) {
14
- const normalizeMessage = (message) => {
15
- return (0, __stryke_type_checks_is_string.isString)(message) ? message : message.message;
16
- };
17
- const log = environment.extendLog(plugin.name.replaceAll(":", " - "));
18
- const callHookFn = async (hook, options, ...args) => {
19
- return environment.$$internal.api.callHook(hook, {
20
- sequential: true,
21
- result: "merge",
22
- ...options,
23
- environment
24
- }, ...args);
25
- };
26
- return new Proxy({}, {
27
- get(_, prop) {
28
- if (prop === "$$internal") return {
29
- ...environment.$$internal,
30
- environment,
31
- callHook: callHookFn
32
- };
33
- if (prop === "log" || prop === "logger") return log;
34
- if (prop === "error") return (message) => {
35
- log(__storm_software_config_tools_types.LogLevelLabel.ERROR, normalizeMessage(message));
36
- };
37
- if (prop === "warn") return (message) => {
38
- log(__storm_software_config_tools_types.LogLevelLabel.WARN, normalizeMessage(message));
39
- };
40
- if (prop === "info") return (message) => {
41
- log(__storm_software_config_tools_types.LogLevelLabel.INFO, normalizeMessage(message));
42
- };
43
- if (prop === "debug") return (message) => {
44
- log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, normalizeMessage(message));
45
- };
46
- if (prop === "trace") return (message) => {
47
- log(__storm_software_config_tools_types.LogLevelLabel.TRACE, normalizeMessage(message));
48
- };
49
- return environment[prop];
50
- },
51
- set(_, prop, value) {
52
- if ([
53
- "$$internal",
54
- "environment",
55
- "config",
56
- "log",
57
- "logger",
58
- "error",
59
- "warn",
60
- "plugins",
61
- "hooks",
62
- "addPlugin",
63
- "selectHooks"
64
- ].includes(prop)) {
65
- log(__storm_software_config_tools_types.LogLevelLabel.WARN, `Cannot set read-only property "${String(prop)}"`);
66
- return false;
67
- }
68
- environment[prop] = value;
69
- return true;
70
- }
71
- });
72
- }
73
-
74
- //#endregion
75
- exports.createPluginContext = createPluginContext;
@@ -1,74 +0,0 @@
1
- import { LogLevelLabel } from "@storm-software/config-tools/types";
2
- import { isString } from "@stryke/type-checks/is-string";
3
-
4
- //#region ../powerlines/src/lib/contexts/plugin-context.ts
5
- /**
6
- * Create a Proxy-based PluginContext
7
- *
8
- * @param plugin - The plugin instance
9
- * @param environment - The environment context
10
- * @returns The proxied plugin context
11
- */
12
- function createPluginContext(plugin, environment) {
13
- const normalizeMessage = (message) => {
14
- return isString(message) ? message : message.message;
15
- };
16
- const log = environment.extendLog(plugin.name.replaceAll(":", " - "));
17
- const callHookFn = async (hook, options, ...args) => {
18
- return environment.$$internal.api.callHook(hook, {
19
- sequential: true,
20
- result: "merge",
21
- ...options,
22
- environment
23
- }, ...args);
24
- };
25
- return new Proxy({}, {
26
- get(_, prop) {
27
- if (prop === "$$internal") return {
28
- ...environment.$$internal,
29
- environment,
30
- callHook: callHookFn
31
- };
32
- if (prop === "log" || prop === "logger") return log;
33
- if (prop === "error") return (message) => {
34
- log(LogLevelLabel.ERROR, normalizeMessage(message));
35
- };
36
- if (prop === "warn") return (message) => {
37
- log(LogLevelLabel.WARN, normalizeMessage(message));
38
- };
39
- if (prop === "info") return (message) => {
40
- log(LogLevelLabel.INFO, normalizeMessage(message));
41
- };
42
- if (prop === "debug") return (message) => {
43
- log(LogLevelLabel.DEBUG, normalizeMessage(message));
44
- };
45
- if (prop === "trace") return (message) => {
46
- log(LogLevelLabel.TRACE, normalizeMessage(message));
47
- };
48
- return environment[prop];
49
- },
50
- set(_, prop, value) {
51
- if ([
52
- "$$internal",
53
- "environment",
54
- "config",
55
- "log",
56
- "logger",
57
- "error",
58
- "warn",
59
- "plugins",
60
- "hooks",
61
- "addPlugin",
62
- "selectHooks"
63
- ].includes(prop)) {
64
- log(LogLevelLabel.WARN, `Cannot set read-only property "${String(prop)}"`);
65
- return false;
66
- }
67
- environment[prop] = value;
68
- return true;
69
- }
70
- });
71
- }
72
-
73
- //#endregion
74
- export { createPluginContext };
@@ -1,69 +0,0 @@
1
- const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
- const require_paths = require('../plugin-utils/paths.cjs');
3
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
4
- let __stryke_convert_to_array = require("@stryke/convert/to-array");
5
- let __stryke_fs_list_files = require("@stryke/fs/list-files");
6
- let __stryke_path_append = require("@stryke/path/append");
7
- let __stryke_path_replace = require("@stryke/path/replace");
8
- let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
9
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
10
- let __stryke_hash_murmurhash = require("@stryke/hash/murmurhash");
11
- let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
12
- let __stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
13
- let __stryke_fs_is_file = require("@stryke/fs/is-file");
14
-
15
- //#region ../powerlines/src/lib/entry.ts
16
- function resolveEntryInputFile(context, typeDefinition) {
17
- return (0, __stryke_path_replace.replacePath)(typeDefinition.file, (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot));
18
- }
19
- function resolveEntryInput(context, typeDefinition) {
20
- return {
21
- file: resolveEntryInputFile(context, typeDefinition),
22
- name: typeDefinition.name
23
- };
24
- }
25
- function resolveEntryOutput(context, typeDefinition) {
26
- return (0, __stryke_path_replace.replaceExtension)((0, __stryke_path_replace.replacePath)((0, __stryke_path_replace.replacePath)((0, __stryke_path_replace.replacePath)((0, __stryke_path_replace.replacePath)((0, __stryke_path_replace.replacePath)(typeDefinition.file, (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.sourceRoot)), (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot)), context.config.sourceRoot), context.config.projectRoot), (0, __stryke_path_replace.replacePath)(context.config.sourceRoot, context.config.projectRoot)));
27
- }
28
- function resolveEntry(context, typeDefinition) {
29
- const input = resolveEntryInput(context, typeDefinition);
30
- return {
31
- ...input,
32
- input,
33
- output: resolveEntryOutput(context, typeDefinition)
34
- };
35
- }
36
- /**
37
- * Resolves multiple type definitions into their corresponding resolved entry type definitions.
38
- *
39
- * @param context - The current context
40
- * @param typeDefinitions - The type definitions to resolve.
41
- * @returns A promise that resolves to an array of resolved entry type definitions.
42
- */
43
- function resolveEntriesSync(context, typeDefinitions) {
44
- return typeDefinitions.map((entry) => (0, __stryke_type_checks_is_string.isString)(entry) ? require_paths.replacePathTokens(context, entry) : require_paths.replacePathTokens(context, entry.file)).map((typeDefinition) => {
45
- const parsed = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(typeDefinition);
46
- const filePath = (0, __stryke_path_append.appendPath)(parsed.file, context.config.projectRoot);
47
- if ((0, __stryke_fs_is_file.isFile)(filePath)) return resolveEntry(context, {
48
- file: (0, __stryke_path_replace.replacePath)(filePath, context.config.projectRoot),
49
- name: parsed.name
50
- });
51
- return (0, __stryke_fs_list_files.listFilesSync)(filePath).map((file) => resolveEntry(context, {
52
- file,
53
- name: parsed.name
54
- }));
55
- }).flat().filter(Boolean);
56
- }
57
- /**
58
- * Get unique entries from the provided list.
59
- *
60
- * @param entries - The entries to process.
61
- * @returns An array of unique entries (by file path or content hash).
62
- */
63
- function getUniqueEntries(entries = []) {
64
- return (0, __stryke_helpers_get_unique.getUniqueBy)((0, __stryke_convert_to_array.toArray)(entries), (item) => (0, __stryke_type_checks_is_set_string.isSetString)(item) ? item : (0, __stryke_hash_murmurhash.murmurhash)(item ?? {}, { maxLength: 24 }));
65
- }
66
-
67
- //#endregion
68
- exports.getUniqueEntries = getUniqueEntries;
69
- exports.resolveEntriesSync = resolveEntriesSync;
@@ -1,67 +0,0 @@
1
- import { replacePathTokens } from "../plugin-utils/paths.mjs";
2
- import { joinPaths } from "@stryke/path/join-paths";
3
- import { toArray } from "@stryke/convert/to-array";
4
- import { listFiles, listFilesSync } from "@stryke/fs/list-files";
5
- import { appendPath } from "@stryke/path/append";
6
- import { replaceExtension, replacePath } from "@stryke/path/replace";
7
- import { isSetString } from "@stryke/type-checks/is-set-string";
8
- import { isString } from "@stryke/type-checks/is-string";
9
- import { murmurhash } from "@stryke/hash/murmurhash";
10
- import { getUniqueBy } from "@stryke/helpers/get-unique";
11
- import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
12
- import { isFile } from "@stryke/fs/is-file";
13
-
14
- //#region ../powerlines/src/lib/entry.ts
15
- function resolveEntryInputFile(context, typeDefinition) {
16
- return replacePath(typeDefinition.file, joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot));
17
- }
18
- function resolveEntryInput(context, typeDefinition) {
19
- return {
20
- file: resolveEntryInputFile(context, typeDefinition),
21
- name: typeDefinition.name
22
- };
23
- }
24
- function resolveEntryOutput(context, typeDefinition) {
25
- return replaceExtension(replacePath(replacePath(replacePath(replacePath(replacePath(typeDefinition.file, joinPaths(context.workspaceConfig.workspaceRoot, context.config.sourceRoot)), joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot)), context.config.sourceRoot), context.config.projectRoot), replacePath(context.config.sourceRoot, context.config.projectRoot)));
26
- }
27
- function resolveEntry(context, typeDefinition) {
28
- const input = resolveEntryInput(context, typeDefinition);
29
- return {
30
- ...input,
31
- input,
32
- output: resolveEntryOutput(context, typeDefinition)
33
- };
34
- }
35
- /**
36
- * Resolves multiple type definitions into their corresponding resolved entry type definitions.
37
- *
38
- * @param context - The current context
39
- * @param typeDefinitions - The type definitions to resolve.
40
- * @returns A promise that resolves to an array of resolved entry type definitions.
41
- */
42
- function resolveEntriesSync(context, typeDefinitions) {
43
- return typeDefinitions.map((entry) => isString(entry) ? replacePathTokens(context, entry) : replacePathTokens(context, entry.file)).map((typeDefinition) => {
44
- const parsed = parseTypeDefinition(typeDefinition);
45
- const filePath = appendPath(parsed.file, context.config.projectRoot);
46
- if (isFile(filePath)) return resolveEntry(context, {
47
- file: replacePath(filePath, context.config.projectRoot),
48
- name: parsed.name
49
- });
50
- return listFilesSync(filePath).map((file) => resolveEntry(context, {
51
- file,
52
- name: parsed.name
53
- }));
54
- }).flat().filter(Boolean);
55
- }
56
- /**
57
- * Get unique entries from the provided list.
58
- *
59
- * @param entries - The entries to process.
60
- * @returns An array of unique entries (by file path or content hash).
61
- */
62
- function getUniqueEntries(entries = []) {
63
- return getUniqueBy(toArray(entries), (item) => isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 }));
64
- }
65
-
66
- //#endregion
67
- export { getUniqueEntries, resolveEntriesSync };