@powerlines/plugin-webpack 0.5.134 → 0.5.136

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 (35) hide show
  1. package/dist/powerlines/src/internal/helpers/hooks.cjs +15 -12
  2. package/dist/powerlines/src/internal/helpers/hooks.d.cts +47 -0
  3. package/dist/powerlines/src/internal/helpers/hooks.d.mts +49 -0
  4. package/dist/powerlines/src/internal/helpers/hooks.mjs +15 -12
  5. package/dist/powerlines/src/lib/contexts/environment-context.cjs +108 -73
  6. package/dist/powerlines/src/lib/contexts/environment-context.mjs +109 -74
  7. package/dist/powerlines/src/lib/unplugin/helpers.cjs +13 -1
  8. package/dist/powerlines/src/lib/unplugin/helpers.mjs +12 -1
  9. package/dist/powerlines/src/lib/unplugin/index.cjs +1 -1
  10. package/dist/powerlines/src/lib/unplugin/index.mjs +1 -1
  11. package/dist/powerlines/src/lib/unplugin/plugin.cjs +3 -3
  12. package/dist/powerlines/src/lib/unplugin/plugin.mjs +3 -3
  13. package/dist/powerlines/src/plugin-utils/helpers.cjs +34 -15
  14. package/dist/powerlines/src/plugin-utils/helpers.mjs +33 -15
  15. package/dist/powerlines/src/types/api.d.cts +104 -0
  16. package/dist/powerlines/src/types/api.d.mts +104 -0
  17. package/dist/powerlines/src/types/build.cjs +11 -3
  18. package/dist/powerlines/src/types/build.d.cts +39 -3
  19. package/dist/powerlines/src/types/build.d.mts +39 -3
  20. package/dist/powerlines/src/types/build.mjs +10 -3
  21. package/dist/powerlines/src/types/config.d.cts +60 -5
  22. package/dist/powerlines/src/types/config.d.mts +60 -5
  23. package/dist/powerlines/src/types/context.d.cts +113 -1
  24. package/dist/powerlines/src/types/context.d.mts +113 -3
  25. package/dist/powerlines/src/types/hooks.d.cts +32 -0
  26. package/dist/powerlines/src/types/hooks.d.mts +32 -2
  27. package/dist/powerlines/src/types/plugin.cjs +5 -4
  28. package/dist/powerlines/src/types/plugin.d.cts +35 -61
  29. package/dist/powerlines/src/types/plugin.d.mts +35 -61
  30. package/dist/powerlines/src/types/plugin.mjs +6 -5
  31. package/dist/powerlines/src/types/resolved.d.cts +15 -4
  32. package/dist/powerlines/src/types/resolved.d.mts +15 -5
  33. package/dist/powerlines/src/types/unplugin.d.cts +22 -0
  34. package/dist/powerlines/src/types/unplugin.d.mts +23 -0
  35. package/package.json +5 -5
@@ -1,5 +1,7 @@
1
1
  const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_build = require('../../types/build.cjs');
2
3
  let defu = require("defu");
4
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
3
5
 
4
6
  //#region ../powerlines/src/lib/unplugin/helpers.ts
5
7
  /**
@@ -12,6 +14,16 @@ let defu = require("defu");
12
14
  function combineContexts(context, unplugin) {
13
15
  return (0, defu.defu)(context, unplugin);
14
16
  }
17
+ /**
18
+ * Checks if a value is a valid UnpluginBuilderVariant.
19
+ *
20
+ * @param str - The value to check.
21
+ * @returns True if the value is a UnpluginBuilderVariant, false otherwise.
22
+ */
23
+ function isUnpluginBuilderVariant(str) {
24
+ return (0, __stryke_type_checks_is_set_string.isSetString)(str) && require_build.UNPLUGIN_BUILDER_VARIANTS.includes(str);
25
+ }
15
26
 
16
27
  //#endregion
17
- exports.combineContexts = combineContexts;
28
+ exports.combineContexts = combineContexts;
29
+ exports.isUnpluginBuilderVariant = isUnpluginBuilderVariant;
@@ -1,4 +1,6 @@
1
+ import { UNPLUGIN_BUILDER_VARIANTS } from "../../types/build.mjs";
1
2
  import { defu } from "defu";
3
+ import { isSetString } from "@stryke/type-checks/is-set-string";
2
4
 
3
5
  //#region ../powerlines/src/lib/unplugin/helpers.ts
4
6
  /**
@@ -11,6 +13,15 @@ import { defu } from "defu";
11
13
  function combineContexts(context, unplugin) {
12
14
  return defu(context, unplugin);
13
15
  }
16
+ /**
17
+ * Checks if a value is a valid UnpluginBuilderVariant.
18
+ *
19
+ * @param str - The value to check.
20
+ * @returns True if the value is a UnpluginBuilderVariant, false otherwise.
21
+ */
22
+ function isUnpluginBuilderVariant(str) {
23
+ return isSetString(str) && UNPLUGIN_BUILDER_VARIANTS.includes(str);
24
+ }
14
25
 
