@powerlines/plugin-webpack 0.5.137 → 0.5.139

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 (84) hide show
  1. package/dist/helpers/unplugin.cjs +2 -3
  2. package/dist/helpers/unplugin.mjs +1 -2
  3. package/dist/index.cjs +3 -4
  4. package/dist/index.mjs +4 -5
  5. package/dist/powerlines/src/types/babel.d.mts +1 -3
  6. package/dist/powerlines/src/types/config.d.mts +1 -2
  7. package/dist/powerlines/src/types/context.d.mts +5 -5
  8. package/dist/powerlines/src/types/fs.d.mts +1 -1
  9. package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
  10. package/package.json +5 -10
  11. package/dist/powerlines/schemas/fs.cjs +0 -226
  12. package/dist/powerlines/schemas/fs.mjs +0 -224
  13. package/dist/powerlines/src/api.cjs +0 -580
  14. package/dist/powerlines/src/api.mjs +0 -578
  15. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
  16. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
  17. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
  18. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
  19. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
  20. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
  21. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -66
  22. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -64
  23. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
  24. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
  25. package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
  26. package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
  27. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
  28. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
  29. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  30. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  31. package/dist/powerlines/src/lib/build/webpack.cjs +0 -47
  32. package/dist/powerlines/src/lib/build/webpack.mjs +0 -45
  33. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  34. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  35. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  36. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  37. package/dist/powerlines/src/lib/contexts/context.cjs +0 -933
  38. package/dist/powerlines/src/lib/contexts/context.mjs +0 -931
  39. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -195
  40. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -194
  41. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
  42. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
  43. package/dist/powerlines/src/lib/entry.cjs +0 -69
  44. package/dist/powerlines/src/lib/entry.mjs +0 -67
  45. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  46. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  47. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  48. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  49. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  50. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  51. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  52. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  53. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
  54. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
  55. package/dist/powerlines/src/lib/logger.cjs +0 -58
  56. package/dist/powerlines/src/lib/logger.mjs +0 -55
  57. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
  58. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
  59. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  60. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  61. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  62. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  63. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -29
  64. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -27
  65. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
  66. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
  67. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
  68. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
  69. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  70. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  71. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
  72. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
  73. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  74. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  75. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -167
  76. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -156
  77. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  78. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  79. package/dist/powerlines/src/types/build.cjs +0 -23
  80. package/dist/powerlines/src/types/build.mjs +0 -21
  81. package/dist/powerlines/src/types/commands.cjs +0 -16
  82. package/dist/powerlines/src/types/commands.mjs +0 -15
  83. package/dist/powerlines/src/types/plugin.cjs +0 -33
  84. package/dist/powerlines/src/types/plugin.mjs +0 -32
