@powerlines/core 0.48.39 → 0.48.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/context-helpers.cjs +7 -4
- package/dist/lib/context-helpers.d.cts +4 -4
- package/dist/lib/context-helpers.d.mts +4 -4
- package/dist/lib/context-helpers.mjs +7 -4
- package/dist/lib/context-helpers.mjs.map +1 -1
- package/dist/lib/hooks.cjs +3 -1
- package/dist/lib/hooks.d.cts.map +1 -1
- package/dist/lib/hooks.d.mts.map +1 -1
- package/dist/lib/hooks.mjs +3 -1
- package/dist/lib/hooks.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +4 -4
- package/dist/plugin-utils/context-helpers.d.cts +3 -3
- package/dist/plugin-utils/context-helpers.d.mts +3 -3
- package/dist/plugin-utils/context-helpers.mjs +4 -4
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/package.json +16 -16
|
@@ -19,10 +19,13 @@ async function resolvePluginConfig(context) {
|
|
|
19
19
|
meta: { category: "plugins" },
|
|
20
20
|
message: "No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended."
|
|
21
21
|
});
|
|
22
|
-
else
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
else {
|
|
23
|
+
const pluginNumberWidth = context.plugins.length >= 10 ? String(context.plugins.length).length : 1;
|
|
24
|
+
context.info({
|
|
25
|
+
meta: { category: "plugins" },
|
|
26
|
+
message: `Loaded ${context.plugins.length} ${(0, _stryke_string_format_title_case.titleCase)(context.config.framework?.name ?? "powerlines")} plugin${context.plugins.length > 1 ? "s" : ""}: \n${context.plugins.map((plugin, index) => `${String(index + 1).padStart(pluginNumberWidth, "0")}. ${require_plugin_utils_logging.colorText(plugin.name)}`).join("\n")}`
|
|
27
|
+
});
|
|
28
|
+
}
|
|
26
29
|
const pluginConfig = await context.callHook("config", {
|
|
27
30
|
environment: await context.getEnvironment(),
|
|
28
31
|
sequential: true,
|
|
@@ -2,13 +2,13 @@ import { ExecutionContext } from "../types/context.cjs";
|
|
|
2
2
|
import { InferOverridableConfig, ResolvedConfig } from "../types/config.cjs";
|
|
3
3
|
//#region src/lib/context-helpers.d.ts
|
|
4
4
|
declare function getConfigProps<TResolvedConfig extends ResolvedConfig>(config?: TResolvedConfig["userConfig"] | TResolvedConfig["inlineConfig"] | TResolvedConfig["pluginConfig"] | InferOverridableConfig<TResolvedConfig>): ({
|
|
5
|
-
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "
|
|
5
|
+
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends object ? Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends infer T ? T extends Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] ? T extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T : { [K in keyof T]?: (T[K] extends object ? T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_1 : { [K_2 in keyof T_1]?: (T_1[K_2] extends object ? T_1[K_2] extends infer T_2 ? T_2 extends T_1[K_2] ? T_2 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_2 : { [K_3 in keyof T_2]?: (T_2[K_3] extends object ? T_2[K_3] extends infer T_3 ? T_3 extends T_2[K_3] ? T_3 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_3 : { [K_4 in keyof T_3]?: (T_3[K_4] extends object ? T_3[K_4] extends infer T_4 ? T_4 extends T_3[K_4] ? T_4 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_4 : { [K_5 in keyof T_4]?: (T_4[K_5] extends object ? T_4[K_5] extends infer T_5 ? T_5 extends T_4[K_5] ? T_5 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_5 : { [K_6 in keyof T_5]?: (T_5[K_6] extends object ? T_5[K_6] extends infer T_6 ? T_6 extends T_5[K_6] ? T_6 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_6 : { [K_7 in keyof T_6]?: (T_6[K_7] extends object ? T_6[K_7] extends infer T_7 ? T_7 extends T_6[K_7] ? T_7 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_7 : { [K_8 in keyof T_7]?: (T_7[K_8] extends object ? T_7[K_8] extends infer T_8 ? T_8 extends T_7[K_8] ? T_8 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_8 : { [K_9 in keyof T_8]?: (T_8[K_9] extends object ? T_8[K_9] : T_8[K_9]) | undefined } : never : never : T_7[K_8]) | undefined } : never : never : T_6[K_7]) | undefined } : never : never : T_5[K_6]) | undefined } : never : never : T_4[K_5]) | undefined } : never : never : T_3[K_4]) | undefined } : never : never : T_2[K_3]) | undefined } : never : never : T_1[K_2]) | undefined } : never : never : T[K]) | undefined } : never : never : Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"]) | undefined;
|
|
6
6
|
} & TResolvedConfig["userConfig"]) | ({
|
|
7
|
-
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "
|
|
7
|
+
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends object ? Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends infer T_1 ? T_1 extends Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] ? T_1 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_1 : { [K_1 in keyof T_1]?: (T_1[K_1] extends object ? T_1[K_1] extends infer T_2 ? T_2 extends T_1[K_1] ? T_2 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_2 : { [K_3 in keyof T_2]?: (T_2[K_3] extends object ? T_2[K_3] extends infer T_3 ? T_3 extends T_2[K_3] ? T_3 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_3 : { [K_4 in keyof T_3]?: (T_3[K_4] extends object ? T_3[K_4] extends infer T_4 ? T_4 extends T_3[K_4] ? T_4 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_4 : { [K_5 in keyof T_4]?: (T_4[K_5] extends object ? T_4[K_5] extends infer T_5 ? T_5 extends T_4[K_5] ? T_5 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_5 : { [K_6 in keyof T_5]?: (T_5[K_6] extends object ? T_5[K_6] extends infer T_6 ? T_6 extends T_5[K_6] ? T_6 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_6 : { [K_7 in keyof T_6]?: (T_6[K_7] extends object ? T_6[K_7] extends infer T_7 ? T_7 extends T_6[K_7] ? T_7 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_7 : { [K_8 in keyof T_7]?: (T_7[K_8] extends object ? T_7[K_8] extends infer T_8 ? T_8 extends T_7[K_8] ? T_8 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_8 : { [K_9 in keyof T_8]?: (T_8[K_9] extends object ? T_8[K_9] extends infer T_9 ? T_9 extends T_8[K_9] ? T_9 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_9 : { [K_10 in keyof T_9]?: (T_9[K_10] extends object ? T_9[K_10] : T_9[K_10]) | undefined } : never : never : T_8[K_9]) | undefined } : never : never : T_7[K_8]) | undefined } : never : never : T_6[K_7]) | undefined } : never : never : T_5[K_6]) | undefined } : never : never : T_4[K_5]) | undefined } : never : never : T_3[K_4]) | undefined } : never : never : T_2[K_3]) | undefined } : never : never : T_1[K_1]) | undefined } : never : never : Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"]) | undefined;
|
|
8
8
|
} & TResolvedConfig["inlineConfig"]) | ({
|
|
9
|
-
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "
|
|
9
|
+
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends object ? Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends infer T_2 ? T_2 extends Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] ? T_2 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_2 : { [K_2 in keyof T_2]?: (T_2[K_2] extends object ? T_2[K_2] extends infer T_3 ? T_3 extends T_2[K_2] ? T_3 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_3 : { [K_4 in keyof T_3]?: (T_3[K_4] extends object ? T_3[K_4] extends infer T_4 ? T_4 extends T_3[K_4] ? T_4 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_4 : { [K_5 in keyof T_4]?: (T_4[K_5] extends object ? T_4[K_5] extends infer T_5 ? T_5 extends T_4[K_5] ? T_5 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_5 : { [K_6 in keyof T_5]?: (T_5[K_6] extends object ? T_5[K_6] extends infer T_6 ? T_6 extends T_5[K_6] ? T_6 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_6 : { [K_7 in keyof T_6]?: (T_6[K_7] extends object ? T_6[K_7] extends infer T_7 ? T_7 extends T_6[K_7] ? T_7 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_7 : { [K_8 in keyof T_7]?: (T_7[K_8] extends object ? T_7[K_8] extends infer T_8 ? T_8 extends T_7[K_8] ? T_8 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_8 : { [K_9 in keyof T_8]?: (T_8[K_9] extends object ? T_8[K_9] extends infer T_9 ? T_9 extends T_8[K_9] ? T_9 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_9 : { [K_10 in keyof T_9]?: (T_9[K_10] extends object ? T_9[K_10] extends infer T_10 ? T_10 extends T_9[K_10] ? T_10 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_10 : { [K_11 in keyof T_10]?: (T_10[K_11] extends object ? T_10[K_11] : T_10[K_11]) | undefined } : never : never : T_9[K_10]) | undefined } : never : never : T_8[K_9]) | undefined } : never : never : T_7[K_8]) | undefined } : never : never : T_6[K_7]) | undefined } : never : never : T_5[K_6]) | undefined } : never : never : T_4[K_5]) | undefined } : never : never : T_3[K_4]) | undefined } : never : never : T_2[K_2]) | undefined } : never : never : Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"]) | undefined;
|
|
10
10
|
} & TResolvedConfig["pluginConfig"]) | ({
|
|
11
|
-
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "
|
|
11
|
+
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends object ? Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends infer T_3 ? T_3 extends Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] ? T_3 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_3 : { [K_3 in keyof T_3]?: (T_3[K_3] extends object ? T_3[K_3] extends infer T_4 ? T_4 extends T_3[K_3] ? T_4 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_4 : { [K_5 in keyof T_4]?: (T_4[K_5] extends object ? T_4[K_5] extends infer T_5 ? T_5 extends T_4[K_5] ? T_5 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_5 : { [K_6 in keyof T_5]?: (T_5[K_6] extends object ? T_5[K_6] extends infer T_6 ? T_6 extends T_5[K_6] ? T_6 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_6 : { [K_7 in keyof T_6]?: (T_6[K_7] extends object ? T_6[K_7] extends infer T_7 ? T_7 extends T_6[K_7] ? T_7 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_7 : { [K_8 in keyof T_7]?: (T_7[K_8] extends object ? T_7[K_8] extends infer T_8 ? T_8 extends T_7[K_8] ? T_8 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_8 : { [K_9 in keyof T_8]?: (T_8[K_9] extends object ? T_8[K_9] extends infer T_9 ? T_9 extends T_8[K_9] ? T_9 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_9 : { [K_10 in keyof T_9]?: (T_9[K_10] extends object ? T_9[K_10] extends infer T_10 ? T_10 extends T_9[K_10] ? T_10 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_10 : { [K_11 in keyof T_10]?: (T_10[K_11] extends object ? T_10[K_11] extends infer T_11 ? T_11 extends T_10[K_11] ? T_11 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_11 : { [K_12 in keyof T_11]?: (T_11[K_12] extends object ? T_11[K_12] : T_11[K_12]) | undefined } : never : never : T_10[K_11]) | undefined } : never : never : T_9[K_10]) | undefined } : never : never : T_8[K_9]) | undefined } : never : never : T_7[K_8]) | undefined } : never : never : T_6[K_7]) | undefined } : never : never : T_5[K_6]) | undefined } : never : never : T_4[K_5]) | undefined } : never : never : T_3[K_3]) | undefined } : never : never : Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"]) | undefined;
|
|
12
12
|
} & InferOverridableConfig<TResolvedConfig>);
|
|
13
13
|
declare function resolvePluginConfig<TResolvedConfig extends ResolvedConfig = ResolvedConfig, TSystemContext = unknown, TContext extends ExecutionContext<TResolvedConfig, TSystemContext> = ExecutionContext<TResolvedConfig, TSystemContext>>(context: TContext): Promise<void>;
|
|
14
14
|
//#endregion
|
|
@@ -2,13 +2,13 @@ import { ExecutionContext } from "../types/context.mjs";
|
|
|
2
2
|
import { InferOverridableConfig, ResolvedConfig } from "../types/config.mjs";
|
|
3
3
|
//#region src/lib/context-helpers.d.ts
|
|
4
4
|
declare function getConfigProps<TResolvedConfig extends ResolvedConfig>(config?: TResolvedConfig["userConfig"] | TResolvedConfig["inlineConfig"] | TResolvedConfig["pluginConfig"] | InferOverridableConfig<TResolvedConfig>): ({
|
|
5
|
-
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "
|
|
5
|
+
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends object ? Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends infer T ? T extends Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] ? T extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T : { [K in keyof T]?: (T[K] extends object ? T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_1 : { [K_2 in keyof T_1]?: (T_1[K_2] extends object ? T_1[K_2] extends infer T_2 ? T_2 extends T_1[K_2] ? T_2 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_2 : { [K_3 in keyof T_2]?: (T_2[K_3] extends object ? T_2[K_3] extends infer T_3 ? T_3 extends T_2[K_3] ? T_3 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_3 : { [K_4 in keyof T_3]?: (T_3[K_4] extends object ? T_3[K_4] extends infer T_4 ? T_4 extends T_3[K_4] ? T_4 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_4 : { [K_5 in keyof T_4]?: (T_4[K_5] extends object ? T_4[K_5] extends infer T_5 ? T_5 extends T_4[K_5] ? T_5 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_5 : { [K_6 in keyof T_5]?: (T_5[K_6] extends object ? T_5[K_6] extends infer T_6 ? T_6 extends T_5[K_6] ? T_6 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_6 : { [K_7 in keyof T_6]?: (T_6[K_7] extends object ? T_6[K_7] extends infer T_7 ? T_7 extends T_6[K_7] ? T_7 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_7 : { [K_8 in keyof T_7]?: (T_7[K_8] extends object ? T_7[K_8] extends infer T_8 ? T_8 extends T_7[K_8] ? T_8 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_8 : { [K_9 in keyof T_8]?: (T_8[K_9] extends object ? T_8[K_9] : T_8[K_9]) | undefined } : never : never : T_7[K_8]) | undefined } : never : never : T_6[K_7]) | undefined } : never : never : T_5[K_6]) | undefined } : never : never : T_4[K_5]) | undefined } : never : never : T_3[K_4]) | undefined } : never : never : T_2[K_3]) | undefined } : never : never : T_1[K_2]) | undefined } : never : never : T[K]) | undefined } : never : never : Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"]) | undefined;
|
|
6
6
|
} & TResolvedConfig["userConfig"]) | ({
|
|
7
|
-
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "
|
|
7
|
+
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends object ? Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends infer T_1 ? T_1 extends Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] ? T_1 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_1 : { [K_1 in keyof T_1]?: (T_1[K_1] extends object ? T_1[K_1] extends infer T_2 ? T_2 extends T_1[K_1] ? T_2 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_2 : { [K_3 in keyof T_2]?: (T_2[K_3] extends object ? T_2[K_3] extends infer T_3 ? T_3 extends T_2[K_3] ? T_3 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_3 : { [K_4 in keyof T_3]?: (T_3[K_4] extends object ? T_3[K_4] extends infer T_4 ? T_4 extends T_3[K_4] ? T_4 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_4 : { [K_5 in keyof T_4]?: (T_4[K_5] extends object ? T_4[K_5] extends infer T_5 ? T_5 extends T_4[K_5] ? T_5 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_5 : { [K_6 in keyof T_5]?: (T_5[K_6] extends object ? T_5[K_6] extends infer T_6 ? T_6 extends T_5[K_6] ? T_6 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_6 : { [K_7 in keyof T_6]?: (T_6[K_7] extends object ? T_6[K_7] extends infer T_7 ? T_7 extends T_6[K_7] ? T_7 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_7 : { [K_8 in keyof T_7]?: (T_7[K_8] extends object ? T_7[K_8] extends infer T_8 ? T_8 extends T_7[K_8] ? T_8 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_8 : { [K_9 in keyof T_8]?: (T_8[K_9] extends object ? T_8[K_9] extends infer T_9 ? T_9 extends T_8[K_9] ? T_9 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_9 : { [K_10 in keyof T_9]?: (T_9[K_10] extends object ? T_9[K_10] : T_9[K_10]) | undefined } : never : never : T_8[K_9]) | undefined } : never : never : T_7[K_8]) | undefined } : never : never : T_6[K_7]) | undefined } : never : never : T_5[K_6]) | undefined } : never : never : T_4[K_5]) | undefined } : never : never : T_3[K_4]) | undefined } : never : never : T_2[K_3]) | undefined } : never : never : T_1[K_1]) | undefined } : never : never : Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"]) | undefined;
|
|
8
8
|
} & TResolvedConfig["inlineConfig"]) | ({
|
|
9
|
-
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "
|
|
9
|
+
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends object ? Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends infer T_2 ? T_2 extends Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] ? T_2 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_2 : { [K_2 in keyof T_2]?: (T_2[K_2] extends object ? T_2[K_2] extends infer T_3 ? T_3 extends T_2[K_2] ? T_3 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_3 : { [K_4 in keyof T_3]?: (T_3[K_4] extends object ? T_3[K_4] extends infer T_4 ? T_4 extends T_3[K_4] ? T_4 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_4 : { [K_5 in keyof T_4]?: (T_4[K_5] extends object ? T_4[K_5] extends infer T_5 ? T_5 extends T_4[K_5] ? T_5 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_5 : { [K_6 in keyof T_5]?: (T_5[K_6] extends object ? T_5[K_6] extends infer T_6 ? T_6 extends T_5[K_6] ? T_6 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_6 : { [K_7 in keyof T_6]?: (T_6[K_7] extends object ? T_6[K_7] extends infer T_7 ? T_7 extends T_6[K_7] ? T_7 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_7 : { [K_8 in keyof T_7]?: (T_7[K_8] extends object ? T_7[K_8] extends infer T_8 ? T_8 extends T_7[K_8] ? T_8 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_8 : { [K_9 in keyof T_8]?: (T_8[K_9] extends object ? T_8[K_9] extends infer T_9 ? T_9 extends T_8[K_9] ? T_9 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_9 : { [K_10 in keyof T_9]?: (T_9[K_10] extends object ? T_9[K_10] extends infer T_10 ? T_10 extends T_9[K_10] ? T_10 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_10 : { [K_11 in keyof T_10]?: (T_10[K_11] extends object ? T_10[K_11] : T_10[K_11]) | undefined } : never : never : T_9[K_10]) | undefined } : never : never : T_8[K_9]) | undefined } : never : never : T_7[K_8]) | undefined } : never : never : T_6[K_7]) | undefined } : never : never : T_5[K_6]) | undefined } : never : never : T_4[K_5]) | undefined } : never : never : T_3[K_4]) | undefined } : never : never : T_2[K_2]) | undefined } : never : never : Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"]) | undefined;
|
|
10
10
|
} & TResolvedConfig["pluginConfig"]) | ({
|
|
11
|
-
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "
|
|
11
|
+
input: import("@stryke/types/configuration").FileReference | import("@stryke/types/configuration").FileReferenceInput[] | Record<string, import("@stryke/types/configuration").FileReferenceInput | import("@stryke/types/configuration").FileReferenceInput[]> | TResolvedConfig["input"] | (Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends object ? Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] extends infer T_3 ? T_3 extends Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"] ? T_3 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_3 : { [K_3 in keyof T_3]?: (T_3[K_3] extends object ? T_3[K_3] extends infer T_4 ? T_4 extends T_3[K_3] ? T_4 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_4 : { [K_5 in keyof T_4]?: (T_4[K_5] extends object ? T_4[K_5] extends infer T_5 ? T_5 extends T_4[K_5] ? T_5 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_5 : { [K_6 in keyof T_5]?: (T_5[K_6] extends object ? T_5[K_6] extends infer T_6 ? T_6 extends T_5[K_6] ? T_6 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_6 : { [K_7 in keyof T_6]?: (T_6[K_7] extends object ? T_6[K_7] extends infer T_7 ? T_7 extends T_6[K_7] ? T_7 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_7 : { [K_8 in keyof T_7]?: (T_7[K_8] extends object ? T_7[K_8] extends infer T_8 ? T_8 extends T_7[K_8] ? T_8 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_8 : { [K_9 in keyof T_8]?: (T_8[K_9] extends object ? T_8[K_9] extends infer T_9 ? T_9 extends T_8[K_9] ? T_9 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_9 : { [K_10 in keyof T_9]?: (T_9[K_10] extends object ? T_9[K_10] extends infer T_10 ? T_10 extends T_9[K_10] ? T_10 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_10 : { [K_11 in keyof T_10]?: (T_10[K_11] extends object ? T_10[K_11] extends infer T_11 ? T_11 extends T_10[K_11] ? T_11 extends import("@stryke/types/base").BrowserNativeObject | import("@stryke/types/base").NestedValue<object> ? T_11 : { [K_12 in keyof T_11]?: (T_11[K_12] extends object ? T_11[K_12] : T_11[K_12]) | undefined } : never : never : T_10[K_11]) | undefined } : never : never : T_9[K_10]) | undefined } : never : never : T_8[K_9]) | undefined } : never : never : T_7[K_8]) | undefined } : never : never : T_6[K_7]) | undefined } : never : never : T_5[K_6]) | undefined } : never : never : T_4[K_5]) | undefined } : never : never : T_3[K_3]) | undefined } : never : never : Omit<TResolvedConfig, "cwd" | "configFile" | "command" | "pluginConfig" | "userConfig" | "inlineConfig">["input"]) | undefined;
|
|
12
12
|
} & InferOverridableConfig<TResolvedConfig>);
|
|
13
13
|
declare function resolvePluginConfig<TResolvedConfig extends ResolvedConfig = ResolvedConfig, TSystemContext = unknown, TContext extends ExecutionContext<TResolvedConfig, TSystemContext> = ExecutionContext<TResolvedConfig, TSystemContext>>(context: TContext): Promise<void>;
|
|
14
14
|
//#endregion
|
|
@@ -18,10 +18,13 @@ async function resolvePluginConfig(context) {
|
|
|
18
18
|
meta: { category: "plugins" },
|
|
19
19
|
message: "No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended."
|
|
20
20
|
});
|
|
21
|
-
else
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
else {
|
|
22
|
+
const pluginNumberWidth = context.plugins.length >= 10 ? String(context.plugins.length).length : 1;
|
|
23
|
+
context.info({
|
|
24
|
+
meta: { category: "plugins" },
|
|
25
|
+
message: `Loaded ${context.plugins.length} ${titleCase(context.config.framework?.name ?? "powerlines")} plugin${context.plugins.length > 1 ? "s" : ""}: \n${context.plugins.map((plugin, index) => `${String(index + 1).padStart(pluginNumberWidth, "0")}. ${colorText(plugin.name)}`).join("\n")}`
|
|
26
|
+
});
|
|
27
|
+
}
|
|
25
28
|
const pluginConfig = await context.callHook("config", {
|
|
26
29
|
environment: await context.getEnvironment(),
|
|
27
30
|
sequential: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-helpers.mjs","names":[],"sources":["../../src/lib/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { colorText } from \"../plugin-utils/logging\";\nimport type {\n ExecutionContext,\n InferOverridableConfig,\n PluginConfig,\n PluginContext,\n ResolvedConfig\n} from \"../types\";\nimport { mergeConfigs } from \"./hooks\";\n\nexport function getConfigProps<TResolvedConfig extends ResolvedConfig>(\n config:\n | TResolvedConfig[\"userConfig\"]\n | TResolvedConfig[\"inlineConfig\"]\n | TResolvedConfig[\"pluginConfig\"]\n | InferOverridableConfig<TResolvedConfig> = {}\n) {\n return {\n input: isSetString(config.input) ? [config.input] : config.input,\n ...config\n };\n}\n\nexport async function resolvePluginConfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown,\n TContext extends ExecutionContext<TResolvedConfig, TSystemContext> =\n ExecutionContext<TResolvedConfig, TSystemContext>\n>(context: TContext) {\n const timer = context.timer(\n `${titleCase(context.config.command)} Execution - Initialization`\n );\n\n for (const plugin of (\n context.config.plugins as PluginConfig<\n PluginContext<TResolvedConfig, TSystemContext>\n >[]\n ).flatMap(p => toArray(p)) ?? []) {\n await context.unstable_addPlugin(plugin);\n }\n\n if (context.plugins.length === 0) {\n context.warn({\n meta: {\n category: \"plugins\"\n },\n message:\n \"No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.\"\n });\n } else {\n context.info({\n meta: {\n category: \"plugins\"\n },\n message: `Loaded ${context.plugins.length} ${titleCase(\n context.config.framework?.name ?? \"powerlines\"\n )} plugin${context.plugins.length > 1 ? \"s\" : \"\"}: \\n${context.plugins\n .map((plugin, index)
|
|
1
|
+
{"version":3,"file":"context-helpers.mjs","names":[],"sources":["../../src/lib/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { colorText } from \"../plugin-utils/logging\";\nimport type {\n ExecutionContext,\n InferOverridableConfig,\n PluginConfig,\n PluginContext,\n ResolvedConfig\n} from \"../types\";\nimport { mergeConfigs } from \"./hooks\";\n\nexport function getConfigProps<TResolvedConfig extends ResolvedConfig>(\n config:\n | TResolvedConfig[\"userConfig\"]\n | TResolvedConfig[\"inlineConfig\"]\n | TResolvedConfig[\"pluginConfig\"]\n | InferOverridableConfig<TResolvedConfig> = {}\n) {\n return {\n input: isSetString(config.input) ? [config.input] : config.input,\n ...config\n };\n}\n\nexport async function resolvePluginConfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown,\n TContext extends ExecutionContext<TResolvedConfig, TSystemContext> =\n ExecutionContext<TResolvedConfig, TSystemContext>\n>(context: TContext) {\n const timer = context.timer(\n `${titleCase(context.config.command)} Execution - Initialization`\n );\n\n for (const plugin of (\n context.config.plugins as PluginConfig<\n PluginContext<TResolvedConfig, TSystemContext>\n >[]\n ).flatMap(p => toArray(p)) ?? []) {\n await context.unstable_addPlugin(plugin);\n }\n\n if (context.plugins.length === 0) {\n context.warn({\n meta: {\n category: \"plugins\"\n },\n message:\n \"No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.\"\n });\n } else {\n const pluginNumberWidth =\n context.plugins.length >= 10 ? String(context.plugins.length).length : 1;\n\n context.info({\n meta: {\n category: \"plugins\"\n },\n message: `Loaded ${context.plugins.length} ${titleCase(\n context.config.framework?.name ?? \"powerlines\"\n )} plugin${context.plugins.length > 1 ? \"s\" : \"\"}: \\n${context.plugins\n .map(\n (plugin, index) =>\n `${String(index + 1).padStart(\n pluginNumberWidth,\n \"0\"\n )}. ${colorText(plugin.name)}`\n )\n .join(\"\\n\")}`\n });\n }\n\n const pluginConfig = await context.callHook(\"config\", {\n environment: await context.getEnvironment(),\n sequential: true,\n result: \"merge\",\n merge: mergeConfigs\n });\n if (pluginConfig) {\n await context.setPluginConfig(\n pluginConfig as TContext[\"config\"][\"pluginConfig\"]\n );\n } else {\n context.debug({\n meta: {\n category: \"config\"\n },\n message: \"No plugin configuration was returned from the config hook.\"\n });\n }\n\n timer();\n}\n"],"mappings":";;;;;;;AA+BA,SAAgB,eACd,SAI8C,CAAC,GAC/C;CACA,OAAO;EACL,OAAO,YAAY,OAAO,KAAK,IAAI,CAAC,OAAO,KAAK,IAAI,OAAO;EAC3D,GAAG;CACL;AACF;AAEA,eAAsB,oBAKpB,SAAmB;CACnB,MAAM,QAAQ,QAAQ,MACpB,GAAG,UAAU,QAAQ,OAAO,OAAO,EAAE,4BACvC;CAEA,KAAK,MAAM,UACT,QAAQ,OAAO,QAGf,SAAQ,MAAK,QAAQ,CAAC,CAAC,KAAK,CAAC,GAC7B,MAAM,QAAQ,mBAAmB,MAAM;CAGzC,IAAI,QAAQ,QAAQ,WAAW,GAC7B,QAAQ,KAAK;EACX,MAAM,EACJ,UAAU,UACZ;EACA,SACE;CACJ,CAAC;MACI;EACL,MAAM,oBACJ,QAAQ,QAAQ,UAAU,KAAK,OAAO,QAAQ,QAAQ,MAAM,EAAE,SAAS;EAEzE,QAAQ,KAAK;GACX,MAAM,EACJ,UAAU,UACZ;GACA,SAAS,UAAU,QAAQ,QAAQ,OAAO,GAAG,UAC3C,QAAQ,OAAO,WAAW,QAAQ,YACpC,EAAE,SAAS,QAAQ,QAAQ,SAAS,IAAI,MAAM,GAAG,MAAM,QAAQ,QAC5D,KACE,QAAQ,UACP,GAAG,OAAO,QAAQ,CAAC,EAAE,SACnB,mBACA,GACF,EAAE,IAAI,UAAU,OAAO,IAAI,GAC/B,EACC,KAAK,IAAI;EACd,CAAC;CACH;CAEA,MAAM,eAAe,MAAM,QAAQ,SAAS,UAAU;EACpD,aAAa,MAAM,QAAQ,eAAe;EAC1C,YAAY;EACZ,QAAQ;EACR,OAAO;CACT,CAAC;CACD,IAAI,cACF,MAAM,QAAQ,gBACZ,YACF;MAEA,QAAQ,MAAM;EACZ,MAAM,EACJ,UAAU,SACZ;EACA,SAAS;CACX,CAAC;CAGH,MAAM;AACR"}
|
package/dist/lib/hooks.cjs
CHANGED
|
@@ -53,7 +53,9 @@ function mergeConfigs(currentResult, previousResults) {
|
|
|
53
53
|
async function _callHook(context, key, options, ...args) {
|
|
54
54
|
const hooks = context.selectHooks(key, options);
|
|
55
55
|
if (hooks.length > 0) {
|
|
56
|
-
context.extendLogger({ category: "hooks" })
|
|
56
|
+
const logger = context.extendLogger({ category: "hooks" });
|
|
57
|
+
const pluginNumberWidth = hooks.length >= 10 ? String(hooks.length).length : 1;
|
|
58
|
+
logger.debug(`🧩 Calling ${hooks.length} ${chalk.default.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => `${String(index + 1).padStart(pluginNumberWidth, "0")}. ${require_plugin_utils_logging.colorText(hook.plugin.name)}`).join("\n")}`);
|
|
57
59
|
const invokeHook = async (hook, hookArgs) => {
|
|
58
60
|
return Reflect.apply(hook.handler, hook.context, hookArgs);
|
|
59
61
|
};
|
package/dist/lib/hooks.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.cts","names":[],"sources":["../../src/lib/hooks.ts"],"mappings":";;;;;;;;;;;;iBA0DgB,YAAA,WACJ,MAAA,0CACV,aAAA,EAAe,CAAA,EAAG,eAAA,EAAiB,CAAA,KAAM,CAAA;;;;;;;;iBA8B3B,YAAA,IAAgB,aAAA,EAAe,CAAA,EAAG,eAAA,EAAiB,CAAA,GAAI,CAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"hooks.d.cts","names":[],"sources":["../../src/lib/hooks.ts"],"mappings":";;;;;;;;;;;;iBA0DgB,YAAA,WACJ,MAAA,0CACV,aAAA,EAAe,CAAA,EAAG,eAAA,EAAiB,CAAA,KAAM,CAAA;;;;;;;;iBA8B3B,YAAA,IAAgB,aAAA,EAAe,CAAA,EAAG,eAAA,EAAiB,CAAA,GAAI,CAAA;AAAA,iBAiLvD,YAAA,yBACU,cAAA,GAAiB,cAAA,4BAGzC,OAAA,EAAS,aAAA,CAAc,eAAA,EAAiB,cAAA,GACxC,KAAA,EAAO,MAAA,SAEL,SAAA,CAAU,aAAA,CAAc,eAAA,EAAiB,cAAA,KAE3C,MAAA,EAAQ,MAAA,CAAO,aAAA,CAAc,eAAA,EAAiB,cAAA,IAC9C,GAAA,UACA,SAAA,YACC,MAAA,SAAe,SAAA,CAAU,aAAA,CAAc,eAAA,EAAiB,cAAA;AAAA,iBAwIrC,QAAA,8CAEI,cAAA,4BAGxB,OAAA,EAAS,gBAAA,CAAiB,eAAA,EAAiB,cAAA,GAC3C,GAAA,EAAK,IAAA,EACL,OAAA,EAAS,eAAA;EACP,WAAA,YAAuB,kBAAA,CAAmB,eAAA,EAAiB,cAAA;AAAA,MAE1D,IAAA,EAAM,mBAAA,CACP,aAAA,CAAc,eAAA,EAAiB,cAAA,GAC/B,IAAA,IACD,OAAA,CAAA,UAAA,CAAA,iBAAA,CAAA,aAAA,CAAA,eAAA,EAAA,cAAA,GAAA,IAAA"}
|
package/dist/lib/hooks.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.mts","names":[],"sources":["../../src/lib/hooks.ts"],"mappings":";;;;;;;;;;;;iBA0DgB,YAAA,WACJ,MAAA,0CACV,aAAA,EAAe,CAAA,EAAG,eAAA,EAAiB,CAAA,KAAM,CAAA;;;;;;;;iBA8B3B,YAAA,IAAgB,aAAA,EAAe,CAAA,EAAG,eAAA,EAAiB,CAAA,GAAI,CAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"hooks.d.mts","names":[],"sources":["../../src/lib/hooks.ts"],"mappings":";;;;;;;;;;;;iBA0DgB,YAAA,WACJ,MAAA,0CACV,aAAA,EAAe,CAAA,EAAG,eAAA,EAAiB,CAAA,KAAM,CAAA;;;;;;;;iBA8B3B,YAAA,IAAgB,aAAA,EAAe,CAAA,EAAG,eAAA,EAAiB,CAAA,GAAI,CAAA;AAAA,iBAiLvD,YAAA,yBACU,cAAA,GAAiB,cAAA,4BAGzC,OAAA,EAAS,aAAA,CAAc,eAAA,EAAiB,cAAA,GACxC,KAAA,EAAO,MAAA,SAEL,SAAA,CAAU,aAAA,CAAc,eAAA,EAAiB,cAAA,KAE3C,MAAA,EAAQ,MAAA,CAAO,aAAA,CAAc,eAAA,EAAiB,cAAA,IAC9C,GAAA,UACA,SAAA,YACC,MAAA,SAAe,SAAA,CAAU,aAAA,CAAc,eAAA,EAAiB,cAAA;AAAA,iBAwIrC,QAAA,8CAEI,cAAA,4BAGxB,OAAA,EAAS,gBAAA,CAAiB,eAAA,EAAiB,cAAA,GAC3C,GAAA,EAAK,IAAA,EACL,OAAA,EAAS,eAAA;EACP,WAAA,YAAuB,kBAAA,CAAmB,eAAA,EAAiB,cAAA;AAAA,MAE1D,IAAA,EAAM,mBAAA,CACP,aAAA,CAAc,eAAA,EAAiB,cAAA,GAC/B,IAAA,IACD,OAAA,CAAA,UAAA,CAAA,iBAAA,CAAA,aAAA,CAAA,eAAA,EAAA,cAAA,GAAA,IAAA"}
|
package/dist/lib/hooks.mjs
CHANGED
|
@@ -50,7 +50,9 @@ function mergeConfigs(currentResult, previousResults) {
|
|
|
50
50
|
async function _callHook(context, key, options, ...args) {
|
|
51
51
|
const hooks = context.selectHooks(key, options);
|
|
52
52
|
if (hooks.length > 0) {
|
|
53
|
-
context.extendLogger({ category: "hooks" })
|
|
53
|
+
const logger = context.extendLogger({ category: "hooks" });
|
|
54
|
+
const pluginNumberWidth = hooks.length >= 10 ? String(hooks.length).length : 1;
|
|
55
|
+
logger.debug(`🧩 Calling ${hooks.length} ${chalk.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => `${String(index + 1).padStart(pluginNumberWidth, "0")}. ${colorText(hook.plugin.name)}`).join("\n")}`);
|
|
54
56
|
const invokeHook = async (hook, hookArgs) => {
|
|
55
57
|
return Reflect.apply(hook.handler, hook.context, hookArgs);
|
|
56
58
|
};
|
package/dist/lib/hooks.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.mjs","names":["defu"],"sources":["../../src/lib/hooks.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getField } from \"@stryke/helpers/get-field\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { ArrayValues } from \"@stryke/types/array\";\nimport { AnyFunction } from \"@stryke/types/base\";\nimport chalk from \"chalk\";\nimport { defu } from \"defu\";\nimport {\n addPluginHook,\n colorText,\n isPluginHook,\n isPluginHookField,\n mergeConfig\n} from \"../plugin-utils\";\nimport type {\n CallHookOptions,\n EnvironmentContext,\n ExecutionContext,\n HookListOrders,\n HooksList,\n HooksListItem,\n InferHookParameters,\n InferHookReturnType,\n Plugin,\n PluginContext,\n PluginHookFields,\n ResolvedConfig\n} from \"../types\";\n\n/**\n * Merges the current hook result with the previous results based on their types.\n *\n * @param currentResult - The current hook result to merge with the previous results.\n * @param previousResults - The previous hook results to merge with the current result.\n * @returns The merged result.\n */\nexport function mergeResults<\n T extends Record<string | number | symbol, any> | string\n>(currentResult: T, previousResults: T[]): T[] {\n if (!previousResults || previousResults.length === 0) {\n return [currentResult];\n }\n\n if (isSetString(currentResult)) {\n previousResults = [\n `${isSetString(previousResults[0]) ? previousResults[0] || \"\" : \"\"}\\n${\n isSetString(previousResults[0])\n ? currentResult.replace(previousResults[0], \"\")\n : currentResult\n }`.trim() as T\n ];\n } else if (isObject(currentResult)) {\n previousResults =\n previousResults.length > 0\n ? [defu(currentResult, previousResults[0])]\n : [currentResult];\n }\n\n return previousResults;\n}\n\n/**\n * Merges multiple hook results together, with special handling for string values and object values.\n *\n * @param currentResult - The current hook result to merge with the previous results.\n * @param previousResults - The previous hook results to merge with the current result.\n * @returns The merged result.\n */\nexport function mergeConfigs<T>(currentResult: T, previousResults: T): T {\n if (isString(currentResult)) {\n previousResults =\n `${isString(previousResults) ? previousResults || \"\" : \"\"}\\n${\n currentResult || \"\"\n }`.trim() as T;\n } else if (isObject(currentResult)) {\n previousResults = mergeConfig(currentResult, previousResults ?? {}) as T;\n }\n\n return previousResults;\n}\n\n/**\n * Calls a hook with the given context, options, and arguments.\n *\n * @param context - The context to use when calling the hook.\n * @param key - The hook to call.\n * @param options - Options for calling the hook.\n * @param args - Arguments to pass to the hook.\n * @returns The return value of the hook.\n */\nasync function _callHook<\n TResolvedConfig extends ResolvedConfig,\n TSystemContext,\n TKey extends string\n>(\n context: EnvironmentContext<TResolvedConfig, TSystemContext>,\n key: TKey,\n options: CallHookOptions,\n ...args: InferHookParameters<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n): Promise<\n | InferHookReturnType<PluginContext<TResolvedConfig, TSystemContext>, TKey>\n | undefined\n> {\n const hooks = context.selectHooks(key, options);\n if (hooks.length > 0) {\n const logger = context.extendLogger({ category: \"hooks\" });\n\n logger.debug(\n `🧩 Calling ${hooks.length} ${chalk.bold.cyanBright(\n `${key}${options?.order ? ` (${options.order})` : \"\"}`\n )} plugin hook${hooks.length > 1 ? \"s\" : \"\"}:\\n${hooks\n .map((hook, index) => ` ${index + 1}. ${colorText(hook.plugin.name)}`)\n .join(\"\\n\")}`\n );\n\n const invokeHook = async (\n hook: ArrayValues<typeof hooks>,\n hookArgs: InferHookParameters<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n ) => {\n return Reflect.apply(hook.handler as AnyFunction, hook.context, hookArgs);\n };\n\n let results = [] as InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >[];\n if (options?.sequential === false) {\n results = (await Promise.all(\n hooks.map(async hook => {\n if (!isFunction(hook.handler)) {\n throw new Error(\n `Plugin hook handler for hook \"${key}\" is not a function.`\n );\n }\n\n return invokeHook(hook, [...args]);\n })\n )) as InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >[];\n } else {\n for (const hook of hooks) {\n if (!isFunction(hook.handler)) {\n throw new Error(\n `Plugin hook handler for hook \"${key}\" is not a function.`\n );\n }\n\n if (options?.result === \"first\" || options?.asNextParam === false) {\n results.push(\n (await Promise.resolve(\n invokeHook(hook, [...args])\n )) as InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n );\n if (\n options?.result === \"first\" &&\n isSet(results[results.length - 1])\n ) {\n break;\n }\n } else {\n const sequenceArgs = [...args];\n if (results.length > 0 && sequenceArgs.length > 0) {\n sequenceArgs[0] = isFunction(options.asNextParam)\n ? await Promise.resolve(options.asNextParam(results[0]))\n : results[0];\n }\n\n const result = await Promise.resolve(\n invokeHook(hook, [...sequenceArgs] as InferHookParameters<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >)\n );\n if (result) {\n if (options.result === \"last\") {\n results = [result];\n } else if (options.result === \"merge\" && options.merge) {\n results = [\n results.length > 0 && results[0]\n ? await Promise.resolve(options.merge(result, results[0]))\n : result\n ];\n } else {\n results = mergeResults(result, results);\n }\n }\n }\n }\n }\n\n const definedResults = results.filter(\n (\n result\n ): result is NonNullable<\n InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n > => isSet(result)\n );\n\n if (definedResults.length > 0) {\n let mergedResult = undefined as\n | InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n | undefined;\n\n for (const result of definedResults) {\n mergedResult = defu(\n result as Record<string, unknown>,\n mergedResult ?? {}\n ) as InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >;\n }\n\n return mergedResult;\n }\n }\n\n return undefined;\n}\n\nexport function extractHooks<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>(\n context: PluginContext<TResolvedConfig, TSystemContext>,\n hooks: Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n >,\n plugin: Plugin<PluginContext<TResolvedConfig, TSystemContext>>,\n key: string,\n parentKey?: string\n): Record<string, HooksList<PluginContext<TResolvedConfig, TSystemContext>>> {\n const combinedKey = parentKey ? `${parentKey}:${key}` : key;\n const pluginField = getField(plugin, combinedKey.replace(/:/g, \".\"));\n if (\n isPluginHookField<PluginContext<TResolvedConfig, TSystemContext>>(\n combinedKey\n ) &&\n isPluginHook(pluginField)\n ) {\n const pluginHook = pluginField;\n if (!isPluginHook(pluginHook)) {\n return hooks;\n }\n\n hooks[combinedKey] ??= {\n preEnforced: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n preOrdered: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n normal: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n postEnforced: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n postOrdered: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[]\n };\n\n if (plugin.enforce) {\n const hookListOrder = `${plugin.enforce}Enforced` as HookListOrders;\n hooks[combinedKey][hookListOrder] ??= [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[];\n\n hooks[combinedKey][hookListOrder] = addPluginHook<\n PluginContext<TResolvedConfig, TSystemContext>,\n PluginHookFields<PluginContext<TResolvedConfig, TSystemContext>>\n >(context, plugin, pluginHook, hooks[combinedKey][hookListOrder]);\n\n return hooks;\n }\n\n if (isFunction(pluginHook) || !pluginHook.order) {\n hooks[combinedKey].normal ??= [];\n\n hooks[combinedKey].normal = addPluginHook<\n PluginContext<TResolvedConfig, TSystemContext>,\n PluginHookFields<PluginContext<TResolvedConfig, TSystemContext>>\n >(context, plugin, pluginHook, hooks[combinedKey].normal);\n\n return hooks;\n }\n\n const hookListOrder = `${pluginHook.order}Ordered` as HookListOrders;\n hooks[combinedKey][hookListOrder] ??= [];\n\n hooks[combinedKey][hookListOrder] = addPluginHook<\n PluginContext<TResolvedConfig, TSystemContext>,\n PluginHookFields<PluginContext<TResolvedConfig, TSystemContext>>\n >(context, plugin, pluginHook, hooks[combinedKey][hookListOrder]);\n\n return hooks;\n } else if (isSetObject(pluginField)) {\n return Object.keys(pluginField)\n .map(pluginKey =>\n extractHooks(context, hooks, plugin, pluginKey, combinedKey)\n )\n .reduce((ret, current) => {\n Object.keys(current).forEach(key => {\n ret[key] ??= {\n preEnforced: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n preOrdered: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n normal: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n postEnforced: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n postOrdered: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[]\n };\n\n [\n \"preEnforced\",\n \"preOrdered\",\n \"normal\",\n \"postEnforced\",\n \"postOrdered\"\n ].forEach(order => {\n if (\n current[key]?.[\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ]\n ) {\n ret[key]![\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ] ??= [];\n ret[key]![\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ] = ret[key]![\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ]!.concat(\n current[key][\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ]!\n );\n }\n });\n });\n\n return ret;\n }, hooks);\n }\n\n return hooks;\n}\n\nexport async function callHook<\n TKey extends string,\n TResolvedConfig extends ResolvedConfig,\n TSystemContext = unknown\n>(\n context: ExecutionContext<TResolvedConfig, TSystemContext>,\n key: TKey,\n options: CallHookOptions & {\n environment?: string | EnvironmentContext<TResolvedConfig, TSystemContext>;\n },\n ...args: InferHookParameters<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n) {\n return _callHook<TResolvedConfig, TSystemContext, TKey>(\n isSetObject(options?.environment)\n ? options.environment\n : await context.getEnvironment(options?.environment),\n key,\n { sequential: true, ...options },\n ...args\n );\n}\n"],"mappings":";;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AGb,QAAQ,CAAC;IAGT,cAAc,CAAC;IAGf,aAAa,CAAC;GAGhB;GAEA;IACE;IACA;IACA;IACA;IACA;GACF,EAAE,SAAQ,UAAS;IACjB,IACE,QAAQ,OACN,QAIF;KACA,IAAI,KACF,WAGI,CAAC;KACP,IAAI,KACF,SAGE,IAAI,KACN,OAGC,OACD,QAAQ,KACN,MAIJ;IACF;GACF,CAAC;EACH,CAAC;EAED,OAAO;CACT,GAAG,KAAK;CAGZ,OAAO;AACT;AAEA,eAAsB,SAKpB,SACA,KACA,SAGA,GAAG,MAIH;CACA,OAAO,UACL,YAAY,SAAS,WAAW,IAC5B,QAAQ,cACR,MAAM,QAAQ,eAAe,SAAS,WAAW,GACrD,KACA;EAAE,YAAY;EAAM,GAAG;CAAQ,GAC/B,GAAG,IACL;AACF"}
|
|
1
|
+
{"version":3,"file":"hooks.mjs","names":["defu"],"sources":["../../src/lib/hooks.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getField } from \"@stryke/helpers/get-field\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { ArrayValues } from \"@stryke/types/array\";\nimport { AnyFunction } from \"@stryke/types/base\";\nimport chalk from \"chalk\";\nimport { defu } from \"defu\";\nimport {\n addPluginHook,\n colorText,\n isPluginHook,\n isPluginHookField,\n mergeConfig\n} from \"../plugin-utils\";\nimport type {\n CallHookOptions,\n EnvironmentContext,\n ExecutionContext,\n HookListOrders,\n HooksList,\n HooksListItem,\n InferHookParameters,\n InferHookReturnType,\n Plugin,\n PluginContext,\n PluginHookFields,\n ResolvedConfig\n} from \"../types\";\n\n/**\n * Merges the current hook result with the previous results based on their types.\n *\n * @param currentResult - The current hook result to merge with the previous results.\n * @param previousResults - The previous hook results to merge with the current result.\n * @returns The merged result.\n */\nexport function mergeResults<\n T extends Record<string | number | symbol, any> | string\n>(currentResult: T, previousResults: T[]): T[] {\n if (!previousResults || previousResults.length === 0) {\n return [currentResult];\n }\n\n if (isSetString(currentResult)) {\n previousResults = [\n `${isSetString(previousResults[0]) ? previousResults[0] || \"\" : \"\"}\\n${\n isSetString(previousResults[0])\n ? currentResult.replace(previousResults[0], \"\")\n : currentResult\n }`.trim() as T\n ];\n } else if (isObject(currentResult)) {\n previousResults =\n previousResults.length > 0\n ? [defu(currentResult, previousResults[0])]\n : [currentResult];\n }\n\n return previousResults;\n}\n\n/**\n * Merges multiple hook results together, with special handling for string values and object values.\n *\n * @param currentResult - The current hook result to merge with the previous results.\n * @param previousResults - The previous hook results to merge with the current result.\n * @returns The merged result.\n */\nexport function mergeConfigs<T>(currentResult: T, previousResults: T): T {\n if (isString(currentResult)) {\n previousResults =\n `${isString(previousResults) ? previousResults || \"\" : \"\"}\\n${\n currentResult || \"\"\n }`.trim() as T;\n } else if (isObject(currentResult)) {\n previousResults = mergeConfig(currentResult, previousResults ?? {}) as T;\n }\n\n return previousResults;\n}\n\n/**\n * Calls a hook with the given context, options, and arguments.\n *\n * @param context - The context to use when calling the hook.\n * @param key - The hook to call.\n * @param options - Options for calling the hook.\n * @param args - Arguments to pass to the hook.\n * @returns The return value of the hook.\n */\nasync function _callHook<\n TResolvedConfig extends ResolvedConfig,\n TSystemContext,\n TKey extends string\n>(\n context: EnvironmentContext<TResolvedConfig, TSystemContext>,\n key: TKey,\n options: CallHookOptions,\n ...args: InferHookParameters<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n): Promise<\n | InferHookReturnType<PluginContext<TResolvedConfig, TSystemContext>, TKey>\n | undefined\n> {\n const hooks = context.selectHooks(key, options);\n if (hooks.length > 0) {\n const logger = context.extendLogger({ category: \"hooks\" });\n const pluginNumberWidth =\n hooks.length >= 10 ? String(hooks.length).length : 1;\n\n logger.debug(\n `🧩 Calling ${hooks.length} ${chalk.bold.cyanBright(\n `${key}${options?.order ? ` (${options.order})` : \"\"}`\n )} plugin hook${hooks.length > 1 ? \"s\" : \"\"}:\\n${hooks\n .map(\n (hook, index) =>\n `${String(index + 1).padStart(\n pluginNumberWidth,\n \"0\"\n )}. ${colorText(hook.plugin.name)}`\n )\n .join(\"\\n\")}`\n );\n\n const invokeHook = async (\n hook: ArrayValues<typeof hooks>,\n hookArgs: InferHookParameters<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n ) => {\n return Reflect.apply(hook.handler as AnyFunction, hook.context, hookArgs);\n };\n\n let results = [] as InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >[];\n if (options?.sequential === false) {\n results = (await Promise.all(\n hooks.map(async hook => {\n if (!isFunction(hook.handler)) {\n throw new Error(\n `Plugin hook handler for hook \"${key}\" is not a function.`\n );\n }\n\n return invokeHook(hook, [...args]);\n })\n )) as InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >[];\n } else {\n for (const hook of hooks) {\n if (!isFunction(hook.handler)) {\n throw new Error(\n `Plugin hook handler for hook \"${key}\" is not a function.`\n );\n }\n\n if (options?.result === \"first\" || options?.asNextParam === false) {\n results.push(\n (await Promise.resolve(\n invokeHook(hook, [...args])\n )) as InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n );\n if (\n options?.result === \"first\" &&\n isSet(results[results.length - 1])\n ) {\n break;\n }\n } else {\n const sequenceArgs = [...args];\n if (results.length > 0 && sequenceArgs.length > 0) {\n sequenceArgs[0] = isFunction(options.asNextParam)\n ? await Promise.resolve(options.asNextParam(results[0]))\n : results[0];\n }\n\n const result = await Promise.resolve(\n invokeHook(hook, [...sequenceArgs] as InferHookParameters<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >)\n );\n if (result) {\n if (options.result === \"last\") {\n results = [result];\n } else if (options.result === \"merge\" && options.merge) {\n results = [\n results.length > 0 && results[0]\n ? await Promise.resolve(options.merge(result, results[0]))\n : result\n ];\n } else {\n results = mergeResults(result, results);\n }\n }\n }\n }\n }\n\n const definedResults = results.filter(\n (\n result\n ): result is NonNullable<\n InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n > => isSet(result)\n );\n\n if (definedResults.length > 0) {\n let mergedResult = undefined as\n | InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n | undefined;\n\n for (const result of definedResults) {\n mergedResult = defu(\n result as Record<string, unknown>,\n mergedResult ?? {}\n ) as InferHookReturnType<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >;\n }\n\n return mergedResult;\n }\n }\n\n return undefined;\n}\n\nexport function extractHooks<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>(\n context: PluginContext<TResolvedConfig, TSystemContext>,\n hooks: Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n >,\n plugin: Plugin<PluginContext<TResolvedConfig, TSystemContext>>,\n key: string,\n parentKey?: string\n): Record<string, HooksList<PluginContext<TResolvedConfig, TSystemContext>>> {\n const combinedKey = parentKey ? `${parentKey}:${key}` : key;\n const pluginField = getField(plugin, combinedKey.replace(/:/g, \".\"));\n if (\n isPluginHookField<PluginContext<TResolvedConfig, TSystemContext>>(\n combinedKey\n ) &&\n isPluginHook(pluginField)\n ) {\n const pluginHook = pluginField;\n if (!isPluginHook(pluginHook)) {\n return hooks;\n }\n\n hooks[combinedKey] ??= {\n preEnforced: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n preOrdered: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n normal: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n postEnforced: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n postOrdered: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[]\n };\n\n if (plugin.enforce) {\n const hookListOrder = `${plugin.enforce}Enforced` as HookListOrders;\n hooks[combinedKey][hookListOrder] ??= [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[];\n\n hooks[combinedKey][hookListOrder] = addPluginHook<\n PluginContext<TResolvedConfig, TSystemContext>,\n PluginHookFields<PluginContext<TResolvedConfig, TSystemContext>>\n >(context, plugin, pluginHook, hooks[combinedKey][hookListOrder]);\n\n return hooks;\n }\n\n if (isFunction(pluginHook) || !pluginHook.order) {\n hooks[combinedKey].normal ??= [];\n\n hooks[combinedKey].normal = addPluginHook<\n PluginContext<TResolvedConfig, TSystemContext>,\n PluginHookFields<PluginContext<TResolvedConfig, TSystemContext>>\n >(context, plugin, pluginHook, hooks[combinedKey].normal);\n\n return hooks;\n }\n\n const hookListOrder = `${pluginHook.order}Ordered` as HookListOrders;\n hooks[combinedKey][hookListOrder] ??= [];\n\n hooks[combinedKey][hookListOrder] = addPluginHook<\n PluginContext<TResolvedConfig, TSystemContext>,\n PluginHookFields<PluginContext<TResolvedConfig, TSystemContext>>\n >(context, plugin, pluginHook, hooks[combinedKey][hookListOrder]);\n\n return hooks;\n } else if (isSetObject(pluginField)) {\n return Object.keys(pluginField)\n .map(pluginKey =>\n extractHooks(context, hooks, plugin, pluginKey, combinedKey)\n )\n .reduce((ret, current) => {\n Object.keys(current).forEach(key => {\n ret[key] ??= {\n preEnforced: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n preOrdered: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n normal: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n postEnforced: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[],\n postOrdered: [] as HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>\n >[]\n };\n\n [\n \"preEnforced\",\n \"preOrdered\",\n \"normal\",\n \"postEnforced\",\n \"postOrdered\"\n ].forEach(order => {\n if (\n current[key]?.[\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ]\n ) {\n ret[key]![\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ] ??= [];\n ret[key]![\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ] = ret[key]![\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ]!.concat(\n current[key][\n order as keyof HooksList<\n PluginContext<TResolvedConfig, TSystemContext>\n >\n ]!\n );\n }\n });\n });\n\n return ret;\n }, hooks);\n }\n\n return hooks;\n}\n\nexport async function callHook<\n TKey extends string,\n TResolvedConfig extends ResolvedConfig,\n TSystemContext = unknown\n>(\n context: ExecutionContext<TResolvedConfig, TSystemContext>,\n key: TKey,\n options: CallHookOptions & {\n environment?: string | EnvironmentContext<TResolvedConfig, TSystemContext>;\n },\n ...args: InferHookParameters<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >\n) {\n return _callHook<TResolvedConfig, TSystemContext, TKey>(\n isSetObject(options?.environment)\n ? options.environment\n : await context.getEnvironment(options?.environment),\n key,\n { sequential: true, ...options },\n ...args\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,aAEd,eAAkB,iBAA2B;CAC7C,IAAI,CAAC,mBAAmB,gBAAgB,WAAW,GACjD,OAAO,CAAC,aAAa;CAGvB,IAAI,YAAY,aAAa,GAC3B,kBAAkB,CAChB,GAAG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E;IACA;IACA;IACA;IACA;GACF,EAAE,SAAQ,UAAS;IACjB,IACE,QAAQ,OACN,QAIF;KACA,IAAI,KACF,WAGI,CAAC;KACP,IAAI,KACF,SAGE,IAAI,KACN,OAGC,OACD,QAAQ,KACN,MAIJ;IACF;GACF,CAAC;EACH,CAAC;EAED,OAAO;CACT,GAAG,KAAK;CAGZ,OAAO;AACT;AAEA,eAAsB,SAKpB,SACA,KACA,SAGA,GAAG,MAIH;CACA,OAAO,UACL,YAAY,SAAS,WAAW,IAC5B,QAAQ,cACR,MAAM,QAAQ,eAAe,SAAS,WAAW,GACrD,KACA;EAAE,YAAY;EAAM,GAAG;CAAQ,GAC/B,GAAG,IACL;AACF"}
|
|
@@ -59,7 +59,7 @@ async function getWorkspaceName(context) {
|
|
|
59
59
|
* Format an execution ID based on the project name, command, and config index.
|
|
60
60
|
*
|
|
61
61
|
* @remarks
|
|
62
|
-
* The execution ID is formatted as `${projectName}
|
|
62
|
+
* The execution ID is formatted as `${projectName}:${command}:${index}`, where:
|
|
63
63
|
* - `projectName` is the name of the project.
|
|
64
64
|
* - `command` is the command being executed.
|
|
65
65
|
* - `index` is a zero-padded number representing the execution index (starting from 1).
|
|
@@ -67,10 +67,10 @@ async function getWorkspaceName(context) {
|
|
|
67
67
|
* @example
|
|
68
68
|
* ```ts
|
|
69
69
|
* const executionId = formatExecutionId("my-project", "build", 0);
|
|
70
|
-
* // This will return "my-project
|
|
70
|
+
* // This will return "my-project:build:01"
|
|
71
71
|
*
|
|
72
72
|
* const executionId2 = formatExecutionId("my-project", "test", 5);
|
|
73
|
-
* // This will return "my-project
|
|
73
|
+
* // This will return "my-project:test:06"
|
|
74
74
|
* ```
|
|
75
75
|
*
|
|
76
76
|
* @param projectName - The name of the project.
|
|
@@ -79,7 +79,7 @@ async function getWorkspaceName(context) {
|
|
|
79
79
|
* @returns The formatted execution ID.
|
|
80
80
|
*/
|
|
81
81
|
function formatExecutionId(projectName, command, configIndex = 0) {
|
|
82
|
-
return `${projectName}
|
|
82
|
+
return `${projectName}:${command}:${String(configIndex + 1).padStart(2, "0")}`;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
//#endregion
|
|
@@ -27,7 +27,7 @@ declare function getWorkspaceName(context: UnresolvedContext): Promise<string |
|
|
|
27
27
|
* Format an execution ID based on the project name, command, and config index.
|
|
28
28
|
*
|
|
29
29
|
* @remarks
|
|
30
|
-
* The execution ID is formatted as `${projectName}
|
|
30
|
+
* The execution ID is formatted as `${projectName}:${command}:${index}`, where:
|
|
31
31
|
* - `projectName` is the name of the project.
|
|
32
32
|
* - `command` is the command being executed.
|
|
33
33
|
* - `index` is a zero-padded number representing the execution index (starting from 1).
|
|
@@ -35,10 +35,10 @@ declare function getWorkspaceName(context: UnresolvedContext): Promise<string |
|
|
|
35
35
|
* @example
|
|
36
36
|
* ```ts
|
|
37
37
|
* const executionId = formatExecutionId("my-project", "build", 0);
|
|
38
|
-
* // This will return "my-project
|
|
38
|
+
* // This will return "my-project:build:01"
|
|
39
39
|
*
|
|
40
40
|
* const executionId2 = formatExecutionId("my-project", "test", 5);
|
|
41
|
-
* // This will return "my-project
|
|
41
|
+
* // This will return "my-project:test:06"
|
|
42
42
|
* ```
|
|
43
43
|
*
|
|
44
44
|
* @param projectName - The name of the project.
|
|
@@ -27,7 +27,7 @@ declare function getWorkspaceName(context: UnresolvedContext): Promise<string |
|
|
|
27
27
|
* Format an execution ID based on the project name, command, and config index.
|
|
28
28
|
*
|
|
29
29
|
* @remarks
|
|
30
|
-
* The execution ID is formatted as `${projectName}
|
|
30
|
+
* The execution ID is formatted as `${projectName}:${command}:${index}`, where:
|
|
31
31
|
* - `projectName` is the name of the project.
|
|
32
32
|
* - `command` is the command being executed.
|
|
33
33
|
* - `index` is a zero-padded number representing the execution index (starting from 1).
|
|
@@ -35,10 +35,10 @@ declare function getWorkspaceName(context: UnresolvedContext): Promise<string |
|
|
|
35
35
|
* @example
|
|
36
36
|
* ```ts
|
|
37
37
|
* const executionId = formatExecutionId("my-project", "build", 0);
|
|
38
|
-
* // This will return "my-project
|
|
38
|
+
* // This will return "my-project:build:01"
|
|
39
39
|
*
|
|
40
40
|
* const executionId2 = formatExecutionId("my-project", "test", 5);
|
|
41
|
-
* // This will return "my-project
|
|
41
|
+
* // This will return "my-project:test:06"
|
|
42
42
|
* ```
|
|
43
43
|
*
|
|
44
44
|
* @param projectName - The name of the project.
|
|
@@ -58,7 +58,7 @@ async function getWorkspaceName(context) {
|
|
|
58
58
|
* Format an execution ID based on the project name, command, and config index.
|
|
59
59
|
*
|
|
60
60
|
* @remarks
|
|
61
|
-
* The execution ID is formatted as `${projectName}
|
|
61
|
+
* The execution ID is formatted as `${projectName}:${command}:${index}`, where:
|
|
62
62
|
* - `projectName` is the name of the project.
|
|
63
63
|
* - `command` is the command being executed.
|
|
64
64
|
* - `index` is a zero-padded number representing the execution index (starting from 1).
|
|
@@ -66,10 +66,10 @@ async function getWorkspaceName(context) {
|
|
|
66
66
|
* @example
|
|
67
67
|
* ```ts
|
|
68
68
|
* const executionId = formatExecutionId("my-project", "build", 0);
|
|
69
|
-
* // This will return "my-project
|
|
69
|
+
* // This will return "my-project:build:01"
|
|
70
70
|
*
|
|
71
71
|
* const executionId2 = formatExecutionId("my-project", "test", 5);
|
|
72
|
-
* // This will return "my-project
|
|
72
|
+
* // This will return "my-project:test:06"
|
|
73
73
|
* ```
|
|
74
74
|
*
|
|
75
75
|
* @param projectName - The name of the project.
|
|
@@ -78,7 +78,7 @@ async function getWorkspaceName(context) {
|
|
|
78
78
|
* @returns The formatted execution ID.
|
|
79
79
|
*/
|
|
80
80
|
function formatExecutionId(projectName, command, configIndex = 0) {
|
|
81
|
-
return `${projectName}
|
|
81
|
+
return `${projectName}:${command}:${String(configIndex + 1).padStart(2, "0")}`;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-helpers.mjs","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Get the organization name from the context\n *\n * @param context - The Powerlines plugin context.\n * @returns The organization name or undefined if not found.\n */\nexport async function getOrganizationName(\n context: UnresolvedContext\n): Promise<string | undefined> {\n if (isSetString(context.config.organization)) {\n return context.config.organization;\n }\n\n return (\n getPackageJsonOrganization(context.packageJson) ||\n (await getWorkspaceName(context)) ||\n context.config.name\n );\n}\n\n/**\n * Get the organization name from the `package.json` file\n *\n * @param packageJson - The `package.json` object to extract the organization name from.\n * @returns The organization name or undefined if not found.\n */\nexport function getPackageJsonOrganization(\n packageJson: PackageJson\n): string | undefined {\n let result: string | undefined;\n if (\n Array.isArray(packageJson.maintainers) &&\n packageJson.maintainers.length > 0\n ) {\n if (isSetObject(packageJson.maintainers[0])) {\n result = (packageJson.maintainers[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.maintainers[0])) {\n result = packageJson.maintainers[0];\n }\n }\n\n if (\n !result &&\n Array.isArray(packageJson.author) &&\n packageJson.author.length > 0\n ) {\n if (isSetObject(packageJson.author[0])) {\n result = (packageJson.author[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.author[0])) {\n result = packageJson.author[0];\n }\n }\n\n if (\n !result &&\n Array.isArray(packageJson.contributors) &&\n packageJson.contributors.length > 0\n ) {\n if (isSetObject(packageJson.contributors[0])) {\n result = (packageJson.contributors[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.contributors[0])) {\n result = packageJson.contributors[0];\n }\n }\n\n if (!result && isSetString(packageJson.namespace)) {\n result = packageJson.namespace?.replace(/^@/, \"\");\n }\n\n if (!result && isSetString(packageJson.name)) {\n result = packageJson.name.replace(/^@/, \"\").replace(/\\/.*$/, \"\");\n }\n\n return result;\n}\n\n/**\n * Get the organization name from the context\n *\n * @param context - The Powerlines plugin context.\n * @returns The organization name or undefined if not found.\n */\nexport async function getWorkspaceName(\n context: UnresolvedContext\n): Promise<string | undefined> {\n let result: string | undefined;\n\n const workspaceConfig = await tryGetWorkspaceConfig(true);\n if (workspaceConfig) {\n if (isSetString(workspaceConfig.name)) {\n result = workspaceConfig.name;\n }\n\n if (!result && isSetString(workspaceConfig.namespace)) {\n result = workspaceConfig.namespace.replace(/^@/, \"\");\n }\n }\n\n if (!result && isSetString(context.packageJson.namespace)) {\n result = context.packageJson.namespace.replace(/^@/, \"\");\n }\n\n if (!result && isSetString(context.packageJson.name)) {\n result = context.packageJson.name.replace(/^@/, \"\").replace(/\\/.*$/, \"\");\n }\n\n return result;\n}\n\n/**\n * Format an execution ID based on the project name, command, and config index.\n *\n * @remarks\n * The execution ID is formatted as `${projectName}
|
|
1
|
+
{"version":3,"file":"context-helpers.mjs","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Get the organization name from the context\n *\n * @param context - The Powerlines plugin context.\n * @returns The organization name or undefined if not found.\n */\nexport async function getOrganizationName(\n context: UnresolvedContext\n): Promise<string | undefined> {\n if (isSetString(context.config.organization)) {\n return context.config.organization;\n }\n\n return (\n getPackageJsonOrganization(context.packageJson) ||\n (await getWorkspaceName(context)) ||\n context.config.name\n );\n}\n\n/**\n * Get the organization name from the `package.json` file\n *\n * @param packageJson - The `package.json` object to extract the organization name from.\n * @returns The organization name or undefined if not found.\n */\nexport function getPackageJsonOrganization(\n packageJson: PackageJson\n): string | undefined {\n let result: string | undefined;\n if (\n Array.isArray(packageJson.maintainers) &&\n packageJson.maintainers.length > 0\n ) {\n if (isSetObject(packageJson.maintainers[0])) {\n result = (packageJson.maintainers[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.maintainers[0])) {\n result = packageJson.maintainers[0];\n }\n }\n\n if (\n !result &&\n Array.isArray(packageJson.author) &&\n packageJson.author.length > 0\n ) {\n if (isSetObject(packageJson.author[0])) {\n result = (packageJson.author[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.author[0])) {\n result = packageJson.author[0];\n }\n }\n\n if (\n !result &&\n Array.isArray(packageJson.contributors) &&\n packageJson.contributors.length > 0\n ) {\n if (isSetObject(packageJson.contributors[0])) {\n result = (packageJson.contributors[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.contributors[0])) {\n result = packageJson.contributors[0];\n }\n }\n\n if (!result && isSetString(packageJson.namespace)) {\n result = packageJson.namespace?.replace(/^@/, \"\");\n }\n\n if (!result && isSetString(packageJson.name)) {\n result = packageJson.name.replace(/^@/, \"\").replace(/\\/.*$/, \"\");\n }\n\n return result;\n}\n\n/**\n * Get the organization name from the context\n *\n * @param context - The Powerlines plugin context.\n * @returns The organization name or undefined if not found.\n */\nexport async function getWorkspaceName(\n context: UnresolvedContext\n): Promise<string | undefined> {\n let result: string | undefined;\n\n const workspaceConfig = await tryGetWorkspaceConfig(true);\n if (workspaceConfig) {\n if (isSetString(workspaceConfig.name)) {\n result = workspaceConfig.name;\n }\n\n if (!result && isSetString(workspaceConfig.namespace)) {\n result = workspaceConfig.namespace.replace(/^@/, \"\");\n }\n }\n\n if (!result && isSetString(context.packageJson.namespace)) {\n result = context.packageJson.namespace.replace(/^@/, \"\");\n }\n\n if (!result && isSetString(context.packageJson.name)) {\n result = context.packageJson.name.replace(/^@/, \"\").replace(/\\/.*$/, \"\");\n }\n\n return result;\n}\n\n/**\n * Format an execution ID based on the project name, command, and config index.\n *\n * @remarks\n * The execution ID is formatted as `${projectName}:${command}:${index}`, where:\n * - `projectName` is the name of the project.\n * - `command` is the command being executed.\n * - `index` is a zero-padded number representing the execution index (starting from 1).\n *\n * @example\n * ```ts\n * const executionId = formatExecutionId(\"my-project\", \"build\", 0);\n * // This will return \"my-project:build:01\"\n *\n * const executionId2 = formatExecutionId(\"my-project\", \"test\", 5);\n * // This will return \"my-project:test:06\"\n * ```\n *\n * @param projectName - The name of the project.\n * @param command - The command being executed.\n * @param configIndex - The index of the execution (starting from 0).\n * @returns The formatted execution ID.\n */\nexport function formatExecutionId(\n projectName: string,\n command: string,\n configIndex: number = 0\n) {\n return `${projectName}:${command}:${String(configIndex + 1).padStart(2, \"0\")}`;\n}\n"],"mappings":";;;;;;;;;;;AA8BA,eAAsB,oBACpB,SAC6B;CAC7B,IAAI,YAAY,QAAQ,OAAO,YAAY,GACzC,OAAO,QAAQ,OAAO;CAGxB,OACE,2BAA2B,QAAQ,WAAW,KAC7C,MAAM,iBAAiB,OAAO,KAC/B,QAAQ,OAAO;AAEnB;;;;;;;AAQA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S,QAAQ,YAAY,UAAU,QAAQ,MAAM,EAAE;CAGzD,IAAI,CAAC,UAAU,YAAY,QAAQ,YAAY,IAAI,GACjD,SAAS,QAAQ,YAAY,KAAK,QAAQ,MAAM,EAAE,EAAE,QAAQ,SAAS,EAAE;CAGzE,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,kBACd,aACA,SACA,cAAsB,GACtB;CACA,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,cAAc,CAAC,EAAE,SAAS,GAAG,GAAG;AAC7E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/core",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.41",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "An internal core package for Powerlines - please use the `powerlines` package for public usage.",
|
|
6
6
|
"homepage": "https://stormsoftware.com",
|
|
@@ -329,17 +329,17 @@
|
|
|
329
329
|
"@rolldown/pluginutils": "1.0.0-rc.18",
|
|
330
330
|
"@storm-software/config": "^1.137.72",
|
|
331
331
|
"@storm-software/config-tools": "^1.190.40",
|
|
332
|
-
"@stryke/capnp": "^0.12.
|
|
333
|
-
"@stryke/convert": "^0.7.
|
|
334
|
-
"@stryke/env": "^0.20.
|
|
335
|
-
"@stryke/fs": "^0.33.
|
|
336
|
-
"@stryke/hash": "^0.13.
|
|
337
|
-
"@stryke/helpers": "^0.10.
|
|
338
|
-
"@stryke/json": "^0.15.
|
|
339
|
-
"@stryke/path": "^0.29.
|
|
340
|
-
"@stryke/string-format": "^0.17.
|
|
341
|
-
"@stryke/type-checks": "^0.6.
|
|
342
|
-
"@stryke/unique-id": "^0.3.
|
|
332
|
+
"@stryke/capnp": "^0.12.111",
|
|
333
|
+
"@stryke/convert": "^0.7.15",
|
|
334
|
+
"@stryke/env": "^0.20.102",
|
|
335
|
+
"@stryke/fs": "^0.33.85",
|
|
336
|
+
"@stryke/hash": "^0.13.38",
|
|
337
|
+
"@stryke/helpers": "^0.10.24",
|
|
338
|
+
"@stryke/json": "^0.15.8",
|
|
339
|
+
"@stryke/path": "^0.29.11",
|
|
340
|
+
"@stryke/string-format": "^0.17.26",
|
|
341
|
+
"@stryke/type-checks": "^0.6.17",
|
|
342
|
+
"@stryke/unique-id": "^0.3.96",
|
|
343
343
|
"birpc": "^4.0.0",
|
|
344
344
|
"bundle-require": "^5.1.0",
|
|
345
345
|
"c12": "^3.3.4",
|
|
@@ -357,13 +357,13 @@
|
|
|
357
357
|
"oxc-resolver": "^11.20.0",
|
|
358
358
|
"prettier": "^3.8.3",
|
|
359
359
|
"ts-morph": "^27.0.2",
|
|
360
|
-
"undici": "^7.
|
|
360
|
+
"undici": "^7.27.0",
|
|
361
361
|
"unplugin": "^3.0.0",
|
|
362
362
|
"unplugin-combine": "^2.4.0"
|
|
363
363
|
},
|
|
364
364
|
"devDependencies": {
|
|
365
365
|
"@storm-software/testing-tools": "^1.119.193",
|
|
366
|
-
"@stryke/types": "^0.12.
|
|
366
|
+
"@stryke/types": "^0.12.12",
|
|
367
367
|
"@types/bun": "^1.3.14",
|
|
368
368
|
"@types/diff-match-patch": "^1.0.36",
|
|
369
369
|
"@types/node": "^25.9.1",
|
|
@@ -372,8 +372,8 @@
|
|
|
372
372
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
373
373
|
"tsdown": "^0.22.1",
|
|
374
374
|
"typescript": "^6.0.3",
|
|
375
|
-
"undici-types": "^7.
|
|
375
|
+
"undici-types": "^7.27.0"
|
|
376
376
|
},
|
|
377
377
|
"publishConfig": { "access": "public" },
|
|
378
|
-
"gitHead": "
|
|
378
|
+
"gitHead": "56d15e5936a73dc76f87493f7f05ec2df0b1ba7f"
|
|
379
379
|
}
|