15
26
  //#endregion
16
- export { combineContexts };
27
+ export { combineContexts, isUnpluginBuilderVariant };
@@ -1,3 +1,3 @@
1
- require('./factory.cjs');
2
1
  const require_helpers = require('./helpers.cjs');
2
+ require('./factory.cjs');
3
3
  const require_plugin = require('./plugin.cjs');
@@ -1,5 +1,5 @@
1
+ import { combineContexts, isUnpluginBuilderVariant } from "./helpers.mjs";
1
2
  import "./factory.mjs";
2
- import { combineContexts } from "./helpers.mjs";
3
3
  import { createUnplugin } from "./plugin.mjs";
4
4
 
5
5
  export { };
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
2
  const require_logger = require('../logger.cjs');
3
- const require_source_file = require('../utilities/source-file.cjs');
4
3
  const require_helpers = require('./helpers.cjs');
4
+ const require_source_file = require('../utilities/source-file.cjs');
5
5
  let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
6
6
  let unplugin = require("unplugin");
7
7
  let __stryke_path_replace = require("@stryke/path/replace");
@@ -86,8 +86,8 @@ export * from "${(0, __stryke_type_checks_is_string.isString)(resolved) ? resolv
86
86
  }
87
87
  async function transform(code, id) {
88
88
  let transformed = code;
89
- for (const handler of ctx.$$internal.environment.selectHooks("transform")) {
90
- const result = await handler.handle.apply(require_helpers.combineContexts(ctx, this), [require_source_file.getString(transformed), id]);
89
+ for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
90
+ const result = await hook.handler.apply(require_helpers.combineContexts(ctx, this), [require_source_file.getString(transformed), id]);
91
91
  if (result) transformed = result;
92
92
  }
93
93
  return transformed;
@@ -1,6 +1,6 @@
1
1
  import { extendLog } from "../logger.mjs";
2
- import { getString } from "../utilities/source-file.mjs";
3
2
  import { combineContexts } from "./helpers.mjs";
3
+ import { getString } from "../utilities/source-file.mjs";
4
4
  import { LogLevelLabel } from "@storm-software/config-tools/types";
5
5
  import { setParseImpl } from "unplugin";
6
6
  import { replaceExtension } from "@stryke/path/replace";
@@ -85,8 +85,8 @@ export * from "${isString(resolved) ? resolved : resolved.id}";
85
85
  }
86
86
  async function transform(code, id) {
87
87
  let transformed = code;
88
- for (const handler of ctx.$$internal.environment.selectHooks("transform")) {
89
- const result = await handler.handle.apply(combineContexts(ctx, this), [getString(transformed), id]);
88
+ for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
89
+ const result = await hook.handler.apply(combineContexts(ctx, this), [getString(transformed), id]);
90
90
  if (result) transformed = result;
91
91
  }
92
92
  return transformed;
@@ -14,7 +14,7 @@ let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefine
14
14
  * @returns True if the object is a {@link Plugin}, false otherwise
15
15
  */
16
16
  function isPlugin(value) {
17
- return (0, __stryke_type_checks_is_set_object.isSetObject)(value) && "name" in value && (0, __stryke_type_checks_is_set_string.isSetString)(value.name) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.api) || "api" in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value.api)) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.applyToEnvironment) || "applyToEnvironment" in value && (0, __stryke_type_checks_is_function.isFunction)(value.applyToEnvironment)) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.dedupe) || "dedupe" in value && (0, __stryke_type_checks_is_function.isFunction)(value.dedupe)) && require_plugin.KNOWN_HOOKS.every((hook) => (0, __stryke_type_checks_is_undefined.isUndefined)(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && (0, __stryke_type_checks_is_set_object.isSetObject)(value[hook]))) && require_build.UNPLUGIN_BUILD_VARIANTS.every((variant) => (0, __stryke_type_checks_is_undefined.isUndefined)(value[variant]) || variant in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value[variant]));
17
+ return (0, __stryke_type_checks_is_set_object.isSetObject)(value) && "name" in value && (0, __stryke_type_checks_is_set_string.isSetString)(value.name) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.api) || "api" in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value.api)) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.applyToEnvironment) || "applyToEnvironment" in value && (0, __stryke_type_checks_is_function.isFunction)(value.applyToEnvironment)) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.dedupe) || "dedupe" in value && (0, __stryke_type_checks_is_function.isFunction)(value.dedupe)) && require_plugin.PLUGIN_HOOKS_FIELDS.every((hook) => (0, __stryke_type_checks_is_undefined.isUndefined)(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && (0, __stryke_type_checks_is_set_object.isSetObject)(value[hook]))) && require_build.BUILDER_VARIANTS.every((variant) => (0, __stryke_type_checks_is_undefined.isUndefined)(value[variant]) || variant in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value[variant]));
18
18
  }