@@ -1,195 +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_helpers$1 = require('../unplugin/helpers.cjs');
6
- const require_plugin_context = require('./plugin-context.cjs');
7
- let __stryke_fs_resolve = require("@stryke/fs/resolve");
8
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
9
- let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
10
- let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
11
-
12
- //#region ../powerlines/src/lib/contexts/environment-context.ts
13
- var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends require_context.PowerlinesContext {
14
- /**
15
- * The hooks registered by plugins in this environment
16
- */
17
- #hooks = {};
18
- /**
19
- * Create a new Storm context from the workspace root and user config.
20
- *
21
- * @param workspaceConfig - The root directory of the workspace.
22
- * @param config - The user configuration options.
23
- * @returns A promise that resolves to the new context.
24
- */
25
- static async fromConfig(workspaceConfig, config) {
26
- const context = new PowerlinesEnvironmentContext(config, workspaceConfig);
27
- await context.init();
28
- const powerlinesPath = await (0, __stryke_fs_resolve.resolvePackage)("powerlines");
29
- if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
30
- context.powerlinesPath = powerlinesPath;
31
- return context;
32
- }
33
- /**
34
- * The resolved environment configuration
35
- */
36
- environment;
37
- /**
38
- * The list of plugins applied to this environment
39
- */
40
- plugins = [];
41
- /**
42
- * The resolved configuration options
43
- */
44
- get config() {
45
- return super.config;
46
- }
47
- get hooks() {
48
- return this.#hooks;
49
- }
50
- async addPlugin(plugin) {
51
- let resolvedPlugin = plugin;
52
- if ((0, __stryke_type_checks_is_function.isFunction)(plugin.applyToEnvironment)) {
53
- const result = await Promise.resolve(plugin.applyToEnvironment(this.environment));
54
- if (!result || (0, __stryke_type_checks_is_object.isObject)(result) && Object.keys(result).length === 0) return;
55
- if (require_helpers.isPluginConfig(result)) return this.$$internal.addPlugin(result);
56
- resolvedPlugin = require_helpers.isPlugin(result) ? result : plugin;
57
- }
58
- const context = require_plugin_context.createPluginContext(resolvedPlugin, this);
59
- this.plugins.push({
60
- plugin: resolvedPlugin,
61
- context
62
- });
63
- this.#hooks = Object.keys(resolvedPlugin).filter((key) => !require_plugin.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => {
64
- const hook = key;
65
- if (require_helpers.isPluginHookField(hook)) {
66
- const pluginHook = resolvedPlugin[hook];
67
- if (!require_helpers.isPluginHook(pluginHook)) return ret;
68
- ret[hook] ??= {
69
- preEnforced: [],
70
- preOrdered: [],
71
- normal: [],
72
- postEnforced: [],
73
- postOrdered: []
74
- };
75
- if (resolvedPlugin.enforce) {
76
- const hookListOrder$1 = `${resolvedPlugin.enforce}Enforced`;
77
- ret[hook][hookListOrder$1] ??= [];
78
- const bucket = ret[hook][hookListOrder$1];
79
- require_helpers.addPluginHook(context, resolvedPlugin, pluginHook, bucket);
80
- return ret;
81
- }
82
- if ((0, __stryke_type_checks_is_function.isFunction)(pluginHook) || !pluginHook.order) {
83
- ret[hook].normal ??= [];
84
- const bucket = ret[hook].normal;
85
- require_helpers.addPluginHook(context, resolvedPlugin, pluginHook, bucket);
86
- return ret;
87
- }
88
- const hookListOrder = `${pluginHook.order}Ordered`;
89
- ret[hook][hookListOrder] ??= [];
90
- require_helpers.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][hookListOrder]);
91
- return ret;
92
- } else if (require_helpers.isUnpluginHookField(hook)) {
93
- const unpluginPlugin = resolvedPlugin[hook];
94
- if (!(0, __stryke_type_checks_is_set_object.isSetObject)(unpluginPlugin)) return ret;
95
- for (const field of Object.keys(unpluginPlugin)) {
96
- const variantField = field;
97
- const pluginHook = unpluginPlugin[variantField];
98
- if (!require_helpers.isPluginHook(pluginHook)) continue;
99
- ret[hook] ??= {};
100
- ret[hook][variantField] ??= {
101
- preEnforced: [],
102
- preOrdered: [],
103
- normal: [],
104
- postEnforced: [],
105
- postOrdered: []
106
- };
107
- if (resolvedPlugin.enforce) {
108
- require_helpers.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${resolvedPlugin.enforce}Enforced`]);
109
- return ret;
110
- }
111
- if ((0, __stryke_type_checks_is_function.isFunction)(pluginHook) || !pluginHook.order) {
112
- require_helpers.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][variantField].normal);
113
- return ret;
114
- }
115
- require_helpers.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${pluginHook.order}Ordered`]);
116
- }
117
- } else this.warn(`Unknown plugin hook field: ${String(hook)}`);
118
- return ret;
119
- }, this.hooks);
120
- }
121
- /**
122
- * Retrieves the hook handlers for a specific hook name
123
- */
124
- selectHooks(key, options) {
125
- const result = [];
126
- if (require_helpers.isUnpluginHookKey(key)) {
127
- const variant = String(key).split(":")[0];
128
- if (require_helpers$1.isUnpluginBuilderVariant(variant)) {
129
- const hooks = this.hooks[variant];
130
- if (hooks) {
131
- const field = String(key).split(":")[1];
132
- if (field && hooks[field]) {
133
- const fieldHooks = hooks[field];
134
- if (options?.order) {
135
- const mapHooksToResult = (hooksList) => hooksList.map((hook) => {
136
- const plugin = this.plugins.find((p) => p.plugin.name === hook.plugin.name);
137
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${hook.plugin.name}".`);
138
- return {
139
- handler: hook.handler,
140
- plugin: hook.plugin,
141
- context: plugin.context
142
- };
143
- });
144
- if (options?.order === "pre") {
145
- result.push(...mapHooksToResult(fieldHooks.preOrdered ?? []));
146
- result.push(...mapHooksToResult(fieldHooks.preEnforced ?? []));
147
- } else if (options?.order === "post") {
148
- result.push(...mapHooksToResult(fieldHooks.postOrdered ?? []));
149
- result.push(...mapHooksToResult(fieldHooks.postEnforced ?? []));
150
- } else result.push(...mapHooksToResult(fieldHooks.normal ?? []));
151
- } else {
152
- result.push(...this.selectHooks(key, { order: "pre" }));
153
- result.push(...this.selectHooks(key, { order: "normal" }));
154
- result.push(...this.selectHooks(key, { order: "post" }));
155
- }
156
- }
157
- }
158
- }
159
- } else if (require_helpers.isPluginHookField(key)) {
160
- if (this.hooks[key]) {
161
- const fieldHooks = this.hooks[key];
162
- if (options?.order) {
163
- const mapHooksToResult = (hooksList) => hooksList.map((hook) => {
164
- const plugin = this.plugins.find((p) => p.plugin.name === hook.plugin.name);
165
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${hook.plugin.name}".`);
166
- return {
167
- handler: hook.handler,
168
- plugin: hook.plugin,
169
- context: plugin.context
170
- };
171
- });
172
- if (options?.order === "pre") {
173
- result.push(...mapHooksToResult(fieldHooks.preOrdered ?? []));
174
- result.push(...mapHooksToResult(fieldHooks.preEnforced ?? []));
175
- } else if (options?.order === "post") {
176
- result.push(...mapHooksToResult(fieldHooks.postOrdered ?? []));
177
- result.push(...mapHooksToResult(fieldHooks.postEnforced ?? []));
178
- } else result.push(...mapHooksToResult(fieldHooks.normal ?? []));
179
- } else {
180
- result.push(...this.selectHooks(key, { order: "pre" }));
181
- result.push(...this.selectHooks(key, { order: "normal" }));
182
- result.push(...this.selectHooks(key, { order: "post" }));
183
- }
184
- }
185
- } else throw new Error(`Unknown plugin hook key: ${String(key)}`);
186
- return result;
187
- }
188
- constructor(config, workspaceConfig) {
189
- super(workspaceConfig);
190
- this.resolvedConfig = config;
191
- }
192
- };
193
-
194
- //#endregion
195
- exports.PowerlinesEnvironmentContext = PowerlinesEnvironmentContext;
@@ -1,194 +0,0 @@
1
- import { PLUGIN_NON_HOOK_FIELDS } from "../../types/plugin.mjs";
2
- import { addPluginHook, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, isUnpluginHookField, isUnpluginHookKey } from "../../plugin-utils/helpers.mjs";
3
- import { PowerlinesContext } from "./context.mjs";
4
- import { isUnpluginBuilderVariant } from "../unplugin/helpers.mjs";
5
- import { createPluginContext } from "./plugin-context.mjs";
6
- import { resolvePackage } from "@stryke/fs/resolve";
7
- import { isFunction } from "@stryke/type-checks/is-function";
8
- import { isObject } from "@stryke/type-checks/is-object";
9
- import { isSetObject } from "@stryke/type-checks/is-set-object";
10
-
11
- //#region ../powerlines/src/lib/contexts/environment-context.ts
12
- var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends PowerlinesContext {
13
- /**
14
- * The hooks registered by plugins in this environment
15
- */
16
- #hooks = {};
17
- /**
18
- * Create a new Storm context from the workspace root and user config.
19
- *
20
- * @param workspaceConfig - The root directory of the workspace.
21
- * @param config - The user configuration options.
22
- * @returns A promise that resolves to the new context.
23
- */
24
- static async fromConfig(workspaceConfig, config) {
25
- const context = new PowerlinesEnvironmentContext(config, workspaceConfig);
26
- await context.init();
27
- const powerlinesPath = await resolvePackage("powerlines");
28
- if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
29
- context.powerlinesPath = powerlinesPath;
30
- return context;
31
- }
32
- /**
33
- * The resolved environment configuration
34
- */
35
- environment;
36
- /**
37
- * The list of plugins applied to this environment
38
- */
39
- plugins = [];
40
- /**
41
- * The resolved configuration options
42
- */
43
- get config() {
44
- return super.config;
45
- }
46
- get hooks() {
47
- return this.#hooks;
48
- }
49
- async addPlugin(plugin) {
50
- let resolvedPlugin = plugin;
51
- if (isFunction(plugin.applyToEnvironment)) {
52
- const result = await Promise.resolve(plugin.applyToEnvironment(this.environment));
53
- if (!result || isObject(result) && Object.keys(result).length === 0) return;
54
- if (isPluginConfig(result)) return this.$$internal.addPlugin(result);
55
- resolvedPlugin = isPlugin(result) ? result : plugin;
56
- }
57
- const context = createPluginContext(resolvedPlugin, this);
58
- this.plugins.push({
59
- plugin: resolvedPlugin,
60
- context
61
- });
62
- this.#hooks = Object.keys(resolvedPlugin).filter((key) => !PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => {
63
- const hook = key;
64
- if (isPluginHookField(hook)) {
65
- const pluginHook = resolvedPlugin[hook];
66
- if (!isPluginHook(pluginHook)) return ret;
67
- ret[hook] ??= {
68
- preEnforced: [],
69
- preOrdered: [],
70
- normal: [],
71
- postEnforced: [],
72
- postOrdered: []
73
- };
74
- if (resolvedPlugin.enforce) {
75
- const hookListOrder$1 = `${resolvedPlugin.enforce}Enforced`;
76
- ret[hook][hookListOrder$1] ??= [];
77
- const bucket = ret[hook][hookListOrder$1];
78
- addPluginHook(context, resolvedPlugin, pluginHook, bucket);
79
- return ret;
80
- }
81
- if (isFunction(pluginHook) || !pluginHook.order) {
82
- ret[hook].normal ??= [];
83
- const bucket = ret[hook].normal;
84
- addPluginHook(context, resolvedPlugin, pluginHook, bucket);
85
- return ret;
86
- }
87
- const hookListOrder = `${pluginHook.order}Ordered`;
88
- ret[hook][hookListOrder] ??= [];
89
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][hookListOrder]);
90
- return ret;
91
- } else if (isUnpluginHookField(hook)) {
92
- const unpluginPlugin = resolvedPlugin[hook];
93
- if (!isSetObject(unpluginPlugin)) return ret;
94
- for (const field of Object.keys(unpluginPlugin)) {
95
- const variantField = field;
96
- const pluginHook = unpluginPlugin[variantField];
97
- if (!isPluginHook(pluginHook)) continue;
98
- ret[hook] ??= {};
99
- ret[hook][variantField] ??= {
100
- preEnforced: [],
101
- preOrdered: [],
102
- normal: [],
103
- postEnforced: [],
104
- postOrdered: []
105
- };
106
- if (resolvedPlugin.enforce) {
107
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${resolvedPlugin.enforce}Enforced`]);
108
- return ret;
109
- }
110
- if (isFunction(pluginHook) || !pluginHook.order) {
111
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][variantField].normal);
112
- return ret;
113
- }
114
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${pluginHook.order}Ordered`]);
115
- }
116
- } else this.warn(`Unknown plugin hook field: ${String(hook)}`);
117
- return ret;
118
- }, this.hooks);
119
- }
120
- /**
121
- * Retrieves the hook handlers for a specific hook name
122
- */
123
- selectHooks(key, options) {
124
- const result = [];
125
- if (isUnpluginHookKey(key)) {
126
- const variant = String(key).split(":")[0];
127
- if (isUnpluginBuilderVariant(variant)) {
128
- const hooks = this.hooks[variant];
129
- if (hooks) {
130
- const field = String(key).split(":")[1];
131
- if (field && hooks[field]) {
132
- const fieldHooks = hooks[field];
133
- if (options?.order) {
134
- const mapHooksToResult = (hooksList) => hooksList.map((hook) => {
135
- const plugin = this.plugins.find((p) => p.plugin.name === hook.plugin.name);
136
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${hook.plugin.name}".`);
137
- return {
138
- handler: hook.handler,
139
- plugin: hook.plugin,
140
- context: plugin.context
141
- };
142
- });
143
- if (options?.order === "pre") {
144
- result.push(...mapHooksToResult(fieldHooks.preOrdered ?? []));
145
- result.push(...mapHooksToResult(fieldHooks.preEnforced ?? []));
146
- } else if (options?.order === "post") {
147
- result.push(...mapHooksToResult(fieldHooks.postOrdered ?? []));
148
- result.push(...mapHooksToResult(fieldHooks.postEnforced ?? []));
149
- } else result.push(...mapHooksToResult(fieldHooks.normal ?? []));
150
- } else {
151
- result.push(...this.selectHooks(key, { order: "pre" }));
152
- result.push(...this.selectHooks(key, { order: "normal" }));
153
- result.push(...this.selectHooks(key, { order: "post" }));
154
- }
155
- }
156
- }
157
- }
158
- } else if (isPluginHookField(key)) {
159
- if (this.hooks[key]) {
160
- const fieldHooks = this.hooks[key];
161
- if (options?.order) {
162
- const mapHooksToResult = (hooksList) => hooksList.map((hook) => {
163
- const plugin = this.plugins.find((p) => p.plugin.name === hook.plugin.name);
164
- if (!plugin) throw new Error(`Could not find plugin context for plugin "${hook.plugin.name}".`);
165
- return {
166
- handler: hook.handler,
167
- plugin: hook.plugin,
168
- context: plugin.context
169
- };
170
- });
171
- if (options?.order === "pre") {
172
- result.push(...mapHooksToResult(fieldHooks.preOrdered ?? []));
173
- result.push(...mapHooksToResult(fieldHooks.preEnforced ?? []));
174
- } else if (options?.order === "post") {
175
- result.push(...mapHooksToResult(fieldHooks.postOrdered ?? []));
176
- result.push(...mapHooksToResult(fieldHooks.postEnforced ?? []));
177
- } else result.push(...mapHooksToResult(fieldHooks.normal ?? []));
178
- } else {
179
- result.push(...this.selectHooks(key, { order: "pre" }));
180
- result.push(...this.selectHooks(key, { order: "normal" }));
181
- result.push(...this.selectHooks(key, { order: "post" }));
182
- }
183
- }
184
- } else throw new Error(`Unknown plugin hook key: ${String(key)}`);
185
- return result;
186
- }
187
- constructor(config, workspaceConfig) {
188
- super(workspaceConfig);
189
- this.resolvedConfig = config;
190
- }
191
- };
192
-
193
- //#endregion
194
- 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 };