@rushstack/heft
Advanced tools
Comparing version 0.48.0-dev.0 to 0.48.0-dev.1
@@ -41,3 +41,3 @@ "use strict"; | ||
for (const pluginDefinition of lifecycle.pluginDefinitions) { | ||
const { lifecycleSession } = await lifecycle.getContextForPluginDefinitionAsync(pluginDefinition); | ||
const lifecycleSession = await lifecycle.getSessionForPluginDefinitionAsync(pluginDefinition); | ||
deleteOperations.push({ sourcePath: lifecycleSession.tempFolderPath }); | ||
@@ -44,0 +44,0 @@ // Also delete the cache folder if requested |
@@ -5,6 +5,6 @@ import { HeftPluginHost } from './HeftPluginHost'; | ||
import type { HeftLifecyclePluginDefinition } from '../configuration/HeftPluginDefinition'; | ||
import { HeftLifecycleSession, type IHeftLifecycleHooks } from './HeftLifecycleSession'; | ||
import { HeftLifecycleSession, type IHeftLifecycleHooks, type IHeftLifecycleSession } from './HeftLifecycleSession'; | ||
export interface IHeftLifecycleContext { | ||
lifecycleSession: HeftLifecycleSession; | ||
pluginOptions?: object; | ||
lifecycleSession?: HeftLifecycleSession; | ||
pluginOptions: object | undefined; | ||
} | ||
@@ -21,7 +21,7 @@ export declare class HeftLifecycle extends HeftPluginHost { | ||
constructor(internalHeftSession: InternalHeftSession, lifecyclePluginSpecifiers: IHeftConfigurationJsonPluginSpecifier[]); | ||
applyPluginsInternalAsync(): Promise<void>; | ||
protected applyPluginsInternalAsync(): Promise<void>; | ||
ensureInitializedAsync(): Promise<void>; | ||
getContextForPluginDefinitionAsync(pluginDefinition: HeftLifecyclePluginDefinition): Promise<IHeftLifecycleContext>; | ||
getSessionForPluginDefinitionAsync(pluginDefinition: HeftLifecyclePluginDefinition): Promise<IHeftLifecycleSession>; | ||
private _getLifecyclePluginForPluginDefinitionAsync; | ||
} | ||
//# sourceMappingURL=HeftLifecycle.d.ts.map |
@@ -39,4 +39,18 @@ "use strict"; | ||
const loadPluginPromises = []; | ||
for (const [pluginDefinition] of this._lifecycleContextByDefinition) { | ||
loadPluginPromises.push(this._getLifecyclePluginForPluginDefinitionAsync(pluginDefinition)); | ||
for (const [pluginDefinition, lifecycleContext] of this._lifecycleContextByDefinition) { | ||
if (!lifecycleContext.lifecycleSession) { | ||
// Generate the plugin-specific session | ||
lifecycleContext.lifecycleSession = new HeftLifecycleSession_1.HeftLifecycleSession({ | ||
debug: this._internalHeftSession.debug, | ||
heftConfiguration: this._internalHeftSession.heftConfiguration, | ||
loggingManager: this._internalHeftSession.loggingManager, | ||
metricsCollector: this._internalHeftSession.metricsCollector, | ||
logger: this._internalHeftSession.loggingManager.requestScopedLogger(`lifecycle:${pluginDefinition.pluginName}`), | ||
lifecycleHooks: this.hooks, | ||
lifecycleParameters: this._internalHeftSession.parameterManager.getParametersForPlugin(pluginDefinition), | ||
pluginDefinition: pluginDefinition, | ||
pluginHost: this | ||
}); | ||
} | ||
loadPluginPromises.push(this._getLifecyclePluginForPluginDefinitionAsync(pluginDefinition, lifecycleContext.lifecycleSession)); | ||
} | ||
@@ -50,2 +64,3 @@ // Promise.all maintains the order of the input array | ||
try { | ||
// Apply the plugin. We know the session should exist because we generated it above. | ||
lifecyclePlugin.apply(lifecycleContext.lifecycleSession, this._internalHeftSession.heftConfiguration, lifecycleContext.pluginOptions); | ||
@@ -91,17 +106,7 @@ } | ||
} | ||
// Generate the plugin-specific session | ||
const lifecycleSession = new HeftLifecycleSession_1.HeftLifecycleSession({ | ||
debug: this._internalHeftSession.debug, | ||
heftConfiguration: this._internalHeftSession.heftConfiguration, | ||
loggingManager: this._internalHeftSession.loggingManager, | ||
metricsCollector: this._internalHeftSession.metricsCollector, | ||
logger: this._internalHeftSession.loggingManager.requestScopedLogger(`lifecycle:${pluginDefinition.pluginName}`), | ||
lifecycleHooks: this.hooks, | ||
lifecycleParameters: this._internalHeftSession.parameterManager.getParametersForPlugin(pluginDefinition), | ||
pluginDefinition: pluginDefinition, | ||
pluginHost: this | ||
}); | ||
// Validate the plugin options | ||
const pluginOptions = pluginSpecifier.options; | ||
// Set the context | ||
const lifecycleContext = { lifecycleSession, pluginOptions }; | ||
pluginDefinition.validateOptions(pluginOptions); | ||
// Partially populate the context. The session will be populated while applying the plugins. | ||
const lifecycleContext = { lifecycleSession: undefined, pluginOptions }; | ||
this._lifecycleContextByDefinition.set(pluginDefinition, lifecycleContext); | ||
@@ -111,3 +116,3 @@ } | ||
} | ||
async getContextForPluginDefinitionAsync(pluginDefinition) { | ||
async getSessionForPluginDefinitionAsync(pluginDefinition) { | ||
await this.ensureInitializedAsync(); | ||
@@ -118,10 +123,11 @@ const lifecycleContext = this._lifecycleContextByDefinition.get(pluginDefinition); | ||
} | ||
return lifecycleContext; | ||
if (!lifecycleContext.lifecycleSession) { | ||
throw new node_core_library_1.InternalError(`Lifecycle session for plugin ${JSON.stringify(pluginDefinition.pluginName)} has not been created yet.`); | ||
} | ||
return lifecycleContext.lifecycleSession; | ||
} | ||
async _getLifecyclePluginForPluginDefinitionAsync(pluginDefinition) { | ||
async _getLifecyclePluginForPluginDefinitionAsync(pluginDefinition, lifecycleSession) { | ||
let lifecyclePlugin = this._lifecyclePluginsByDefinition.get(pluginDefinition); | ||
if (!lifecyclePlugin) { | ||
// Need to obtain the plugin logger from the session | ||
const lifecycleContext = await this.getContextForPluginDefinitionAsync(pluginDefinition); | ||
lifecyclePlugin = await pluginDefinition.loadPluginAsync(lifecycleContext.lifecycleSession.logger); | ||
lifecyclePlugin = await pluginDefinition.loadPluginAsync(lifecycleSession.logger); | ||
this._lifecyclePluginsByDefinition.set(pluginDefinition, lifecyclePlugin); | ||
@@ -128,0 +134,0 @@ } |
@@ -31,4 +31,4 @@ import { AsyncParallelHook } from 'tapable'; | ||
*/ | ||
applyPluginsInternalAsync(): Promise<void>; | ||
protected applyPluginsInternalAsync(): Promise<void>; | ||
} | ||
//# sourceMappingURL=HeftPhaseSession.d.ts.map |
@@ -31,2 +31,5 @@ "use strict"; | ||
const internalHeftSession = new InternalHeftSession(heftConfigurationJson, options); | ||
// Initialize the lifecycle and the tasks. This will ensure that we throw an error if a plugin is improperly | ||
// specified, or if the options provided to a plugin are invalid. We will avoid loading the actual plugins | ||
// until they are needed. | ||
await internalHeftSession.lifecycle.ensureInitializedAsync(); | ||
@@ -33,0 +36,0 @@ const tasks = getAllTasks(internalHeftSession.phases); |
{ | ||
"name": "@rushstack/heft", | ||
"version": "0.48.0-dev.0", | ||
"version": "0.48.0-dev.1", | ||
"description": "Build all your JavaScript projects the same way: A way that works.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
885185
9201
0