19
19
  /**
20
20
  * Type guard to check if an object is a {@link PluginConfigObject}
@@ -82,11 +82,29 @@ function getHookHandler(pluginHook) {
82
82
  /**
83
83
  * Check if a hook is external.
84
84
  *
85
- * @param hook - The name of the hook to check.
85
+ * @param keys - The name of the hook to check.
86
86
  * @returns True if the hook is external, false otherwise.
87
87
  */
88
- function isHookExternal(hook) {
89
- return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
88
+ function isUnpluginHookKey(keys) {
89
+ return require_build.UNPLUGIN_BUILDER_VARIANTS.some((variant) => keys.startsWith(`${variant}:`));
90
+ }
91
+ /**
92
+ * Check if a hook is internal.
93
+ *
94
+ * @param keys - The name of the hook to check.
95
+ * @returns True if the hook is external, false otherwise.
96
+ */
97
+ function isPluginHookField(keys) {
98
+ return !isUnpluginHookKey(keys) && require_plugin.PLUGIN_HOOKS_FIELDS.includes(keys);
99
+ }
100
+ /**
101
+ * Check if a hook is external.
102
+ *
103
+ * @param field - The name of the hook to check.
104
+ * @returns True if the hook is external, false otherwise.
105
+ */
106
+ function isUnpluginHookField(field) {
107
+ return !isPluginHookField(field) && require_build.UNPLUGIN_BUILDER_VARIANTS.includes(field);
90
108
  }
91
109
  /**
92
110
  * Check if a plugin should be deduplicated.
@@ -107,14 +125,14 @@ function checkDedupe(plugin, plugins) {
107
125
  * @param hooksList - The list of hooks to add to
108
126
  */
109
127
  function addPluginHook(context, plugin, pluginHook, hooksList) {
110
- if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) hooksList.push((0, __stryke_type_checks_is_function.isFunction)(pluginHook) ? {
111
- plugin,
112
- handler: getHookHandler(pluginHook).bind(context)
113
- } : {
114
- plugin,
115
- ...pluginHook,
116
- handler: getHookHandler(pluginHook).bind(context)
117
- });
128
+ if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin).filter(Boolean))) {
129
+ const handler = ((...args) => getHookHandler(pluginHook).apply(context, args));
130
+ if (!handler) return;
131
+ hooksList.push({
132
+ plugin,
133
+ handler
134
+ });
135
+ }
118
136
  }
119
137
  /**
120
138
  * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.
@@ -139,10 +157,11 @@ function findInvalidPluginConfig(config) {
139
157
  exports.addPluginHook = addPluginHook;
140
158
  exports.checkDedupe = checkDedupe;
141
159
  exports.findInvalidPluginConfig = findInvalidPluginConfig;
142
- exports.getHookHandler = getHookHandler;
143
- exports.isHookExternal = isHookExternal;
144
160
  exports.isPlugin = isPlugin;
145
161
  exports.isPluginConfig = isPluginConfig;
146
162
  exports.isPluginConfigObject = isPluginConfigObject;
147
163
  exports.isPluginConfigTuple = isPluginConfigTuple;
148
- exports.isPluginHook = isPluginHook;
164
+ exports.isPluginHook = isPluginHook;
165
+ exports.isPluginHookField = isPluginHookField;
166
+ exports.isUnpluginHookField = isUnpluginHookField;
167
+ exports.isUnpluginHookKey = isUnpluginHookKey;
@@ -1,5 +1,5 @@
1
- import { UNPLUGIN_BUILD_VARIANTS } from "../types/build.mjs";
2
- import { KNOWN_HOOKS } from "../types/plugin.mjs";
1
+ import { BUILDER_VARIANTS, UNPLUGIN_BUILDER_VARIANTS } from "../types/build.mjs";
2
+ import { PLUGIN_HOOKS_FIELDS } from "../types/plugin.mjs";
3
3
  import { isFunction } from "@stryke/type-checks/is-function";
4
4
  import { isSetObject } from "@stryke/type-checks/is-set-object";
5
5
  import { isSetString } from "@stryke/type-checks/is-set-string";
@@ -13,7 +13,7 @@ import { isUndefined } from "@stryke/type-checks/is-undefined";
13
13
  * @returns True if the object is a {@link Plugin}, false otherwise
14
14
  */
