@powerlines/core 0.15.24 → 0.15.26
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/constants/log-level.d.cts +1 -1
- package/dist/constants/log-level.d.mts +1 -1
- package/dist/context/environment-context.cjs +1 -1
- package/dist/context/environment-context.d.cts.map +1 -1
- package/dist/context/environment-context.d.mts.map +1 -1
- package/dist/context/environment-context.mjs +2 -2
- package/dist/context/environment-context.mjs.map +1 -1
- package/dist/context/execution-context.cjs +1 -1
- package/dist/context/execution-context.mjs +1 -1
- package/dist/context/execution-context.mjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/lib/config.cjs +0 -6
- package/dist/lib/config.d.cts +26 -5
- package/dist/lib/config.d.cts.map +1 -1
- package/dist/lib/config.d.mts +26 -5
- package/dist/lib/config.d.mts.map +1 -1
- package/dist/lib/config.mjs +0 -6
- package/dist/lib/config.mjs.map +1 -1
- package/dist/lib/context-helpers.d.cts +4 -4
- package/dist/lib/context-helpers.d.mts +4 -4
- package/dist/types/config.d.cts +33 -40
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +33 -40
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/package.json +6 -6
|
@@ -20,7 +20,7 @@ declare const LogCategories: {
|
|
|
20
20
|
readonly BABEL: "babel";
|
|
21
21
|
readonly COMMUNICATION: "communication";
|
|
22
22
|
};
|
|
23
|
-
declare const LOG_CATEGORIES_ARRAY: ("
|
|
23
|
+
declare const LOG_CATEGORIES_ARRAY: ("general" | "fs" | "performance" | "config" | "plugins" | "hooks" | "env" | "rpc" | "babel" | "communication")[];
|
|
24
24
|
declare const LOG_CATEGORIES: readonly ["general", "fs", "performance", "config", "plugins", "hooks", "env", "rpc", "communication", "babel"];
|
|
25
25
|
declare const DEFAULT_DEVELOPMENT_LOG_LEVEL: {
|
|
26
26
|
readonly general: "debug";
|
|
@@ -20,7 +20,7 @@ declare const LogCategories: {
|
|
|
20
20
|
readonly BABEL: "babel";
|
|
21
21
|
readonly COMMUNICATION: "communication";
|
|
22
22
|
};
|
|
23
|
-
declare const LOG_CATEGORIES_ARRAY: ("
|
|
23
|
+
declare const LOG_CATEGORIES_ARRAY: ("general" | "fs" | "performance" | "config" | "plugins" | "hooks" | "env" | "rpc" | "babel" | "communication")[];
|
|
24
24
|
declare const LOG_CATEGORIES: readonly ["general", "fs", "performance", "config", "plugins", "hooks", "env", "rpc", "communication", "babel"];
|
|
25
25
|
declare const DEFAULT_DEVELOPMENT_LOG_LEVEL: {
|
|
26
26
|
readonly general: "debug";
|
|
@@ -119,7 +119,7 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends re
|
|
|
119
119
|
* @internal
|
|
120
120
|
*/
|
|
121
121
|
async unstable_addPlugin(plugin) {
|
|
122
|
-
const plugins = await require_lib_plugins.resolvePlugins(this, plugin);
|
|
122
|
+
const plugins = await require_lib_plugins.resolvePlugins(this, plugin, { skipLogging: !!(this.environmentConfig?.name && this.environmentConfig.name !== "default" && this.environmentConfig.name !== "__global__") });
|
|
123
123
|
for (const plugin of plugins) {
|
|
124
124
|
let resolvedPlugin = plugin;
|
|
125
125
|
if ((0, _stryke_type_checks_is_function.isFunction)(plugin.applyToEnvironment)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-context.d.cts","names":[],"sources":["../../src/context/environment-context.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"environment-context.d.cts","names":[],"sources":["../../src/context/environment-context.ts"],"mappings":";;;;;;cA2Da,4BAAA,yBACa,cAAA,GAAiB,cAAA,oCAGjC,iBAAA,CACN,yBAAA,CAA0B,eAAA,GAC1B,cAAA,aAES,kBAAA,CAAmB,eAAA,EAAiB,cAAA;EAAA;;;;;AARjD;;;;;SAgCsB,IAAA,yBACM,cAAA,GAAiB,cAAA,2BAAA,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AA,GAAe,yBAAA,CAA0B,eAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-context.d.mts","names":[],"sources":["../../src/context/environment-context.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"environment-context.d.mts","names":[],"sources":["../../src/context/environment-context.ts"],"mappings":";;;;;;cA2Da,4BAAA,yBACa,cAAA,GAAiB,cAAA,oCAGjC,iBAAA,CACN,yBAAA,CAA0B,eAAA,GAC1B,cAAA,aAES,kBAAA,CAAmB,eAAA,EAAiB,cAAA;EAAA;;;;;AARjD;;;;;SAgCsB,IAAA,yBACM,cAAA,GAAiB,cAAA,2BAAA,CAGzC,SAAA,EAAW,gBAAA,CAAiB,eAAA,EAAiB,cAAA,GAC7C,OAAA,EAAS,gBAAA,EACT,MAAA,EAAQ,eAAA,EACR,gBAAA,EAAkB,sBAAA,CAChB,yBAAA,CAA0B,eAAA,KAE3B,OAAA,CAAQ,4BAAA,CAA6B,eAAA,EAAiB,cAAA;EArCvD;;;EAAA,UAkDiB,iBAAA,EAAmB,yBAAA,CAA0B,eAAA;EAtBtC;;;EA4BnB,OAAA,EAAS,iBAAA,CAAkB,eAAA,EAAiB,cAAA;EAzBtC;;;EAAA,IA8BF,EAAA,CAAA;EA1BP;;;EAAA,IAiCO,KAAA,CAAA,GAAS,MAAA,SAElB,SAAA,CAAU,aAAA,CAAc,eAAA,EAAiB,cAAA;EAjChC;;;;;;;;EAAA,IA8CA,kBAAA,CAAA,GAAsB,gBAAA,CAC/B,eAAA,EACA,cAAA;EAfU;;;;;;EA0BC,oBAAA,CACX,MAAA,EAAQ,yBAAA,CAA0B,eAAA,mBACjC,OAAA;EADO;;;;;;EAiBM,YAAA,CAAa,OAAA,EAAS,aAAA,GAAgB,MAAA;EA6BA;;;;;;EAhBtC,YAAA,CAAa,OAAA,EAAS,aAAA,GAAgB,MAAA;EAuHH;;;;;;;;EAxGtC,kBAAA,CACX,MAAA,EAAQ,YAAA,CAAa,aAAA,CAAc,eAAA,EAAiB,cAAA,KACnD,OAAA;EAqL2B;;;EAlFvB,WAAA,qBAAA,CACL,GAAA,EAAK,IAAA,EACL,OAAA,GAAU,kBAAA,GACT,gBAAA,CAAiB,aAAA,CAAc,eAAA,EAAiB,cAAA,GAAiB,IAAA;EAkGlC;;;;;;;;;;;;EAAA,UAxBzB,WAAA,CACP,SAAA,EAAW,gBAAA,CAAiB,eAAA,EAAiB,cAAA,GAC7C,OAAA,EAAS,gBAAA,EACT,MAAA,EAAQ,eAAA,EACR,gBAAA,EAAkB,sBAAA,CAChB,yBAAA,CAA0B,eAAA;EAlUnB;;;;;EAAA,UAqVQ,WAAA,CAAA,GAAe,yBAAA,CAA0B,eAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_ENVIRONMENT } from "../constants/environments.mjs";
|
|
1
|
+
import { DEFAULT_ENVIRONMENT, GLOBAL_ENVIRONMENT } from "../constants/environments.mjs";
|
|
2
2
|
import { PLUGIN_NON_HOOK_FIELDS } from "../constants/plugin.mjs";
|
|
3
3
|
import { dedupeHooklist, isPlugin, isPluginConfig, isPluginHookField } from "../plugin-utils/helpers.mjs";
|
|
4
4
|
import { mergeConfig } from "../plugin-utils/merge.mjs";
|
|
@@ -117,7 +117,7 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
117
117
|
* @internal
|
|
118
118
|
*/
|
|
119
119
|
async unstable_addPlugin(plugin) {
|
|
120
|
-
const plugins = await resolvePlugins(this, plugin);
|
|
120
|
+
const plugins = await resolvePlugins(this, plugin, { skipLogging: !!(this.environmentConfig?.name && this.environmentConfig.name !== "default" && this.environmentConfig.name !== "__global__") });
|
|
121
121
|
for (const plugin of plugins) {
|
|
122
122
|
let resolvedPlugin = plugin;
|
|
123
123
|
if (isFunction(plugin.applyToEnvironment)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-context.mjs","names":["#hooks","#execution"],"sources":["../../src/context/environment-context.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 { omit } from \"@stryke/helpers/omit\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { ArrayValues } from \"@stryke/types/array\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { DEFAULT_ENVIRONMENT, PLUGIN_NON_HOOK_FIELDS } from \"../constants\";\nimport { extractHooks } from \"../lib/hooks\";\nimport { resolvePlugins } from \"../lib/plugins\";\nimport {\n dedupeHooklist,\n formatConfig,\n isPlugin,\n isPluginConfig,\n isPluginHookField,\n mergeConfig\n} from \"../plugin-utils\";\nimport type {\n EnvironmentContext,\n EnvironmentPlugin,\n EnvironmentResolvedConfig,\n ExecutionContext,\n ExecutionOptions,\n HooksList,\n HooksListItem,\n InferOverridableConfig,\n Logger,\n LoggerOptions,\n PluginConfig,\n PluginContext,\n ResolvedConfig,\n SelectHookResult,\n SelectHooksOptions\n} from \"../types\";\nimport { PowerlinesContext } from \"./context\";\nimport { createPluginContext } from \"./plugin-context\";\n\nexport class PowerlinesEnvironmentContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>\n extends PowerlinesContext<\n EnvironmentResolvedConfig<TResolvedConfig>,\n TSystemContext\n >\n implements EnvironmentContext<TResolvedConfig, TSystemContext>\n{\n /**\n * The hooks registered by plugins in this environment\n */\n #hooks: Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n > = {};\n\n /**\n * The execution context associated with this environment, which provides access to the project configuration, environment, and utility functions for performing the build. The execution context is used to manage the state and behavior of the build process across multiple environments, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n */\n #execution: ExecutionContext<TResolvedConfig, TSystemContext>;\n\n /**\n * Create a new context from the config.\n *\n * @param execution - The execution context for the build process, which provides access to the project configuration, environment, and utility functions for performing the build. The context is used to manage the state and behavior of the build process, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n * @param options - The resolved execution options.\n * @param config - The user configuration options.\n * @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.\n * @returns A promise that resolves to an instance of the PowerlinesEnvironmentContext class, initialized with the provided configuration and environment data.\n */\n public static async from<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n >(\n execution: ExecutionContext<TResolvedConfig, TSystemContext>,\n options: ExecutionOptions,\n config: TResolvedConfig,\n overriddenConfig: InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >\n ): Promise<PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>> {\n const context = new PowerlinesEnvironmentContext<\n TResolvedConfig,\n TSystemContext\n >(execution, options, config, overriddenConfig);\n await context.init();\n\n return context;\n }\n\n /**\n * The configuration options provided by plugins added by the user (and other plugins)\n */\n protected override environmentConfig: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"] =\n {} as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"];\n\n /**\n * The list of plugins applied to this environment\n */\n public plugins: EnvironmentPlugin<TResolvedConfig, TSystemContext>[] = [];\n\n /**\n * The unique identifier of the environment associated with this context, which can be used for logging and other purposes to distinguish between different environments in the same process.\n */\n public get id(): string {\n return this.config.environment.id;\n }\n\n /**\n * The hooks registered by plugins in this environment\n */\n public get hooks(): Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n > {\n return this.#hooks;\n }\n\n /**\n * The execution context associated with this environment, which provides access to the project configuration, environment, and utility functions for performing the build. The execution context is used to manage the state and behavior of the build process across multiple environments, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public get unstable_execution(): ExecutionContext<\n TResolvedConfig,\n TSystemContext\n > {\n return this.#execution;\n }\n\n /**\n * A setter function to populate the environment config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the environment configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any environment configuration provided during execution.\n *\n * @param config - The environment configuration values to set.\n * @returns A promise that resolves when the environment configuration values have been set.\n */\n public async setEnvironmentConfig(\n config: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n ): Promise<void> {\n this.logger.debug({\n meta: { category: \"config\" },\n message: `Updating environment configuration object: \\n${formatConfig(config)}`\n });\n\n this.environmentConfig = config;\n await this.resolveConfig();\n }\n\n /**\n * Create a new logger instance\n *\n * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public override createLogger(options: LoggerOptions): Logger {\n return super.createLogger({\n ...options,\n environment: this.environmentConfig?.name || this.config.environment?.name\n });\n }\n\n /**\n * Extend the base logger with additional configuration options\n *\n * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.\n * @returns A new logger client instance that extends the base logger with the provided configuration options.\n */\n public override extendLogger(options: LoggerOptions): Logger {\n return super.extendLogger({\n ...options,\n environment: this.environmentConfig?.name || this.config.environment?.name\n });\n }\n\n /**\n * A function used internally to add a plugin to the context and update the configuration options\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public async unstable_addPlugin(\n plugin: PluginConfig<PluginContext<TResolvedConfig, TSystemContext>>\n ): Promise<void> {\n const plugins = await resolvePlugins<TResolvedConfig, TSystemContext>(\n this,\n plugin\n );\n for (const plugin of plugins) {\n let resolvedPlugin = plugin as EnvironmentPlugin<\n TResolvedConfig,\n TSystemContext\n >;\n if (isFunction(plugin.applyToEnvironment)) {\n const result = (await Promise.resolve(\n plugin.applyToEnvironment(this.config.environment) as Promise<any>\n )) as\n | boolean\n | PluginConfig<PluginContext<TResolvedConfig, TSystemContext>>;\n\n if (!result || (isObject(result) && Object.keys(result).length === 0)) {\n return;\n }\n\n if (\n isPluginConfig<PluginContext<TResolvedConfig, TSystemContext>>(result)\n ) {\n return this.unstable_addPlugin(result);\n }\n\n resolvedPlugin = (\n isPlugin<PluginContext<TResolvedConfig, TSystemContext>>(result)\n ? result\n : plugin\n ) as EnvironmentPlugin<TResolvedConfig, TSystemContext>;\n }\n\n const id = uuid();\n const context = createPluginContext<TResolvedConfig, TSystemContext>(\n id,\n resolvedPlugin,\n this\n );\n\n resolvedPlugin[\"~internal\"] = {\n id,\n context\n };\n\n this.plugins.push(resolvedPlugin);\n\n this.#hooks = Object.entries(\n Object.keys(resolvedPlugin)\n .filter(\n key =>\n key !== \"~internal\" &&\n !PLUGIN_NON_HOOK_FIELDS.includes(\n key as ArrayValues<typeof PLUGIN_NON_HOOK_FIELDS>\n )\n )\n .reduce(\n (ret, key) =>\n extractHooks<TResolvedConfig, TSystemContext>(\n context,\n ret,\n resolvedPlugin,\n key\n ),\n this.hooks\n )\n ).reduce(\n (ret, [key, value]) => {\n if (isSetObject(value)) {\n Object.entries(value).forEach(([type, list]) => {\n ret[key] ??= {};\n ret[key][type as keyof (typeof ret)[typeof key]] =\n dedupeHooklist<PluginContext<TResolvedConfig, TSystemContext>>(\n list\n );\n });\n }\n\n return ret;\n },\n {} as Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n >\n );\n }\n }\n\n /**\n * Retrieves the hook handlers for a specific hook name\n */\n public selectHooks<TKey extends string>(\n key: TKey,\n options?: SelectHooksOptions\n ): SelectHookResult<PluginContext<TResolvedConfig, TSystemContext>, TKey> {\n const result = [] as SelectHookResult<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >;\n\n if (\n isPluginHookField<PluginContext<TResolvedConfig, TSystemContext>>(key) &&\n this.hooks[key]\n ) {\n if (this.hooks[key]) {\n if (options?.order) {\n const mapHooksToResult = (\n hooksList: HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >[]\n ): SelectHookResult<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n > =>\n hooksList.map(hook => {\n const plugin = this.plugins.find(\n p => p.name === hook.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${\n hook.plugin.name\n }\".`\n );\n }\n\n return {\n handler: hook.handler,\n plugin: hook.plugin,\n context: plugin[\"~internal\"].context\n };\n });\n\n if (options?.order === \"pre\") {\n result.push(...mapHooksToResult(this.hooks[key].preOrdered ?? []));\n result.push(...mapHooksToResult(this.hooks[key].preEnforced ?? []));\n } else if (options?.order === \"post\") {\n result.push(...mapHooksToResult(this.hooks[key].postOrdered ?? []));\n result.push(\n ...mapHooksToResult(this.hooks[key].postEnforced ?? [])\n );\n } else {\n result.push(...mapHooksToResult(this.hooks[key].normal ?? []));\n }\n } else {\n result.push(...this.selectHooks(key, { order: \"pre\" }));\n result.push(...this.selectHooks(key, { order: \"normal\" }));\n result.push(...this.selectHooks(key, { order: \"post\" }));\n }\n }\n }\n\n return result;\n }\n\n /**\n * A function to add a plugin to the context and update the configuration options. This function is used internally when applying plugins to the environment, and it ensures that the plugin is added to the list of plugins in the context and that any hooks or configuration options provided by the plugin are properly integrated into the context's state.\n *\n * @remarks\n * This function is used internally when applying plugins to the environment, and it ensures that the plugin is added to the list of plugins in the context and that any hooks or configuration options provided by the plugin are properly integrated into the context's state. It should not be called directly by external code, as it is intended for internal use only and may be subject to change without warning.\n *\n * @param execution - The execution context for the build process, which provides access to the project configuration, environment, and utility functions for performing the build. The context is used to manage the state and behavior of the build process, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n * @param options - The configuration options for the plugin, which may include properties such as the plugin name, hooks, and any other relevant metadata or settings that should be associated with the plugin when it is added to the context.\n * @param config - The resolved configuration for the environment, which may include properties such as the environment name, SSR settings, and other relevant configuration options that may affect how the plugin is applied to the environment.\n * @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.\n * @returns A promise that resolves when the plugin has been added to the context and the configuration has been updated accordingly.\n */\n protected constructor(\n execution: ExecutionContext<TResolvedConfig, TSystemContext>,\n options: ExecutionOptions,\n config: TResolvedConfig,\n overriddenConfig: InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >\n ) {\n super(options);\n\n this.#execution = execution;\n this.userConfig =\n config.userConfig ?? ({} as TResolvedConfig[\"userConfig\"]);\n this.inlineConfig =\n config.inlineConfig ?? ({} as TResolvedConfig[\"inlineConfig\"]);\n this.pluginConfig = config.pluginConfig ?? {};\n this.overriddenConfig = overriddenConfig;\n }\n\n /**\n * A function to merge the various configuration objects (initial, user, inline, and plugin) into a single resolved configuration object that can be used throughout the Powerlines process. This function takes into account the different sources of configuration and their respective priorities, ensuring that the final configuration reflects the intended settings for the project. The merged configuration is then returned as a new object that can be accessed through the `config` property of the context.\n *\n * @returns The merged configuration object that combines the initial, user, inline, and plugin configurations.\n */\n protected override mergeConfig(): EnvironmentResolvedConfig<TResolvedConfig> {\n return mergeConfig(\n {\n ...omit(this.environmentConfig ?? {}, [\n \"name\",\n \"ssr\",\n \"preview\",\n \"consumer\",\n \"runtime\"\n ]),\n environment: {\n name: this.environmentConfig?.name || DEFAULT_ENVIRONMENT\n },\n environmentConfig: this.environmentConfig ?? {}\n },\n super.mergeConfig()\n ) as EnvironmentResolvedConfig<TResolvedConfig>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuDA,IAAa,+BAAb,MAAa,qCAIH,kBAKV;;;;CAIE,SAGI,CAAC;;;;CAKL;;;;;;;;;;CAWA,aAAoB,KAIlB,WACA,SACA,QACA,kBAGwE;EACxE,MAAM,UAAU,IAAI,6BAGlB,WAAW,SAAS,QAAQ,gBAAgB;EAC9C,MAAM,QAAQ,KAAK;EAEnB,OAAO;CACT;;;;CAKA,AAAmB,oBACjB,CAAC;;;;CAKH,AAAO,UAAgE,CAAC;;;;CAKxE,IAAW,KAAa;EACtB,OAAO,KAAK,OAAO,YAAY;CACjC;;;;CAKA,IAAW,QAGT;EACA,OAAO,KAAKA;CACd;;;;;;;;;CAUA,IAAW,qBAGT;EACA,OAAO,KAAKC;CACd;;;;;;;CAQA,MAAa,qBACX,QACe;EACf,KAAK,OAAO,MAAM;GAChB,MAAM,EAAE,UAAU,SAAS;GAC3B,SAAS,gDAAgD,aAAa,MAAM;EAC9E,CAAC;EAED,KAAK,oBAAoB;EACzB,MAAM,KAAK,cAAc;CAC3B;;;;;;;CAQA,AAAgB,aAAa,SAAgC;EAC3D,OAAO,MAAM,aAAa;GACxB,GAAG;GACH,aAAa,KAAK,mBAAmB,QAAQ,KAAK,OAAO,aAAa;EACxE,CAAC;CACH;;;;;;;CAQA,AAAgB,aAAa,SAAgC;EAC3D,OAAO,MAAM,aAAa;GACxB,GAAG;GACH,aAAa,KAAK,mBAAmB,QAAQ,KAAK,OAAO,aAAa;EACxE,CAAC;CACH;;;;;;;;;CAUA,MAAa,mBACX,QACe;EACf,MAAM,UAAU,MAAM,eACpB,MACA,MACF;EACA,KAAK,MAAM,UAAU,SAAS;GAC5B,IAAI,iBAAiB;GAIrB,IAAI,WAAW,OAAO,kBAAkB,GAAG;IACzC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AO;KAC5B,OAAO,KAAK,GAAG,iBAAiB,KAAK,MAAM,KAAK,cAAc,CAAC,CAAC,CAAC;KACjE,OAAO,KAAK,GAAG,iBAAiB,KAAK,MAAM,KAAK,eAAe,CAAC,CAAC,CAAC;IACpE,OAAO,IAAI,SAAS,UAAU,QAAQ;KACpC,OAAO,KAAK,GAAG,iBAAiB,KAAK,MAAM,KAAK,eAAe,CAAC,CAAC,CAAC;KAClE,OAAO,KACL,GAAG,iBAAiB,KAAK,MAAM,KAAK,gBAAgB,CAAC,CAAC,CACxD;IACF,OACE,OAAO,KAAK,GAAG,iBAAiB,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC;GAEjE,OAAO;IACL,OAAO,KAAK,GAAG,KAAK,YAAY,KAAK,EAAE,OAAO,MAAM,CAAC,CAAC;IACtD,OAAO,KAAK,GAAG,KAAK,YAAY,KAAK,EAAE,OAAO,SAAS,CAAC,CAAC;IACzD,OAAO,KAAK,GAAG,KAAK,YAAY,KAAK,EAAE,OAAO,OAAO,CAAC,CAAC;GACzD;EACF;EAGF,OAAO;CACT;;;;;;;;;;;;;CAcA,AAAU,YACR,WACA,SACA,QACA,kBAGA;EACA,MAAM,OAAO;EAEb,KAAKC,aAAa;EAClB,KAAK,aACH,OAAO,cAAe,CAAC;EACzB,KAAK,eACH,OAAO,gBAAiB,CAAC;EAC3B,KAAK,eAAe,OAAO,gBAAgB,CAAC;EAC5C,KAAK,mBAAmB;CAC1B;;;;;;CAOA,AAAmB,cAA0D;EAC3E,OAAO,YACL;GACE,GAAG,KAAK,KAAK,qBAAqB,CAAC,GAAG;IACpC;IACA;IACA;IACA;IACA;GACF,CAAC;GACD,aAAa,EACX,MAAM,KAAK,mBAAmB,kBAChC;GACA,mBAAmB,KAAK,qBAAqB,CAAC;EAChD,GACA,MAAM,YAAY,CACpB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"environment-context.mjs","names":["#hooks","#execution"],"sources":["../../src/context/environment-context.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 { omit } from \"@stryke/helpers/omit\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { ArrayValues } from \"@stryke/types/array\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport {\n DEFAULT_ENVIRONMENT,\n GLOBAL_ENVIRONMENT,\n PLUGIN_NON_HOOK_FIELDS\n} from \"../constants\";\nimport { extractHooks } from \"../lib/hooks\";\nimport { resolvePlugins } from \"../lib/plugins\";\nimport {\n dedupeHooklist,\n formatConfig,\n isPlugin,\n isPluginConfig,\n isPluginHookField,\n mergeConfig\n} from \"../plugin-utils\";\nimport type {\n EnvironmentContext,\n EnvironmentPlugin,\n EnvironmentResolvedConfig,\n ExecutionContext,\n ExecutionOptions,\n HooksList,\n HooksListItem,\n InferOverridableConfig,\n Logger,\n LoggerOptions,\n PluginConfig,\n PluginContext,\n ResolvedConfig,\n SelectHookResult,\n SelectHooksOptions\n} from \"../types\";\nimport { PowerlinesContext } from \"./context\";\nimport { createPluginContext } from \"./plugin-context\";\n\nexport class PowerlinesEnvironmentContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>\n extends PowerlinesContext<\n EnvironmentResolvedConfig<TResolvedConfig>,\n TSystemContext\n >\n implements EnvironmentContext<TResolvedConfig, TSystemContext>\n{\n /**\n * The hooks registered by plugins in this environment\n */\n #hooks: Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n > = {};\n\n /**\n * The execution context associated with this environment, which provides access to the project configuration, environment, and utility functions for performing the build. The execution context is used to manage the state and behavior of the build process across multiple environments, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n */\n #execution: ExecutionContext<TResolvedConfig, TSystemContext>;\n\n /**\n * Create a new context from the config.\n *\n * @param execution - The execution context for the build process, which provides access to the project configuration, environment, and utility functions for performing the build. The context is used to manage the state and behavior of the build process, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n * @param options - The resolved execution options.\n * @param config - The user configuration options.\n * @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.\n * @returns A promise that resolves to an instance of the PowerlinesEnvironmentContext class, initialized with the provided configuration and environment data.\n */\n public static async from<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n >(\n execution: ExecutionContext<TResolvedConfig, TSystemContext>,\n options: ExecutionOptions,\n config: TResolvedConfig,\n overriddenConfig: InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >\n ): Promise<PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>> {\n const context = new PowerlinesEnvironmentContext<\n TResolvedConfig,\n TSystemContext\n >(execution, options, config, overriddenConfig);\n await context.init();\n\n return context;\n }\n\n /**\n * The configuration options provided by plugins added by the user (and other plugins)\n */\n protected override environmentConfig: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"] =\n {} as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"];\n\n /**\n * The list of plugins applied to this environment\n */\n public plugins: EnvironmentPlugin<TResolvedConfig, TSystemContext>[] = [];\n\n /**\n * The unique identifier of the environment associated with this context, which can be used for logging and other purposes to distinguish between different environments in the same process.\n */\n public get id(): string {\n return this.config.environment.id;\n }\n\n /**\n * The hooks registered by plugins in this environment\n */\n public get hooks(): Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n > {\n return this.#hooks;\n }\n\n /**\n * The execution context associated with this environment, which provides access to the project configuration, environment, and utility functions for performing the build. The execution context is used to manage the state and behavior of the build process across multiple environments, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public get unstable_execution(): ExecutionContext<\n TResolvedConfig,\n TSystemContext\n > {\n return this.#execution;\n }\n\n /**\n * A setter function to populate the environment config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the environment configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any environment configuration provided during execution.\n *\n * @param config - The environment configuration values to set.\n * @returns A promise that resolves when the environment configuration values have been set.\n */\n public async setEnvironmentConfig(\n config: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n ): Promise<void> {\n this.logger.debug({\n meta: { category: \"config\" },\n message: `Updating environment configuration object: \\n${formatConfig(config)}`\n });\n\n this.environmentConfig = config;\n await this.resolveConfig();\n }\n\n /**\n * Create a new logger instance\n *\n * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public override createLogger(options: LoggerOptions): Logger {\n return super.createLogger({\n ...options,\n environment: this.environmentConfig?.name || this.config.environment?.name\n });\n }\n\n /**\n * Extend the base logger with additional configuration options\n *\n * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.\n * @returns A new logger client instance that extends the base logger with the provided configuration options.\n */\n public override extendLogger(options: LoggerOptions): Logger {\n return super.extendLogger({\n ...options,\n environment: this.environmentConfig?.name || this.config.environment?.name\n });\n }\n\n /**\n * A function used internally to add a plugin to the context and update the configuration options\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public async unstable_addPlugin(\n plugin: PluginConfig<PluginContext<TResolvedConfig, TSystemContext>>\n ): Promise<void> {\n const plugins = await resolvePlugins<TResolvedConfig, TSystemContext>(\n this,\n plugin,\n {\n skipLogging: !!(\n this.environmentConfig?.name &&\n this.environmentConfig.name !== DEFAULT_ENVIRONMENT &&\n this.environmentConfig.name !== GLOBAL_ENVIRONMENT\n )\n }\n );\n for (const plugin of plugins) {\n let resolvedPlugin = plugin as EnvironmentPlugin<\n TResolvedConfig,\n TSystemContext\n >;\n if (isFunction(plugin.applyToEnvironment)) {\n const result = (await Promise.resolve(\n plugin.applyToEnvironment(this.config.environment) as Promise<any>\n )) as\n | boolean\n | PluginConfig<PluginContext<TResolvedConfig, TSystemContext>>;\n\n if (!result || (isObject(result) && Object.keys(result).length === 0)) {\n return;\n }\n\n if (\n isPluginConfig<PluginContext<TResolvedConfig, TSystemContext>>(result)\n ) {\n return this.unstable_addPlugin(result);\n }\n\n resolvedPlugin = (\n isPlugin<PluginContext<TResolvedConfig, TSystemContext>>(result)\n ? result\n : plugin\n ) as EnvironmentPlugin<TResolvedConfig, TSystemContext>;\n }\n\n const id = uuid();\n const context = createPluginContext<TResolvedConfig, TSystemContext>(\n id,\n resolvedPlugin,\n this\n );\n\n resolvedPlugin[\"~internal\"] = {\n id,\n context\n };\n\n this.plugins.push(resolvedPlugin);\n\n this.#hooks = Object.entries(\n Object.keys(resolvedPlugin)\n .filter(\n key =>\n key !== \"~internal\" &&\n !PLUGIN_NON_HOOK_FIELDS.includes(\n key as ArrayValues<typeof PLUGIN_NON_HOOK_FIELDS>\n )\n )\n .reduce(\n (ret, key) =>\n extractHooks<TResolvedConfig, TSystemContext>(\n context,\n ret,\n resolvedPlugin,\n key\n ),\n this.hooks\n )\n ).reduce(\n (ret, [key, value]) => {\n if (isSetObject(value)) {\n Object.entries(value).forEach(([type, list]) => {\n ret[key] ??= {};\n ret[key][type as keyof (typeof ret)[typeof key]] =\n dedupeHooklist<PluginContext<TResolvedConfig, TSystemContext>>(\n list\n );\n });\n }\n\n return ret;\n },\n {} as Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n >\n );\n }\n }\n\n /**\n * Retrieves the hook handlers for a specific hook name\n */\n public selectHooks<TKey extends string>(\n key: TKey,\n options?: SelectHooksOptions\n ): SelectHookResult<PluginContext<TResolvedConfig, TSystemContext>, TKey> {\n const result = [] as SelectHookResult<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >;\n\n if (\n isPluginHookField<PluginContext<TResolvedConfig, TSystemContext>>(key) &&\n this.hooks[key]\n ) {\n if (this.hooks[key]) {\n if (options?.order) {\n const mapHooksToResult = (\n hooksList: HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >[]\n ): SelectHookResult<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n > =>\n hooksList.map(hook => {\n const plugin = this.plugins.find(\n p => p.name === hook.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${\n hook.plugin.name\n }\".`\n );\n }\n\n return {\n handler: hook.handler,\n plugin: hook.plugin,\n context: plugin[\"~internal\"].context\n };\n });\n\n if (options?.order === \"pre\") {\n result.push(...mapHooksToResult(this.hooks[key].preOrdered ?? []));\n result.push(...mapHooksToResult(this.hooks[key].preEnforced ?? []));\n } else if (options?.order === \"post\") {\n result.push(...mapHooksToResult(this.hooks[key].postOrdered ?? []));\n result.push(\n ...mapHooksToResult(this.hooks[key].postEnforced ?? [])\n );\n } else {\n result.push(...mapHooksToResult(this.hooks[key].normal ?? []));\n }\n } else {\n result.push(...this.selectHooks(key, { order: \"pre\" }));\n result.push(...this.selectHooks(key, { order: \"normal\" }));\n result.push(...this.selectHooks(key, { order: \"post\" }));\n }\n }\n }\n\n return result;\n }\n\n /**\n * A function to add a plugin to the context and update the configuration options. This function is used internally when applying plugins to the environment, and it ensures that the plugin is added to the list of plugins in the context and that any hooks or configuration options provided by the plugin are properly integrated into the context's state.\n *\n * @remarks\n * This function is used internally when applying plugins to the environment, and it ensures that the plugin is added to the list of plugins in the context and that any hooks or configuration options provided by the plugin are properly integrated into the context's state. It should not be called directly by external code, as it is intended for internal use only and may be subject to change without warning.\n *\n * @param execution - The execution context for the build process, which provides access to the project configuration, environment, and utility functions for performing the build. The context is used to manage the state and behavior of the build process, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n * @param options - The configuration options for the plugin, which may include properties such as the plugin name, hooks, and any other relevant metadata or settings that should be associated with the plugin when it is added to the context.\n * @param config - The resolved configuration for the environment, which may include properties such as the environment name, SSR settings, and other relevant configuration options that may affect how the plugin is applied to the environment.\n * @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.\n * @returns A promise that resolves when the plugin has been added to the context and the configuration has been updated accordingly.\n */\n protected constructor(\n execution: ExecutionContext<TResolvedConfig, TSystemContext>,\n options: ExecutionOptions,\n config: TResolvedConfig,\n overriddenConfig: InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >\n ) {\n super(options);\n\n this.#execution = execution;\n this.userConfig =\n config.userConfig ?? ({} as TResolvedConfig[\"userConfig\"]);\n this.inlineConfig =\n config.inlineConfig ?? ({} as TResolvedConfig[\"inlineConfig\"]);\n this.pluginConfig = config.pluginConfig ?? {};\n this.overriddenConfig = overriddenConfig;\n }\n\n /**\n * A function to merge the various configuration objects (initial, user, inline, and plugin) into a single resolved configuration object that can be used throughout the Powerlines process. This function takes into account the different sources of configuration and their respective priorities, ensuring that the final configuration reflects the intended settings for the project. The merged configuration is then returned as a new object that can be accessed through the `config` property of the context.\n *\n * @returns The merged configuration object that combines the initial, user, inline, and plugin configurations.\n */\n protected override mergeConfig(): EnvironmentResolvedConfig<TResolvedConfig> {\n return mergeConfig(\n {\n ...omit(this.environmentConfig ?? {}, [\n \"name\",\n \"ssr\",\n \"preview\",\n \"consumer\",\n \"runtime\"\n ]),\n environment: {\n name: this.environmentConfig?.name || DEFAULT_ENVIRONMENT\n },\n environmentConfig: this.environmentConfig ?? {}\n },\n super.mergeConfig()\n ) as EnvironmentResolvedConfig<TResolvedConfig>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2DA,IAAa,+BAAb,MAAa,qCAIH,kBAKV;;;;CAIE,SAGI,CAAC;;;;CAKL;;;;;;;;;;CAWA,aAAoB,KAIlB,WACA,SACA,QACA,kBAGwE;EACxE,MAAM,UAAU,IAAI,6BAGlB,WAAW,SAAS,QAAQ,gBAAgB;EAC9C,MAAM,QAAQ,KAAK;EAEnB,OAAO;CACT;;;;CAKA,AAAmB,oBACjB,CAAC;;;;CAKH,AAAO,UAAgE,CAAC;;;;CAKxE,IAAW,KAAa;EACtB,OAAO,KAAK,OAAO,YAAY;CACjC;;;;CAKA,IAAW,QAGT;EACA,OAAO,KAAKA;CACd;;;;;;;;;CAUA,IAAW,qBAGT;EACA,OAAO,KAAKC;CACd;;;;;;;CAQA,MAAa,qBACX,QACe;EACf,KAAK,OAAO,MAAM;GAChB,MAAM,EAAE,UAAU,SAAS;GAC3B,SAAS,gDAAgD,aAAa,MAAM;EAC9E,CAAC;EAED,KAAK,oBAAoB;EACzB,MAAM,KAAK,cAAc;CAC3B;;;;;;;CAQA,AAAgB,aAAa,SAAgC;EAC3D,OAAO,MAAM,aAAa;GACxB,GAAG;GACH,aAAa,KAAK,mBAAmB,QAAQ,KAAK,OAAO,aAAa;EACxE,CAAC;CACH;;;;;;;CAQA,AAAgB,aAAa,SAAgC;EAC3D,OAAO,MAAM,aAAa;GACxB,GAAG;GACH,aAAa,KAAK,mBAAmB,QAAQ,KAAK,OAAO,aAAa;EACxE,CAAC;CACH;;;;;;;;;CAUA,MAAa,mBACX,QACe;EACf,MAAM,UAAU,MA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AAC;GACD,aAAa,EACX,MAAM,KAAK,mBAAmB,kBAChC;GACA,mBAAmB,KAAK,qBAAqB,CAAC;EAChD,GACA,MAAM,YAAY,CACpB;CACF;AACF"}
|
|
@@ -219,7 +219,7 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends requir
|
|
|
219
219
|
* @internal
|
|
220
220
|
*/
|
|
221
221
|
async unstable_addPlugin(plugin) {
|
|
222
|
-
this.plugins.push(...await require_lib_plugins.resolvePlugins(this, plugin, { skipLogging: Object.keys(this.environments).filter((key) => key !== "default" && key !== "__global__").length > 0 }));
|
|
222
|
+
this.plugins.push(...await require_lib_plugins.resolvePlugins(this, plugin, { skipLogging: Object.keys(this.environments).filter((key) => key && key !== "default" && key !== "__global__").length > 0 }));
|
|
223
223
|
await Promise.all(Object.keys(this.environments).map(async (name) => {
|
|
224
224
|
await this.environments[name].unstable_addPlugin(plugin);
|
|
225
225
|
}));
|
|
@@ -216,7 +216,7 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
216
216
|
* @internal
|
|
217
217
|
*/
|
|
218
218
|
async unstable_addPlugin(plugin) {
|
|
219
|
-
this.plugins.push(...await resolvePlugins(this, plugin, { skipLogging: Object.keys(this.environments).filter((key) => key !== "default" && key !== "__global__").length > 0 }));
|
|
219
|
+
this.plugins.push(...await resolvePlugins(this, plugin, { skipLogging: Object.keys(this.environments).filter((key) => key && key !== "default" && key !== "__global__").length > 0 }));
|
|
220
220
|
await Promise.all(Object.keys(this.environments).map(async (name) => {
|
|
221
221
|
await this.environments[name].unstable_addPlugin(plugin);
|
|
222
222
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-context.mjs","names":["#environments","#plugins"],"sources":["../../src/context/execution-context.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 { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { deepClone } from \"@stryke/helpers/deep-clone\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport chalk from \"chalk\";\nimport {\n DEFAULT_ENVIRONMENT,\n GLOBAL_ENVIRONMENT\n} from \"../constants/environments\";\nimport {\n createDefaultEnvironment,\n createEnvironment\n} from \"../lib/environment\";\nimport { resolvePlugins } from \"../lib/plugins\";\nimport type {\n EnvironmentResolvedConfig,\n ExecutionContext,\n ExecutionOptions,\n InferOverridableConfig,\n Logger,\n LoggerOptions,\n Plugin,\n PluginConfig,\n PluginContext,\n ResolvedConfig\n} from \"../types\";\nimport { PowerlinesContext } from \"./context\";\nimport { PowerlinesEnvironmentContext } from \"./environment-context\";\n\nexport class PowerlinesExecutionContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>\n extends PowerlinesContext<TResolvedConfig, TSystemContext>\n implements ExecutionContext<TResolvedConfig, TSystemContext>\n{\n /**\n * A record of all environments by name\n */\n #environments: Record<\n string,\n PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>\n > = {};\n\n /**\n * The plugins added to this execution context, which may be used to track the plugins that have been added to the context and ensure that they are properly registered and executed during the build process. This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n */\n #plugins: Plugin<PluginContext<TResolvedConfig, TSystemContext>>[] = [];\n\n /**\n * Create a new Storm context from the workspace root and user config.\n *\n * @param options - The execution options to create the context with.\n * @param inlineConfig - The inline configuration for the context.\n * @returns A promise that resolves to the new context.\n */\n public static async from<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n >(\n options: ExecutionOptions,\n inlineConfig?: TResolvedConfig[\"inlineConfig\"],\n system?: TSystemContext\n ): Promise<ExecutionContext<TResolvedConfig, TSystemContext>> {\n const context = new PowerlinesExecutionContext<\n TResolvedConfig,\n TSystemContext\n >(options);\n if (system) {\n context.system = system;\n }\n\n await context.init();\n\n if (inlineConfig) {\n await context.setInlineConfig(inlineConfig);\n }\n\n return context;\n }\n\n /**\n * The unique identifier of the execution context, which can be used for logging and other purposes to distinguish between different executions in the same process.\n */\n public get id(): string {\n return this.options.executionId;\n }\n\n /**\n * A record of all environments by name\n */\n public get environments(): Record<\n string,\n PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>\n > {\n return this.#environments;\n }\n\n public get plugins(): Array<\n Plugin<PluginContext<TResolvedConfig, TSystemContext>>\n > {\n return this.#plugins;\n }\n\n /**\n * Creates a new instance.\n *\n * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.\n */\n protected constructor(options: ExecutionOptions) {\n super(options);\n }\n\n /**\n * A setter function to populate the inline config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the inline configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.\n *\n * @param config - The inline configuration values to set.\n * @returns A promise that resolves when the inline configuration values have been set.\n */\n public override async setInlineConfig(\n config: TResolvedConfig[\"inlineConfig\"]\n ): Promise<void> {\n await super.setInlineConfig(config);\n if (this.inlineConfig.command === \"new\") {\n const workspacePackageJsonPath = joinPaths(this.cwd, \"package.json\");\n if (!existsSync(workspacePackageJsonPath)) {\n throw new Error(\n `The workspace package.json file could not be found at ${workspacePackageJsonPath}`\n );\n }\n\n this.packageJson = await readJsonFile<PackageJson>(\n workspacePackageJsonPath\n );\n }\n }\n\n /**\n * Create a new logger instance\n *\n * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public override createLogger(options: LoggerOptions): Logger {\n return super.createLogger({\n ...options,\n executionId: this.id,\n configIndex: this.options.configIndex\n });\n }\n\n /**\n * Extend the base logger with additional configuration options\n *\n * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.\n * @returns A new logger client instance that extends the base logger with the provided configuration options.\n */\n public override extendLogger(options: LoggerOptions): Logger {\n return super.extendLogger({\n ...options,\n executionId: this.id,\n configIndex: this.options.configIndex\n });\n }\n\n /**\n * A function to copy the context and update the fields for a specific environment\n *\n * @param environment - The environment configuration to use.\n * @returns A new context instance with the updated environment.\n */\n public async createEnvironment(\n environment: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n ): Promise<PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>> {\n const context = await PowerlinesEnvironmentContext.from<\n TResolvedConfig,\n TSystemContext\n >(\n this,\n deepClone(this.options),\n deepClone(this.config) as TResolvedConfig,\n deepClone(this.overriddenConfig) as InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >\n );\n\n context.tsconfig = this.tsconfig;\n context.system = this.system;\n\n context.dependencies = deepClone<typeof this.dependencies>(\n this.dependencies\n );\n context.devDependencies = deepClone<typeof this.devDependencies>(\n this.devDependencies\n );\n context.persistedMeta = deepClone<typeof this.persistedMeta>(\n this.persistedMeta\n );\n context.resolvePatterns = deepClone<typeof this.resolvePatterns>(\n this.resolvePatterns\n );\n\n context.powerlinesPath ??= this.powerlinesPath;\n context.resolver ??= this.resolver;\n\n await context.setEnvironmentConfig(\n deepClone(\n environment\n ) as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n );\n\n context.plugins = [];\n for (const plugin of this.plugins) {\n await context.unstable_addPlugin(plugin);\n }\n\n for (const [key, value] of Object.entries(this)) {\n if (\n ![\n \"fs\",\n \"system\",\n \"options\",\n \"config\",\n \"inlineConfig\",\n \"userConfig\",\n \"pluginConfig\",\n \"overriddenConfig\",\n \"environmentConfig\",\n \"dependencies\",\n \"devDependencies\",\n \"persistedMeta\",\n \"packageJson\",\n \"projectJson\",\n \"tsconfig\",\n \"resolver\",\n \"plugins\",\n \"environments\"\n ].includes(key)\n ) {\n if (isObject(value) || Array.isArray(value)) {\n (context as any)[key] = deepClone(value);\n } else {\n (context as any)[key] = value;\n }\n }\n }\n\n return context;\n }\n\n /**\n * Update the context using a new inline configuration options\n */\n public override async resolveConfig() {\n await super.resolveConfig();\n\n await Promise.all(\n toArray(\n this.config.environments &&\n Object.keys(this.config.environments).length > 0\n ? Object.keys(this.config.environments).map(name =>\n createEnvironment(name, this.config)\n )\n : createDefaultEnvironment(this.config)\n ).map(async env => {\n this.#environments[env.name] = await this.createEnvironment(env);\n })\n );\n }\n\n /**\n * Get an environment by name, or the default environment if no name is provided\n *\n * @param name - The name of the environment to retrieve.\n * @returns The requested environment context.\n */\n public async getEnvironment(name?: string) {\n let environment:\n | PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>\n | undefined;\n if (name) {\n environment = this.environments[name];\n }\n\n if (Object.keys(this.environments).length === 1) {\n environment = this.environments[Object.keys(this.environments)[0]!];\n\n this.trace({\n meta: { category: \"plugins\" },\n message: `Applying the only configured environment: ${chalk.bold.cyanBright(\n environment?.config.environment?.name\n )}`\n });\n }\n\n if (!environment) {\n if (name) {\n throw new Error(`Environment \"${name}\" not found.`);\n }\n\n environment = await this.createEnvironment(\n createDefaultEnvironment(this.config)\n );\n\n this.warn({\n meta: { category: \"plugins\" },\n message: `No environment specified, and no default environment found. Using a temporary default environment: ${chalk.bold.cyanBright(\n environment.config.environment?.name\n )}`\n });\n }\n\n return environment;\n }\n\n /**\n * A safe version of `getEnvironment` that returns `undefined` if the environment is not found\n *\n * @param name - The name of the environment to retrieve.\n * @returns The requested environment context or `undefined` if not found.\n */\n public async getEnvironmentSafe(\n name?: string\n ): Promise<\n PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext> | undefined\n > {\n try {\n return await this.getEnvironment(name);\n } catch {\n return undefined;\n }\n }\n\n /**\n * A function to merge all configured environments into a single context.\n *\n * @remarks\n * If only one environment is configured, that environment will be returned directly.\n *\n * @returns A promise that resolves to a merged/global environment context.\n */\n public async toEnvironment(): Promise<\n PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>\n > {\n let environment: PowerlinesEnvironmentContext<\n TResolvedConfig,\n TSystemContext\n >;\n if (Object.keys(this.environments).length > 1) {\n environment = await this.createEnvironment(\n createEnvironment<TResolvedConfig>(GLOBAL_ENVIRONMENT, this.config)\n );\n\n this.debug({\n meta: { category: \"plugins\" },\n message: `Combined all ${Object.keys(this.environments).length} environments into a single global context.`\n });\n } else {\n environment = await this.getEnvironment();\n }\n\n return environment;\n }\n\n /**\n * A function used internally to add a plugin to the context and update the configuration options\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public async unstable_addPlugin(\n plugin: PluginConfig<PluginContext<TResolvedConfig, TSystemContext>>\n ) {\n this.plugins.push(\n ...(await resolvePlugins<TResolvedConfig, TSystemContext>(this, plugin, {\n skipLogging:\n Object.keys(this.environments).filter(\n key => key !== DEFAULT_ENVIRONMENT && key !== GLOBAL_ENVIRONMENT\n ).length > 0\n }))\n );\n\n await Promise.all(\n Object.keys(this.environments).map(async name => {\n await this.environments[name]!.unstable_addPlugin(plugin);\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAkDA,IAAa,6BAAb,MAAa,mCAIH,kBAEV;;;;CAIE,gBAGI,CAAC;;;;CAKL,WAAqE,CAAC;;;;;;;;CAStE,aAAoB,KAIlB,SACA,cACA,QAC4D;EAC5D,MAAM,UAAU,IAAI,2BAGlB,OAAO;EACT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M,KAAK,kBACvB,yBAAyB,KAAK,MAAM,CACtC;GAEA,KAAK,KAAK;IACR,MAAM,EAAE,UAAU,UAAU;IAC5B,SAAS,sGAAsG,MAAM,KAAK,WACxH,YAAY,OAAO,aAAa,IAClC;GACF,CAAC;EACH;EAEA,OAAO;CACT;;;;;;;CAQA,MAAa,mBACX,MAGA;EACA,IAAI;GACF,OAAO,MAAM,KAAK,eAAe,IAAI;EACvC,QAAQ;GACN;EACF;CACF;;;;;;;;;CAUA,MAAa,gBAEX;EACA,IAAI;EAIJ,IAAI,OAAO,KAAK,KAAK,YAAY,EAAE,SAAS,GAAG;GAC7C,cAAc,MAAM,KAAK,kBACvB,kBAAmC,oBAAoB,KAAK,MAAM,CACpE;GAEA,KAAK,MAAM;IACT,MAAM,EAAE,UAAU,UAAU;IAC5B,SAAS,gBAAgB,OAAO,KAAK,KAAK,YAAY,EAAE,OAAO;GACjE,CAAC;EACH,OACE,cAAc,MAAM,KAAK,eAAe;EAG1C,OAAO;CACT;;;;;;;;;CAUA,MAAa,mBACX,QACA;EACA,KAAK,QAAQ,KACX,GAAI,MAAM,eAAgD,MAAM,QAAQ,EACtE,aACE,OAAO,KAAK,KAAK,YAAY,EAAE,QAC7B,QAAO,qBAA+B,oBACxC,EAAE,SAAS,EACf,CAAC,CACH;EAEA,MAAM,QAAQ,IACZ,OAAO,KAAK,KAAK,YAAY,EAAE,IAAI,OAAM,SAAQ;GAC/C,MAAM,KAAK,aAAa,MAAO,mBAAmB,MAAM;EAC1D,CAAC,CACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"execution-context.mjs","names":["#environments","#plugins"],"sources":["../../src/context/execution-context.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 { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { deepClone } from \"@stryke/helpers/deep-clone\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport chalk from \"chalk\";\nimport {\n DEFAULT_ENVIRONMENT,\n GLOBAL_ENVIRONMENT\n} from \"../constants/environments\";\nimport {\n createDefaultEnvironment,\n createEnvironment\n} from \"../lib/environment\";\nimport { resolvePlugins } from \"../lib/plugins\";\nimport type {\n EnvironmentResolvedConfig,\n ExecutionContext,\n ExecutionOptions,\n InferOverridableConfig,\n Logger,\n LoggerOptions,\n Plugin,\n PluginConfig,\n PluginContext,\n ResolvedConfig\n} from \"../types\";\nimport { PowerlinesContext } from \"./context\";\nimport { PowerlinesEnvironmentContext } from \"./environment-context\";\n\nexport class PowerlinesExecutionContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>\n extends PowerlinesContext<TResolvedConfig, TSystemContext>\n implements ExecutionContext<TResolvedConfig, TSystemContext>\n{\n /**\n * A record of all environments by name\n */\n #environments: Record<\n string,\n PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>\n > = {};\n\n /**\n * The plugins added to this execution context, which may be used to track the plugins that have been added to the context and ensure that they are properly registered and executed during the build process. This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n */\n #plugins: Plugin<PluginContext<TResolvedConfig, TSystemContext>>[] = [];\n\n /**\n * Create a new Storm context from the workspace root and user config.\n *\n * @param options - The execution options to create the context with.\n * @param inlineConfig - The inline configuration for the context.\n * @returns A promise that resolves to the new context.\n */\n public static async from<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n >(\n options: ExecutionOptions,\n inlineConfig?: TResolvedConfig[\"inlineConfig\"],\n system?: TSystemContext\n ): Promise<ExecutionContext<TResolvedConfig, TSystemContext>> {\n const context = new PowerlinesExecutionContext<\n TResolvedConfig,\n TSystemContext\n >(options);\n if (system) {\n context.system = system;\n }\n\n await context.init();\n\n if (inlineConfig) {\n await context.setInlineConfig(inlineConfig);\n }\n\n return context;\n }\n\n /**\n * The unique identifier of the execution context, which can be used for logging and other purposes to distinguish between different executions in the same process.\n */\n public get id(): string {\n return this.options.executionId;\n }\n\n /**\n * A record of all environments by name\n */\n public get environments(): Record<\n string,\n PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>\n > {\n return this.#environments;\n }\n\n public get plugins(): Array<\n Plugin<PluginContext<TResolvedConfig, TSystemContext>>\n > {\n return this.#plugins;\n }\n\n /**\n * Creates a new instance.\n *\n * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.\n */\n protected constructor(options: ExecutionOptions) {\n super(options);\n }\n\n /**\n * A setter function to populate the inline config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the inline configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.\n *\n * @param config - The inline configuration values to set.\n * @returns A promise that resolves when the inline configuration values have been set.\n */\n public override async setInlineConfig(\n config: TResolvedConfig[\"inlineConfig\"]\n ): Promise<void> {\n await super.setInlineConfig(config);\n if (this.inlineConfig.command === \"new\") {\n const workspacePackageJsonPath = joinPaths(this.cwd, \"package.json\");\n if (!existsSync(workspacePackageJsonPath)) {\n throw new Error(\n `The workspace package.json file could not be found at ${workspacePackageJsonPath}`\n );\n }\n\n this.packageJson = await readJsonFile<PackageJson>(\n workspacePackageJsonPath\n );\n }\n }\n\n /**\n * Create a new logger instance\n *\n * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public override createLogger(options: LoggerOptions): Logger {\n return super.createLogger({\n ...options,\n executionId: this.id,\n configIndex: this.options.configIndex\n });\n }\n\n /**\n * Extend the base logger with additional configuration options\n *\n * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.\n * @returns A new logger client instance that extends the base logger with the provided configuration options.\n */\n public override extendLogger(options: LoggerOptions): Logger {\n return super.extendLogger({\n ...options,\n executionId: this.id,\n configIndex: this.options.configIndex\n });\n }\n\n /**\n * A function to copy the context and update the fields for a specific environment\n *\n * @param environment - The environment configuration to use.\n * @returns A new context instance with the updated environment.\n */\n public async createEnvironment(\n environment: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n ): Promise<PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>> {\n const context = await PowerlinesEnvironmentContext.from<\n TResolvedConfig,\n TSystemContext\n >(\n this,\n deepClone(this.options),\n deepClone(this.config) as TResolvedConfig,\n deepClone(this.overriddenConfig) as InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >\n );\n\n context.tsconfig = this.tsconfig;\n context.system = this.system;\n\n context.dependencies = deepClone<typeof this.dependencies>(\n this.dependencies\n );\n context.devDependencies = deepClone<typeof this.devDependencies>(\n this.devDependencies\n );\n context.persistedMeta = deepClone<typeof this.persistedMeta>(\n this.persistedMeta\n );\n context.resolvePatterns = deepClone<typeof this.resolvePatterns>(\n this.resolvePatterns\n );\n\n context.powerlinesPath ??= this.powerlinesPath;\n context.resolver ??= this.resolver;\n\n await context.setEnvironmentConfig(\n deepClone(\n environment\n ) as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n );\n\n context.plugins = [];\n for (const plugin of this.plugins) {\n await context.unstable_addPlugin(plugin);\n }\n\n for (const [key, value] of Object.entries(this)) {\n if (\n ![\n \"fs\",\n \"system\",\n \"options\",\n \"config\",\n \"inlineConfig\",\n \"userConfig\",\n \"pluginConfig\",\n \"overriddenConfig\",\n \"environmentConfig\",\n \"dependencies\",\n \"devDependencies\",\n \"persistedMeta\",\n \"packageJson\",\n \"projectJson\",\n \"tsconfig\",\n \"resolver\",\n \"plugins\",\n \"environments\"\n ].includes(key)\n ) {\n if (isObject(value) || Array.isArray(value)) {\n (context as any)[key] = deepClone(value);\n } else {\n (context as any)[key] = value;\n }\n }\n }\n\n return context;\n }\n\n /**\n * Update the context using a new inline configuration options\n */\n public override async resolveConfig() {\n await super.resolveConfig();\n\n await Promise.all(\n toArray(\n this.config.environments &&\n Object.keys(this.config.environments).length > 0\n ? Object.keys(this.config.environments).map(name =>\n createEnvironment(name, this.config)\n )\n : createDefaultEnvironment(this.config)\n ).map(async env => {\n this.#environments[env.name] = await this.createEnvironment(env);\n })\n );\n }\n\n /**\n * Get an environment by name, or the default environment if no name is provided\n *\n * @param name - The name of the environment to retrieve.\n * @returns The requested environment context.\n */\n public async getEnvironment(name?: string) {\n let environment:\n | PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>\n | undefined;\n if (name) {\n environment = this.environments[name];\n }\n\n if (Object.keys(this.environments).length === 1) {\n environment = this.environments[Object.keys(this.environments)[0]!];\n\n this.trace({\n meta: { category: \"plugins\" },\n message: `Applying the only configured environment: ${chalk.bold.cyanBright(\n environment?.config.environment?.name\n )}`\n });\n }\n\n if (!environment) {\n if (name) {\n throw new Error(`Environment \"${name}\" not found.`);\n }\n\n environment = await this.createEnvironment(\n createDefaultEnvironment(this.config)\n );\n\n this.warn({\n meta: { category: \"plugins\" },\n message: `No environment specified, and no default environment found. Using a temporary default environment: ${chalk.bold.cyanBright(\n environment.config.environment?.name\n )}`\n });\n }\n\n return environment;\n }\n\n /**\n * A safe version of `getEnvironment` that returns `undefined` if the environment is not found\n *\n * @param name - The name of the environment to retrieve.\n * @returns The requested environment context or `undefined` if not found.\n */\n public async getEnvironmentSafe(\n name?: string\n ): Promise<\n PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext> | undefined\n > {\n try {\n return await this.getEnvironment(name);\n } catch {\n return undefined;\n }\n }\n\n /**\n * A function to merge all configured environments into a single context.\n *\n * @remarks\n * If only one environment is configured, that environment will be returned directly.\n *\n * @returns A promise that resolves to a merged/global environment context.\n */\n public async toEnvironment(): Promise<\n PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>\n > {\n let environment: PowerlinesEnvironmentContext<\n TResolvedConfig,\n TSystemContext\n >;\n if (Object.keys(this.environments).length > 1) {\n environment = await this.createEnvironment(\n createEnvironment<TResolvedConfig>(GLOBAL_ENVIRONMENT, this.config)\n );\n\n this.debug({\n meta: { category: \"plugins\" },\n message: `Combined all ${Object.keys(this.environments).length} environments into a single global context.`\n });\n } else {\n environment = await this.getEnvironment();\n }\n\n return environment;\n }\n\n /**\n * A function used internally to add a plugin to the context and update the configuration options\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public async unstable_addPlugin(\n plugin: PluginConfig<PluginContext<TResolvedConfig, TSystemContext>>\n ) {\n this.plugins.push(\n ...(await resolvePlugins<TResolvedConfig, TSystemContext>(this, plugin, {\n skipLogging:\n Object.keys(this.environments).filter(\n key =>\n key && key !== DEFAULT_ENVIRONMENT && key !== GLOBAL_ENVIRONMENT\n ).length > 0\n }))\n );\n\n await Promise.all(\n Object.keys(this.environments).map(async name => {\n await this.environments[name]!.unstable_addPlugin(plugin);\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAkDA,IAAa,6BAAb,MAAa,mCAIH,kBAEV;;;;CAIE,gBAGI,CAAC;;;;CAKL,WAAqE,CAAC;;;;;;;;CAStE,aAAoB,KAIlB,SACA,cACA,QAC4D;EAC5D,MAAM,UAAU,IAAI,2BAGlB,OAAO;EACT,IAAI,QACF,QAAQ,SAAS;EAGnB,MAAM,QAAQ,KAAK;EAEnB,IAA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R,MAAM,EAAE,UAAU,UAAU;IAC5B,SAAS,sGAAsG,MAAM,KAAK,WACxH,YAAY,OAAO,aAAa,IAClC;GACF,CAAC;EACH;EAEA,OAAO;CACT;;;;;;;CAQA,MAAa,mBACX,MAGA;EACA,IAAI;GACF,OAAO,MAAM,KAAK,eAAe,IAAI;EACvC,QAAQ;GACN;EACF;CACF;;;;;;;;;CAUA,MAAa,gBAEX;EACA,IAAI;EAIJ,IAAI,OAAO,KAAK,KAAK,YAAY,EAAE,SAAS,GAAG;GAC7C,cAAc,MAAM,KAAK,kBACvB,kBAAmC,oBAAoB,KAAK,MAAM,CACpE;GAEA,KAAK,MAAM;IACT,MAAM,EAAE,UAAU,UAAU;IAC5B,SAAS,gBAAgB,OAAO,KAAK,KAAK,YAAY,EAAE,OAAO;GACjE,CAAC;EACH,OACE,cAAc,MAAM,KAAK,eAAe;EAG1C,OAAO;CACT;;;;;;;;;CAUA,MAAa,mBACX,QACA;EACA,KAAK,QAAQ,KACX,GAAI,MAAM,eAAgD,MAAM,QAAQ,EACtE,aACE,OAAO,KAAK,KAAK,YAAY,EAAE,QAC7B,QACE,OAAO,qBAA+B,oBAC1C,EAAE,SAAS,EACf,CAAC,CACH;EAEA,MAAM,QAAQ,IACZ,OAAO,KAAK,KAAK,YAAY,EAAE,IAAI,OAAM,SAAQ;GAC/C,MAAM,KAAK,aAAa,MAAO,mBAAmB,MAAM;EAC1D,CAAC,CACH;CACF;AACF"}
|
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ import { CallHookOptions, HookListOrders, HooksList, HooksListItem, InferHookFun
|
|
|
6
6
|
import { CustomLogger, CustomLoggerMessage, LogCategory, LogFn, LogFnMeta, LogFnOptions, LogLevel, LogLevelResolvedConfig, LogLevelUserConfig, LogMessage, LogMeta, Logger, LoggerMessage, LoggerMeta, LoggerOptions, PowerlinesMessage } from "./types/logging.cjs";
|
|
7
7
|
import { DeepkitOptions, Level, ParsedTypeScriptConfig, RawReflectionMode, ReflectionMode, TSCompilerOptions, TSConfig } from "./types/tsconfig.cjs";
|
|
8
8
|
import { BaseContext, BuildPluginContext, Context, EmitEntryOptions, EmitOptions, EnvironmentContext, EnvironmentPlugin, ExecutionContext, FetchOptions, InitContextOptions, MetaInfo, ParseOptions, PluginContext, ResolveResult, Resolver, SelectHookResult, SelectHookResultItem, SelectHooksOptions, SourceFile, TransformResult, UnimportContext, UnresolvedContext, WithUnpluginBuildContext } from "./types/context.cjs";
|
|
9
|
-
import {
|
|
9
|
+
import { BaseExecutionOptions, BuildInlineConfig, CleanInlineConfig, Config, ConfigParams, CopyConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, EnvironmentConfig, EnvironmentResolvedConfig, ExecutionOptions, FrameworkOptions, InferOverridableConfig, InlineConfig, InlineConfigPaths, LintInlineConfig, Mode, Options, OutputConfig, ParsedUserConfig, PartialPlugin, PartialPluginFactory, PluginConfig, PluginConfigObject, PluginConfigTuple, PluginFactory, PrepareInlineConfig, ProjectType, ResolveConfig, ResolvedAssetGlob, ResolvedConfig, ResolvedCopyConfig, ResolvedEntryTypeDefinition, ResolvedEnvironmentConfig, ResolvedOutputConfig, ResolvedResolveConfig, TestInlineConfig, TypesInlineConfig, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnObject, UserConfigFnPromise, UserInputConfig, WorkspaceConfig } from "./types/config.cjs";
|
|
10
10
|
import { PartiallyResolvedContext, ResolvePackageConfigsResult, defineConfig, getDefaultLogLevel, getDefaultMode, loadParsedConfig, loadUserConfigFile, loadWorkspaceConfig, normalizeBasePath, resolvePackageConfigs, resolveRoot, tryResolveWorkspaceConfig } from "./lib/config.cjs";
|
|
11
11
|
import { getConfigProps, resolvePluginConfig } from "./lib/context-helpers.cjs";
|
|
12
12
|
import { getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync } from "./lib/entry.cjs";
|
|
@@ -30,4 +30,4 @@ import { getMagicString, getSourceFile, getString } from "./lib/utilities/source
|
|
|
30
30
|
import { generateSourceMap } from "./lib/utilities/source-map.cjs";
|
|
31
31
|
import { writeFile } from "./lib/utilities/write-file.cjs";
|
|
32
32
|
import { VirtualFileSystem } from "./lib/vfs.cjs";
|
|
33
|
-
export {
|
|
33
|
+
export { BaseCommandType, BaseContext, BaseExecutionAPIMethods, BaseExecutionOptions, BasePlugin, BufferedChunk, BuildInlineConfig, BuildPluginContext, BuilderVariant, CallHookOptions, CleanInlineConfig, CommandType, Commands, Config, ConfigParams, Context, CopyConfig, CreateContextOptions, CreateInlineConfig, CreateResolverOptions, CreateStreamReaderOptions, CreateStreamSinkOptions, CreateUnpluginModuleResolutionFunctionsOptions, CreateUnpluginOptions, CreateUnpluginResolverOptions, CustomLogger, CustomLoggerMessage, DeepkitOptions, DeployInlineConfig, DocsInlineConfig, EmitEntryOptions, EmitOptions, EnvironmentConfig, EnvironmentContext, EnvironmentPlugin, EnvironmentResolvedConfig, ExecutionContext, ExecutionOptions, FetchOptions, FileHeaderOptions, FileId, FileMetadata, FileMetadata_KeyValuePair, FileStorage, FileSystem, FrameworkOptions, HookFunctions, HookListOrders, Hooks, HooksList, HooksListItem, InferHookFunction, InferHookParameters, InferHookReturnType, InferHookThisType, InferOverridableConfig, InitContextOptions, InlineConfig, InlineConfigPaths, Level, LintInlineConfig, LogCategory, LogFn, LogFnMeta, LogFnOptions, LogLevel, LogLevelResolvedConfig, LogLevelUserConfig, LogMessage, LogMeta, Logger, LoggerMessage, LoggerMeta, LoggerOptions, MetaInfo, Mode, NormalizedStringFilter, Options, OutputConfig, ParseOptions, ParsedTypeScriptConfig, ParsedUserConfig, PartialPlugin, PartialPluginFactory, PartiallyResolvedContext, Plugin, PluginConfig, PluginConfigObject, PluginConfigTuple, PluginContext, PluginFactory, PluginFilter, PluginHook, PluginHookFields, PluginHookObject, PluginHooks, PluginNonHookFields, PowerlinesExecutionAPIMethods, PowerlinesMessage, PrepareInlineConfig, ProjectType, RawReflectionMode, ReflectionMode, ResolveConfig, ResolveOptions, ResolvePackageConfigsResult, ResolvePluginsOptions, ResolveResult, ResolvedAssetGlob, ResolvedConfig, ResolvedCopyConfig, ResolvedEntryTypeDefinition, ResolvedEnvironmentConfig, ResolvedOutputConfig, ResolvedResolveConfig, Resolver, SelectHookResult, SelectHookResultItem, SelectHooksOptions, SourceFile, StorageAdapter, StoragePort, StoragePreset, StreamErrorPayload, StreamReader, StreamSink, StreamSinkEvents, SupportedCommands, TSCompilerOptions, TSConfig, TestInlineConfig, TransformHookFilter, TransformResult, TypegenContext, TypesInlineConfig, TypesResult, UnimportContext, UnpluginBuilderVariant, UnpluginHookFunctions, UnpluginOptions, UnresolvedContext, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnObject, UserConfigFnPromise, UserInputConfig, VirtualFile, VirtualFileData, VirtualFileExtension, VirtualFileMetadata, VirtualFileSystem, VirtualFileSystemHost, VirtualFileSystemInterface, WithUnpluginBuildContext, WorkspaceConfig, WriteData, WriteOptions, _capnpFileId, callHook, combineContexts, createEventEmitter, createProgram, createResolver, createStreamReader, createStreamSink, createUnplugin, createUnpluginModuleResolutionFunctions, createUnpluginResolver, defineConfig, emitBuiltinTypes, extractHooks, findIncludeMatch, findMatch, format, formatFolder, formatTypes, generateSourceMap, getConfigProps, getDefaultLogLevel, getDefaultMode, getFileHeader, getFileHeaderWarning, getFileHeaderWarningText, getMagicString, getParsedTypeScriptConfig, getPersistedMeta, getPrefixedRootHash, getSourceFile, getString, getTsconfigDtsPath, getTsconfigFilePath, getTypescriptFileHeader, getUniqueInputs, handleTypes, initPlugin, initializeTsconfig, installDependencies, isIncludeMatchFound, isMatchFound, isResolvedEntryTypeDefinition, isTypeDefinition, isUnpluginBuilderVariant, loadParsedConfig, loadUserConfigFile, loadWorkspaceConfig, mergeConfigs, mergeResults, normalizeBasePath, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, resolvePackageConfigs, resolvePlugin, resolvePluginConfig, resolvePlugins, resolveRoot, resolveTsconfig, tryResolveWorkspaceConfig, tryTsconfigFilePath, writeFile, writeMetaFile };
|
package/dist/index.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ import { CallHookOptions, HookListOrders, HooksList, HooksListItem, InferHookFun
|
|
|
6
6
|
import { CustomLogger, CustomLoggerMessage, LogCategory, LogFn, LogFnMeta, LogFnOptions, LogLevel, LogLevelResolvedConfig, LogLevelUserConfig, LogMessage, LogMeta, Logger, LoggerMessage, LoggerMeta, LoggerOptions, PowerlinesMessage } from "./types/logging.mjs";
|
|
7
7
|
import { DeepkitOptions, Level, ParsedTypeScriptConfig, RawReflectionMode, ReflectionMode, TSCompilerOptions, TSConfig } from "./types/tsconfig.mjs";
|
|
8
8
|
import { BaseContext, BuildPluginContext, Context, EmitEntryOptions, EmitOptions, EnvironmentContext, EnvironmentPlugin, ExecutionContext, FetchOptions, InitContextOptions, MetaInfo, ParseOptions, PluginContext, ResolveResult, Resolver, SelectHookResult, SelectHookResultItem, SelectHooksOptions, SourceFile, TransformResult, UnimportContext, UnresolvedContext, WithUnpluginBuildContext } from "./types/context.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { BaseExecutionOptions, BuildInlineConfig, CleanInlineConfig, Config, ConfigParams, CopyConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, EnvironmentConfig, EnvironmentResolvedConfig, ExecutionOptions, FrameworkOptions, InferOverridableConfig, InlineConfig, InlineConfigPaths, LintInlineConfig, Mode, Options, OutputConfig, ParsedUserConfig, PartialPlugin, PartialPluginFactory, PluginConfig, PluginConfigObject, PluginConfigTuple, PluginFactory, PrepareInlineConfig, ProjectType, ResolveConfig, ResolvedAssetGlob, ResolvedConfig, ResolvedCopyConfig, ResolvedEntryTypeDefinition, ResolvedEnvironmentConfig, ResolvedOutputConfig, ResolvedResolveConfig, TestInlineConfig, TypesInlineConfig, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnObject, UserConfigFnPromise, UserInputConfig, WorkspaceConfig } from "./types/config.mjs";
|
|
10
10
|
import { PartiallyResolvedContext, ResolvePackageConfigsResult, defineConfig, getDefaultLogLevel, getDefaultMode, loadParsedConfig, loadUserConfigFile, loadWorkspaceConfig, normalizeBasePath, resolvePackageConfigs, resolveRoot, tryResolveWorkspaceConfig } from "./lib/config.mjs";
|
|
11
11
|
import { getConfigProps, resolvePluginConfig } from "./lib/context-helpers.mjs";
|
|
12
12
|
import { getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync } from "./lib/entry.mjs";
|
|
@@ -30,4 +30,4 @@ import { getMagicString, getSourceFile, getString } from "./lib/utilities/source
|
|
|
30
30
|
import { generateSourceMap } from "./lib/utilities/source-map.mjs";
|
|
31
31
|
import { writeFile } from "./lib/utilities/write-file.mjs";
|
|
32
32
|
import { VirtualFileSystem } from "./lib/vfs.mjs";
|
|
33
|
-
export {
|
|
33
|
+
export { BaseCommandType, BaseContext, BaseExecutionAPIMethods, BaseExecutionOptions, BasePlugin, BufferedChunk, BuildInlineConfig, BuildPluginContext, BuilderVariant, CallHookOptions, CleanInlineConfig, CommandType, Commands, Config, ConfigParams, Context, CopyConfig, CreateContextOptions, CreateInlineConfig, CreateResolverOptions, CreateStreamReaderOptions, CreateStreamSinkOptions, CreateUnpluginModuleResolutionFunctionsOptions, CreateUnpluginOptions, CreateUnpluginResolverOptions, CustomLogger, CustomLoggerMessage, DeepkitOptions, DeployInlineConfig, DocsInlineConfig, EmitEntryOptions, EmitOptions, EnvironmentConfig, EnvironmentContext, EnvironmentPlugin, EnvironmentResolvedConfig, ExecutionContext, ExecutionOptions, FetchOptions, FileHeaderOptions, FileId, FileMetadata, FileMetadata_KeyValuePair, FileStorage, FileSystem, FrameworkOptions, HookFunctions, HookListOrders, Hooks, HooksList, HooksListItem, InferHookFunction, InferHookParameters, InferHookReturnType, InferHookThisType, InferOverridableConfig, InitContextOptions, InlineConfig, InlineConfigPaths, Level, LintInlineConfig, LogCategory, LogFn, LogFnMeta, LogFnOptions, LogLevel, LogLevelResolvedConfig, LogLevelUserConfig, LogMessage, LogMeta, Logger, LoggerMessage, LoggerMeta, LoggerOptions, MetaInfo, Mode, NormalizedStringFilter, Options, OutputConfig, ParseOptions, ParsedTypeScriptConfig, ParsedUserConfig, PartialPlugin, PartialPluginFactory, PartiallyResolvedContext, Plugin, PluginConfig, PluginConfigObject, PluginConfigTuple, PluginContext, PluginFactory, PluginFilter, PluginHook, PluginHookFields, PluginHookObject, PluginHooks, PluginNonHookFields, PowerlinesExecutionAPIMethods, PowerlinesMessage, PrepareInlineConfig, ProjectType, RawReflectionMode, ReflectionMode, ResolveConfig, ResolveOptions, ResolvePackageConfigsResult, ResolvePluginsOptions, ResolveResult, ResolvedAssetGlob, ResolvedConfig, ResolvedCopyConfig, ResolvedEntryTypeDefinition, ResolvedEnvironmentConfig, ResolvedOutputConfig, ResolvedResolveConfig, Resolver, SelectHookResult, SelectHookResultItem, SelectHooksOptions, SourceFile, StorageAdapter, StoragePort, StoragePreset, StreamErrorPayload, StreamReader, StreamSink, StreamSinkEvents, SupportedCommands, TSCompilerOptions, TSConfig, TestInlineConfig, TransformHookFilter, TransformResult, TypegenContext, TypesInlineConfig, TypesResult, UnimportContext, UnpluginBuilderVariant, UnpluginHookFunctions, UnpluginOptions, UnresolvedContext, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnObject, UserConfigFnPromise, UserInputConfig, VirtualFile, VirtualFileData, VirtualFileExtension, VirtualFileMetadata, VirtualFileSystem, VirtualFileSystemHost, VirtualFileSystemInterface, WithUnpluginBuildContext, WorkspaceConfig, WriteData, WriteOptions, _capnpFileId, callHook, combineContexts, createEventEmitter, createProgram, createResolver, createStreamReader, createStreamSink, createUnplugin, createUnpluginModuleResolutionFunctions, createUnpluginResolver, defineConfig, emitBuiltinTypes, extractHooks, findIncludeMatch, findMatch, format, formatFolder, formatTypes, generateSourceMap, getConfigProps, getDefaultLogLevel, getDefaultMode, getFileHeader, getFileHeaderWarning, getFileHeaderWarningText, getMagicString, getParsedTypeScriptConfig, getPersistedMeta, getPrefixedRootHash, getSourceFile, getString, getTsconfigDtsPath, getTsconfigFilePath, getTypescriptFileHeader, getUniqueInputs, handleTypes, initPlugin, initializeTsconfig, installDependencies, isIncludeMatchFound, isMatchFound, isResolvedEntryTypeDefinition, isTypeDefinition, isUnpluginBuilderVariant, loadParsedConfig, loadUserConfigFile, loadWorkspaceConfig, mergeConfigs, mergeResults, normalizeBasePath, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, resolvePackageConfigs, resolvePlugin, resolvePluginConfig, resolvePlugins, resolveRoot, resolveTsconfig, tryResolveWorkspaceConfig, tryTsconfigFilePath, writeFile, writeMetaFile };
|
package/dist/lib/config.cjs
CHANGED
|
@@ -209,12 +209,6 @@ async function loadUserConfigFile(cwd, root, mode, command, framework, configFil
|
|
|
209
209
|
...result
|
|
210
210
|
} : {});
|
|
211
211
|
}
|
|
212
|
-
/**
|
|
213
|
-
* A type helper to make it easier to use `powerlines.config.ts` files.
|
|
214
|
-
*
|
|
215
|
-
* @remarks
|
|
216
|
-
* The function accepts a direct {@link AnyUserConfig} object/function and returns it typed as a {@link UserConfig} object.
|
|
217
|
-
*/
|
|
218
212
|
function defineConfig(config) {
|
|
219
213
|
return config;
|
|
220
214
|
}
|
package/dist/lib/config.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogLevelResolvedConfig } from "../types/logging.cjs";
|
|
2
2
|
import { Context } from "../types/context.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { FrameworkOptions, InlineConfig, Mode, ParsedUserConfig, UserConfigExport, UserConfigFn, UserConfigFnObject, UserConfigFnPromise, UserInputConfig, WorkspaceConfig } from "../types/config.cjs";
|
|
4
4
|
import { PartialKeys } from "@stryke/types/base";
|
|
5
5
|
import { PackageJson } from "@stryke/types/package-json";
|
|
6
6
|
|
|
@@ -108,12 +108,33 @@ declare function loadWorkspaceConfig(cwd: string, root: string): Promise<Workspa
|
|
|
108
108
|
*/
|
|
109
109
|
declare function loadUserConfigFile(cwd: string, root: string, mode: Mode, command: string, framework?: PartialKeys<FrameworkOptions, "orgId">, configFile?: string): Promise<ParsedUserConfig>;
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
111
|
+
* Type helper to make it easier to use `powerlines.config.ts` files. Accepts a direct {@link UserConfig} object, or a function that returns it. The function receives a {@link ConfigParams} object.
|
|
112
112
|
*
|
|
113
|
-
* @
|
|
114
|
-
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { defineConfig } from 'powerlines';
|
|
116
|
+
*
|
|
117
|
+
* export default defineConfig({
|
|
118
|
+
* // Your configuration here
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* // Or with a function
|
|
122
|
+
* export default defineConfig((env) => {
|
|
123
|
+
* console.log(`Running command: ${env.command} in mode: ${env.mode}`);
|
|
124
|
+
* return {
|
|
125
|
+
* // Your configuration here
|
|
126
|
+
* };
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
115
129
|
*/
|
|
116
|
-
declare function defineConfig(config:
|
|
130
|
+
declare function defineConfig(config: UserInputConfig): UserInputConfig;
|
|
131
|
+
declare function defineConfig(config: UserInputConfig[]): UserInputConfig[];
|
|
132
|
+
declare function defineConfig(config: Promise<UserInputConfig>): Promise<UserInputConfig>;
|
|
133
|
+
declare function defineConfig(config: Promise<UserInputConfig[]>): Promise<UserInputConfig[]>;
|
|
134
|
+
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
135
|
+
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
|
136
|
+
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
|
137
|
+
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
117
138
|
//#endregion
|
|
118
139
|
export { PartiallyResolvedContext, ResolvePackageConfigsResult, defineConfig, getDefaultLogLevel, getDefaultMode, loadParsedConfig, loadUserConfigFile, loadWorkspaceConfig, normalizeBasePath, resolvePackageConfigs, resolveRoot, tryResolveWorkspaceConfig };
|
|
119
140
|
//# sourceMappingURL=config.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/lib/config.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/lib/config.ts"],"mappings":";;;;;;;iBA4DgB,iBAAA,CAAkB,IAAkB;AAAA,UAMnC,2BAAA;EAND;;;EAUd,WAAA,GAAc,WAAA;EAVoC;AAMpD;;EASE,WAAA,GAAc,MAAM;AAAA;;;;;;AAAA;AAatB;;;;iBAAsB,qBAAA,CACpB,GAAA,UACA,IAAA,WACC,OAAO,CAAC,2BAAA;;;;;AAA2B;AA+BtC;;;iBAAgB,WAAA,CACd,GAAA,UACA,IAAA,WACA,UAAA;;;;;AAAmB;AAmCrB;;iBAAsB,yBAAA,CACpB,GAAA,UACA,IAAA,YACC,OAAO,CAAC,eAAA;;;;;;;AAAe;AAiB1B;;;iBAAsB,cAAA,CACpB,GAAA,UACA,IAAA,YACC,OAAO,CAAC,IAAA;;;;;;AAAI;AAsBf;;;;iBAAsB,kBAAA,CACpB,GAAA,UACA,IAAA,YACC,OAAO,CAAC,sBAAA;;;;;AAAsB;AAgCjC;;;;;;;;;iBAAsB,gBAAA,CACpB,GAAA,UACA,IAAA,UACA,SAAA,UACA,KAAA,UACA,YAAA,EAAc,YAAA,GAAY,OAAA,CAAA,gBAAA;AAAA,KAwBhB,wBAAA,kBAA0C,OAAA,GAAU,OAAA,IAAW,IAAA,CACzE,QAAA,sEAGA,OAAA,CAAQ,QAAA;EACN,MAAA,EAAQ,QAAA;AAAA;;;;;AA7BgB;AAwB5B;;iBAesB,mBAAA,CACpB,GAAA,UACA,IAAA,WACC,OAAO,CAAC,eAAA;;;;;;;;;;;;;;;iBA2BW,kBAAA,CACpB,GAAA,UACA,IAAA,UACA,IAAA,EAAM,IAAA,EACN,OAAA,UACA,SAAA,GAAY,WAAA,CAAY,gBAAA,YACxB,UAAA,YACC,OAAA,CAAQ,gBAAA;;;;;AA/CS;AAUpB;;;;;;;;;AAG0B;AA2B1B;;;;;iBA+KgB,YAAA,CAAa,MAAA,EAAQ,eAAA,GAAkB,eAAe;AAAA,iBACtD,YAAA,CAAa,MAAA,EAAQ,eAAA,KAAoB,eAAe;AAAA,iBACxD,YAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,eAAA,IACf,OAAA,CAAQ,eAAA;AAAA,iBACK,YAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,eAAA,MACf,OAAA,CAAQ,eAAA;AAAA,iBACK,YAAA,CAAa,MAAA,EAAQ,kBAAA,GAAqB,kBAAkB;AAAA,iBAC5D,YAAA,CAAa,MAAA,EAAQ,mBAAA,GAAsB,mBAAmB;AAAA,iBAC9D,YAAA,CAAa,MAAA,EAAQ,YAAA,GAAe,YAAY;AAAA,iBAChD,YAAA,CAAa,MAAA,EAAQ,gBAAA,GAAmB,gBAAgB"}
|
package/dist/lib/config.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogLevelResolvedConfig } from "../types/logging.mjs";
|
|
2
2
|
import { Context } from "../types/context.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { FrameworkOptions, InlineConfig, Mode, ParsedUserConfig, UserConfigExport, UserConfigFn, UserConfigFnObject, UserConfigFnPromise, UserInputConfig, WorkspaceConfig } from "../types/config.mjs";
|
|
4
4
|
import { PartialKeys } from "@stryke/types/base";
|
|
5
5
|
import { PackageJson } from "@stryke/types/package-json";
|
|
6
6
|
|
|
@@ -108,12 +108,33 @@ declare function loadWorkspaceConfig(cwd: string, root: string): Promise<Workspa
|
|
|
108
108
|
*/
|
|
109
109
|
declare function loadUserConfigFile(cwd: string, root: string, mode: Mode, command: string, framework?: PartialKeys<FrameworkOptions, "orgId">, configFile?: string): Promise<ParsedUserConfig>;
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
111
|
+
* Type helper to make it easier to use `powerlines.config.ts` files. Accepts a direct {@link UserConfig} object, or a function that returns it. The function receives a {@link ConfigParams} object.
|
|
112
112
|
*
|
|
113
|
-
* @
|
|
114
|
-
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { defineConfig } from 'powerlines';
|
|
116
|
+
*
|
|
117
|
+
* export default defineConfig({
|
|
118
|
+
* // Your configuration here
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* // Or with a function
|
|
122
|
+
* export default defineConfig((env) => {
|
|
123
|
+
* console.log(`Running command: ${env.command} in mode: ${env.mode}`);
|
|
124
|
+
* return {
|
|
125
|
+
* // Your configuration here
|
|
126
|
+
* };
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
115
129
|
*/
|
|
116
|
-
declare function defineConfig(config:
|
|
130
|
+
declare function defineConfig(config: UserInputConfig): UserInputConfig;
|
|
131
|
+
declare function defineConfig(config: UserInputConfig[]): UserInputConfig[];
|
|
132
|
+
declare function defineConfig(config: Promise<UserInputConfig>): Promise<UserInputConfig>;
|
|
133
|
+
declare function defineConfig(config: Promise<UserInputConfig[]>): Promise<UserInputConfig[]>;
|
|
134
|
+
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
135
|
+
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
|
136
|
+
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
|
137
|
+
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
117
138
|
//#endregion
|
|
118
139
|
export { PartiallyResolvedContext, ResolvePackageConfigsResult, defineConfig, getDefaultLogLevel, getDefaultMode, loadParsedConfig, loadUserConfigFile, loadWorkspaceConfig, normalizeBasePath, resolvePackageConfigs, resolveRoot, tryResolveWorkspaceConfig };
|
|
119
140
|
//# sourceMappingURL=config.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/lib/config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GAAkB,eAAe;AAAA,iBACtD,YAAA,CAAa,MAAA,EAAQ,eAAA,KAAoB,eAAe;AAAA,iBACxD,YAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,eAAA,IACf,OAAA,CAAQ,eAAA;AAAA,iBACK,YAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,eAAA,MACf,OAAA,CAAQ,eAAA;AAAA,iBACK,YAAA,CAAa,MAAA,EAAQ,kBAAA,GAAqB,kBAAkB;AAAA,iBAC5D,YAAA,CAAa,MAAA,EAAQ,mBAAA,GAAsB,mBAAmB;AAAA,iBAC9D,YAAA,CAAa,MAAA,EAAQ,YAAA,GAAe,YAAY;AAAA,iBAChD,YAAA,CAAa,MAAA,EAAQ,gBAAA,GAAmB,gBAAgB"}
|
package/dist/lib/config.mjs
CHANGED
|
@@ -206,12 +206,6 @@ async function loadUserConfigFile(cwd, root, mode, command, framework, configFil
|
|
|
206
206
|
...result
|
|
207
207
|
} : {});
|
|
208
208
|
}
|
|
209
|
-
/**
|
|
210
|
-
* A type helper to make it easier to use `powerlines.config.ts` files.
|
|
211
|
-
*
|
|
212
|
-
* @remarks
|
|
213
|
-
* The function accepts a direct {@link AnyUserConfig} object/function and returns it typed as a {@link UserConfig} object.
|
|
214
|
-
*/
|
|
215
209
|
function defineConfig(config) {
|
|
216
210
|
return config;
|
|
217
211
|
}
|