15
15
  function isPlugin(value) {
16
- return isSetObject(value) && "name" in value && isSetString(value.name) && (isUndefined(value.api) || "api" in value && isSetObject(value.api)) && (isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction(value.applyToEnvironment)) && (isUndefined(value.dedupe) || "dedupe" in value && isFunction(value.dedupe)) && KNOWN_HOOKS.every((hook) => isUndefined(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && isSetObject(value[hook]))) && UNPLUGIN_BUILD_VARIANTS.every((variant) => isUndefined(value[variant]) || variant in value && isSetObject(value[variant]));
16
+ return isSetObject(value) && "name" in value && isSetString(value.name) && (isUndefined(value.api) || "api" in value && isSetObject(value.api)) && (isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction(value.applyToEnvironment)) && (isUndefined(value.dedupe) || "dedupe" in value && isFunction(value.dedupe)) && PLUGIN_HOOKS_FIELDS.every((hook) => isUndefined(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && isSetObject(value[hook]))) && BUILDER_VARIANTS.every((variant) => isUndefined(value[variant]) || variant in value && isSetObject(value[variant]));
17
17
  }
18
18
  /**
19
19
  * Type guard to check if an object is a {@link PluginConfigObject}
@@ -81,11 +81,29 @@ function getHookHandler(pluginHook) {
81
81
  /**
82
82
  * Check if a hook is external.
83
83
  *
84
- * @param hook - The name of the hook to check.
84
+ * @param keys - The name of the hook to check.
85
85
  * @returns True if the hook is external, false otherwise.
86
86
  */
87
- function isHookExternal(hook) {
88
- return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
87
+ function isUnpluginHookKey(keys) {
88
+ return UNPLUGIN_BUILDER_VARIANTS.some((variant) => keys.startsWith(`${variant}:`));
89
+ }
90
+ /**
91
+ * Check if a hook is internal.
92
+ *
93
+ * @param keys - The name of the hook to check.
94
+ * @returns True if the hook is external, false otherwise.
95
+ */
96
+ function isPluginHookField(keys) {
97
+ return !isUnpluginHookKey(keys) && PLUGIN_HOOKS_FIELDS.includes(keys);
98
+ }
99
+ /**
100
+ * Check if a hook is external.
101
+ *
102
+ * @param field - The name of the hook to check.
103
+ * @returns True if the hook is external, false otherwise.
104
+ */
105
+ function isUnpluginHookField(field) {
106
+ return !isPluginHookField(field) && UNPLUGIN_BUILDER_VARIANTS.includes(field);
89
107
  }
90
108
  /**
91
109
  * Check if a plugin should be deduplicated.
@@ -106,14 +124,14 @@ function checkDedupe(plugin, plugins) {
106
124
  * @param hooksList - The list of hooks to add to
107
125
  */
108
126
  function addPluginHook(context, plugin, pluginHook, hooksList) {
109
- if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) hooksList.push(isFunction(pluginHook) ? {
110
- plugin,
111
- handler: getHookHandler(pluginHook).bind(context)
112
- } : {
113
- plugin,
114
- ...pluginHook,
115
- handler: getHookHandler(pluginHook).bind(context)
116
- });
127
+ if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin).filter(Boolean))) {
128
+ const handler = ((...args) => getHookHandler(pluginHook).apply(context, args));
129
+ if (!handler) return;
130
+ hooksList.push({
131
+ plugin,
132
+ handler
133
+ });
134
+ }
117
135
  }
118
136
  /**
119
137
  * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.
@@ -135,4 +153,4 @@ function findInvalidPluginConfig(config) {
135
153
  }
136
154
 
137
155
  //#endregion
138
- export { addPluginHook, checkDedupe, findInvalidPluginConfig, getHookHandler, isHookExternal, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook };
156
+ export { addPluginHook, checkDedupe, findInvalidPluginConfig, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isUnpluginHookField, isUnpluginHookKey };
@@ -0,0 +1,104 @@
1
+ import { ResolvedConfig } from "./resolved.cjs";
2
+ import { InferHookParameters, InferHookReturnType } from "./hooks.cjs";
3
+ import { CallHookOptions } from "../internal/helpers/hooks.cjs";
4
+ import { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, LintInlineConfig, NewInlineConfig, PrepareInlineConfig } from "./config.cjs";
5
+ import { APIContext, EnvironmentContext, PluginContext } from "./context.cjs";
6
+
7
+ //#region ../powerlines/src/types/api.d.ts
8
+
9
+ /**
10
+ * Powerlines API Interface
11
+ */
12
+ interface API<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
13
+ /**
14
+ * The Powerlines shared API context
15
+ */
16
+ context: APIContext<TResolvedConfig>;
17
+ /**
18
+ * Prepare the Powerlines API
19
+ *
20
+ * @remarks
21
+ * This method will prepare the Powerlines API for use, initializing any necessary resources.
22
+ *
23
+ * @param inlineConfig - The inline configuration for the prepare command
24
+ */
25
+ prepare: (inlineConfig: PrepareInlineConfig | NewInlineConfig | CleanInlineConfig | BuildInlineConfig | LintInlineConfig | DocsInlineConfig | DeployInlineConfig) => Promise<void>;
26
+ /**
27
+ * Create a new Powerlines project
28
+ *
29
+ * @remarks
30
+ * This method will create a new Powerlines project in the current directory.
31
+ *
32
+ * @param inlineConfig - The inline configuration for the new command
33
+ * @returns A promise that resolves when the project has been created
34
+ */
35
+ new: (inlineConfig: NewInlineConfig) => Promise<void>;
36
+ /**
37
+ * Clean any previously prepared artifacts
38
+ *
39
+ * @remarks
40
+ * This method will remove the previous Powerlines artifacts from the project.
41
+ *
42
+ * @param inlineConfig - The inline configuration for the clean command
43
+ * @returns A promise that resolves when the clean command has completed
44
+ */
45
+ clean: (inlineConfig: CleanInlineConfig | PrepareInlineConfig) => Promise<void>;
46
+ /**
47
+ * Lint the project source code
48
+ *
49
+ * @param inlineConfig - The inline configuration for the lint command
50
+ * @returns A promise that resolves when the lint command has completed
51
+ */
52
+ lint: (inlineConfig: LintInlineConfig) => Promise<void>;
53
+ /**
54
+ * Build the project
55
+ *
56
+ * @remarks
57
+ * This method will build the Powerlines project, generating the necessary artifacts.
58
+ *
59
+ * @param inlineConfig - The inline configuration for the build command
60
+ * @returns A promise that resolves when the build command has completed
61
+ */
62
+ build: (inlineConfig: BuildInlineConfig) => Promise<void>;
63
+ /**
64
+ * Prepare the documentation for the project
65
+ *
66
+ * @param inlineConfig - The inline configuration for the docs command
67
+ * @returns A promise that resolves when the documentation generation has completed
68
+ */
69
+ docs: (inlineConfig: DocsInlineConfig) => Promise<void>;
70
+ /**
71
+ * Deploy the project source code
72
+ *
73
+ * @remarks
74
+ * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
75
+ *
76
+ * @param inlineConfig - The inline configuration for the deploy command
77
+ */
78
+ deploy: (inlineConfig: DeployInlineConfig) => Promise<void>;
79
+ /**
80
+ * Finalization process
81
+ *
82
+ * @remarks
83
+ * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
84
+ *
85
+ * @returns A promise that resolves when the finalization process has completed
86
+ */
87
+ finalize: () => Promise<void>;
88
+ /**
89
+ * Invokes the configured plugin hooks
90
+ *
91
+ * @remarks
92
+ * By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
93
+ *
94
+ * @param hook - The hook to call
95
+ * @param options - The options to provide to the hook
96
+ * @param args - The arguments to pass to the hook
97
+ * @returns The result of the hook call
98
+ */
99
+ callHook: <TKey extends string>(hook: TKey, options: CallHookOptions & {
100
+ environment?: string | EnvironmentContext<TResolvedConfig>;
101
+ }, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
102
+ }
103
+ //#endregion
104
+ export { API };
@@ -0,0 +1,104 @@
1
+ import { ResolvedConfig } from "./resolved.mjs";
2
+ import { InferHookParameters, InferHookReturnType } from "./hooks.mjs";
3
+ import { CallHookOptions } from "../internal/helpers/hooks.mjs";
4
+ import { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, LintInlineConfig, NewInlineConfig, PrepareInlineConfig } from "./config.mjs";
5
+ import { APIContext, EnvironmentContext, PluginContext } from "./context.mjs";
6
+
7
+ //#region ../powerlines/src/types/api.d.ts
8
+
9
+ /**
10
+ * Powerlines API Interface
11
+ */
12
+ interface API<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
13
+ /**
14
+ * The Powerlines shared API context
15
+ */
16
+ context: APIContext<TResolvedConfig>;
17
+ /**
18
+ * Prepare the Powerlines API
19
+ *
20
+ * @remarks
21
+ * This method will prepare the Powerlines API for use, initializing any necessary resources.
22
+ *
23
+ * @param inlineConfig - The inline configuration for the prepare command
24
+ */
25
+ prepare: (inlineConfig: PrepareInlineConfig | NewInlineConfig | CleanInlineConfig | BuildInlineConfig | LintInlineConfig | DocsInlineConfig | DeployInlineConfig) => Promise<void>;
26
+ /**
27
+ * Create a new Powerlines project
28
+ *
29
+ * @remarks
30
+ * This method will create a new Powerlines project in the current directory.
31
+ *
32
+ * @param inlineConfig - The inline configuration for the new command
33
+ * @returns A promise that resolves when the project has been created
34
+ */
35
+ new: (inlineConfig: NewInlineConfig) => Promise<void>;
36
+ /**
37
+ * Clean any previously prepared artifacts
38
+ *
39
+ * @remarks
40
+ * This method will remove the previous Powerlines artifacts from the project.
41
+ *
42
+ * @param inlineConfig - The inline configuration for the clean command
43
+ * @returns A promise that resolves when the clean command has completed
44
+ */
45
+ clean: (inlineConfig: CleanInlineConfig | PrepareInlineConfig) => Promise<void>;
46
+ /**
47
+ * Lint the project source code
48
+ *
49
+ * @param inlineConfig - The inline configuration for the lint command
50
+ * @returns A promise that resolves when the lint command has completed
51
+ */
52
+ lint: (inlineConfig: LintInlineConfig) => Promise<void>;
53
+ /**
54
+ * Build the project
55
+ *
56
+ * @remarks
57
+ * This method will build the Powerlines project, generating the necessary artifacts.
58
+ *
59
+ * @param inlineConfig - The inline configuration for the build command
60
+ * @returns A promise that resolves when the build command has completed
61
+ */
62
+ build: (inlineConfig: BuildInlineConfig) => Promise<void>;
63
+ /**
64
+ * Prepare the documentation for the project
65
+ *
66
+ * @param inlineConfig - The inline configuration for the docs command
67
+ * @returns A promise that resolves when the documentation generation has completed
68
+ */
69
+ docs: (inlineConfig: DocsInlineConfig) => Promise<void>;
70
+ /**
71
+ * Deploy the project source code
72
+ *
73
+ * @remarks
74
+ * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
75
+ *
76
+ * @param inlineConfig - The inline configuration for the deploy command
77
+ */
78
+ deploy: (inlineConfig: DeployInlineConfig) => Promise<void>;
79
+ /**
80
+ * Finalization process
81
+ *
82
+ * @remarks
83
+ * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
84
+ *
85
+ * @returns A promise that resolves when the finalization process has completed
86
+ */
87
+ finalize: () => Promise<void>;
88
+ /**
89
+ * Invokes the configured plugin hooks
90
+ *
91
+ * @remarks
92
+ * By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
93
+ *
94
+ * @param hook - The hook to call
95
+ * @param options - The options to provide to the hook
96
+ * @param args - The arguments to pass to the hook
97
+ * @returns The result of the hook call
98
+ */
99
+ callHook: <TKey extends string>(hook: TKey, options: CallHookOptions & {
100
+ environment?: string | EnvironmentContext<TResolvedConfig>;
101
+ }, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
102
+ }
103
+ //#endregion
104
+ export { API };
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region ../powerlines/src/types/build.ts
3
- const UNPLUGIN_BUILD_VARIANTS = [
3
+ const UNPLUGIN_BUILDER_VARIANTS = [
4
4
  "rollup",
5
5
  "webpack",
6
6
  "rspack",
@@ -8,8 +8,16 @@ const UNPLUGIN_BUILD_VARIANTS = [
8
8
  "esbuild",
9
9
  "farm",
10
10
  "unloader",
11
- "rolldown"
11
+ "rolldown",
12
+ "bun"
13
+ ];
14
+ const BUILDER_VARIANTS = [
15
+ ...UNPLUGIN_BUILDER_VARIANTS,
16
+ "tsup",
17
+ "tsdown",
18
+ "unbuild"
12
19
  ];
13
20
 
14
21
  //#endregion
15
- exports.UNPLUGIN_BUILD_VARIANTS = UNPLUGIN_BUILD_VARIANTS;
22
+ exports.BUILDER_VARIANTS = BUILDER_VARIANTS;
23
+ exports.UNPLUGIN_BUILDER_VARIANTS = UNPLUGIN_BUILDER_VARIANTS;
@@ -1,8 +1,18 @@
1
1
  import { Configuration } from "webpack";
2
+ import { UserConfig } from "@farmfe/core";
3
+ import { Configuration as Configuration$1 } from "@rspack/core";
4
+ import { BuildOptions } from "@storm-software/tsup/types";
5
+ import { UnbuildOptions } from "@storm-software/unbuild/types";
6
+ import { BuildOptions as BuildOptions$1 } from "esbuild";
7
+ import { RolldownOptions } from "rolldown";
8
+ import { OutputOptions, RollupOptions } from "rollup";
9
+ import { UserConfig as UserConfig$1 } from "tsdown";
10
+ import { DepOptimizationOptions, UserConfig as UserConfig$2 } from "vite";
2
11
 
3
12
  //#region ../powerlines/src/types/build.d.ts
4
-
5
- type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
13
+ type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
14
+ type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
15
+ type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
6
16
  interface BuildConfig {
7
17
  /**
8
18
  * The platform to build the project for
@@ -143,7 +153,33 @@ interface BuildConfig {
143
153
  override?: Record<string, any>;
144
154
  }
145
155
  type BuildResolvedConfig = Omit<BuildConfig, "override">;
156
+ type ESBuildBuildConfig = Omit<BuildOptions$1, "entryPoints" | "sourceRoot" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel"> & BuildConfig;
157
+ type ESBuildResolvedBuildConfig = Omit<BuildOptions$1, "inject"> & BuildResolvedConfig;
158
+ type ViteBuildConfig = Omit<UserConfig$2, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig & {
159
+ /**
160
+ * Optimize deps config
161
+ */
162
+ optimizeDeps?: Omit<DepOptimizationOptions, "extensions">;
163
+ };
164
+ type ViteResolvedBuildConfig = UserConfig$2 & BuildResolvedConfig;
146
165
  type WebpackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
147
166
  type WebpackResolvedBuildConfig = Configuration & BuildResolvedConfig;
167
+ type RspackBuildConfig = Omit<Configuration$1, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
168
+ type RspackResolvedBuildConfig = Configuration$1 & BuildResolvedConfig;
169
+ type RollupBuildOutputConfig = Omit<OutputOptions, "dir" | "format">;
170
+ type RollupBuildConfig = Omit<RollupOptions, "entry" | "external" | "input" | "output" | "logLevel"> & {
171
+ output: RollupBuildOutputConfig | RollupBuildOutputConfig[];
172
+ } & BuildConfig;
173
+ type RollupResolvedBuildConfig = RollupOptions & BuildResolvedConfig;
174
+ type RolldownBuildConfig = Omit<RolldownOptions, "input" | "external" | "tsconfig" | "logLevel" | "output"> & BuildConfig;
175
+ type RolldownResolvedBuildConfig = RolldownOptions & BuildResolvedConfig;
176
+ type TsupBuildConfig = Partial<Omit<BuildOptions, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "clean" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
177
+ type TsupResolvedBuildConfig = BuildOptions & BuildResolvedConfig;
178
+ type TsdownBuildConfig = Partial<Omit<UserConfig$1, "name" | "outDir" | "clean" | "cwd" | "tsconfig" | "publicDir" | "copy" | "alias" | "format" | "platform" | "env" | "define" | "entry" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
179
+ type TsdownResolvedBuildConfig = UserConfig$1 & BuildResolvedConfig;
180
+ type UnbuildBuildConfig = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
181
+ type UnbuildResolvedBuildConfig = UnbuildOptions & BuildResolvedConfig;
182
+ type FarmBuildConfig = Partial<Omit<UserConfig, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
183
+ type FarmResolvedBuildConfig = UserConfig & BuildResolvedConfig;
148
184
  //#endregion
149
- export { BuildConfig, BuildResolvedConfig, UnpluginBuildVariant, WebpackBuildConfig, WebpackResolvedBuildConfig };
185
+ export { BuildConfig, BuildResolvedConfig, BuilderVariant, ESBuildBuildConfig, ESBuildResolvedBuildConfig, FarmBuildConfig, FarmResolvedBuildConfig, InferUnpluginVariant, RolldownBuildConfig, RolldownResolvedBuildConfig, RollupBuildConfig, RollupResolvedBuildConfig, RspackBuildConfig, RspackResolvedBuildConfig, TsdownBuildConfig, TsdownResolvedBuildConfig, TsupBuildConfig, TsupResolvedBuildConfig, UnbuildBuildConfig, UnbuildResolvedBuildConfig, UnpluginBuilderVariant, ViteBuildConfig, ViteResolvedBuildConfig, WebpackBuildConfig, WebpackResolvedBuildConfig };
@@ -1,8 +1,18 @@
1
1
  import { Configuration } from "webpack";
2
+ import { UserConfig } from "@farmfe/core";
3
+ import { Configuration as Configuration$1 } from "@rspack/core";
4
+ import { BuildOptions } from "@storm-software/tsup/types";
5
+ import { UnbuildOptions } from "@storm-software/unbuild/types";
6
+ import { BuildOptions as BuildOptions$1 } from "esbuild";
7
+ import { RolldownOptions } from "rolldown";
8
+ import { OutputOptions, RollupOptions } from "rollup";
9
+ import { UserConfig as UserConfig$1 } from "tsdown";
10
+ import { DepOptimizationOptions, UserConfig as UserConfig$2 } from "vite";
2
11
 
3
12
  //#region ../powerlines/src/types/build.d.ts
4
-
5
- type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
13
+ type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
14
+ type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
15
+ type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
6
16
  interface BuildConfig {
7
17
  /**
8
18
  * The platform to build the project for
@@ -143,7 +153,33 @@ interface BuildConfig {
143
153
  override?: Record<string, any>;
144
154
  }
145
155
  type BuildResolvedConfig = Omit<BuildConfig, "override">;
156
+ type ESBuildBuildConfig = Omit<BuildOptions$1, "entryPoints" | "sourceRoot" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel"> & BuildConfig;
157
+ type ESBuildResolvedBuildConfig = Omit<BuildOptions$1, "inject"> & BuildResolvedConfig;
158
+ type ViteBuildConfig = Omit<UserConfig$2, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig & {
159
+ /**
160
+ * Optimize deps config
161
+ */
162
+ optimizeDeps?: Omit<DepOptimizationOptions, "extensions">;
163
+ };
164
+ type ViteResolvedBuildConfig = UserConfig$2 & BuildResolvedConfig;
146
165
  type WebpackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
147
166
  type WebpackResolvedBuildConfig = Configuration & BuildResolvedConfig;
167
+ type RspackBuildConfig = Omit<Configuration$1, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
168
+ type RspackResolvedBuildConfig = Configuration$1 & BuildResolvedConfig;
169
+ type RollupBuildOutputConfig = Omit<OutputOptions, "dir" | "format">;
170
+ type RollupBuildConfig = Omit<RollupOptions, "entry" | "external" | "input" | "output" | "logLevel"> & {
171
+ output: RollupBuildOutputConfig | RollupBuildOutputConfig[];
172
+ } & BuildConfig;
173
+ type RollupResolvedBuildConfig = RollupOptions & BuildResolvedConfig;
174
+ type RolldownBuildConfig = Omit<RolldownOptions, "input" | "external" | "tsconfig" | "logLevel" | "output"> & BuildConfig;
175
+ type RolldownResolvedBuildConfig = RolldownOptions & BuildResolvedConfig;
176
+ type TsupBuildConfig = Partial<Omit<BuildOptions, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "clean" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
177
+ type TsupResolvedBuildConfig = BuildOptions & BuildResolvedConfig;
178
+ type TsdownBuildConfig = Partial<Omit<UserConfig$1, "name" | "outDir" | "clean" | "cwd" | "tsconfig" | "publicDir" | "copy" | "alias" | "format" | "platform" | "env" | "define" | "entry" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
179
+ type TsdownResolvedBuildConfig = UserConfig$1 & BuildResolvedConfig;
180
+ type UnbuildBuildConfig = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
181
+ type UnbuildResolvedBuildConfig = UnbuildOptions & BuildResolvedConfig;
182
+ type FarmBuildConfig = Partial<Omit<UserConfig, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
183
+ type FarmResolvedBuildConfig = UserConfig & BuildResolvedConfig;
148
184
  //#endregion
149
- export { BuildConfig, BuildResolvedConfig, UnpluginBuildVariant, WebpackBuildConfig, WebpackResolvedBuildConfig };
185
+ export { BuildConfig, BuildResolvedConfig, BuilderVariant, ESBuildBuildConfig, ESBuildResolvedBuildConfig, FarmBuildConfig, FarmResolvedBuildConfig, InferUnpluginVariant, RolldownBuildConfig, RolldownResolvedBuildConfig, RollupBuildConfig, RollupResolvedBuildConfig, RspackBuildConfig, RspackResolvedBuildConfig, TsdownBuildConfig, TsdownResolvedBuildConfig, TsupBuildConfig, TsupResolvedBuildConfig, UnbuildBuildConfig, UnbuildResolvedBuildConfig, UnpluginBuilderVariant, ViteBuildConfig, ViteResolvedBuildConfig, WebpackBuildConfig, WebpackResolvedBuildConfig };
@@ -1,5 +1,5 @@
1
1
  //#region ../powerlines/src/types/build.ts
2
- const UNPLUGIN_BUILD_VARIANTS = [
2
+ const UNPLUGIN_BUILDER_VARIANTS = [
3
3
  "rollup",
4
4
  "webpack",
5
5
  "rspack",
@@ -7,8 +7,15 @@ const UNPLUGIN_BUILD_VARIANTS = [
7
7
  "esbuild",
8
8
  "farm",
9
9
  "unloader",
10
- "rolldown"
10
+ "rolldown",
11
+ "bun"
12
+ ];
13
+ const BUILDER_VARIANTS = [
14
+ ...UNPLUGIN_BUILDER_VARIANTS,
15
+ "tsup",
16
+ "tsdown",
17
+ "unbuild"
11
18
  ];
12
19
 
13
20
  //#endregion
14
- export { UNPLUGIN_BUILD_VARIANTS };
21
+ export { BUILDER_VARIANTS, UNPLUGIN_BUILDER_VARIANTS };