@@ -56,6 +56,13 @@ export type SerializedEntry = Assign<Entry, { inputs: string[]; outputs: string[
5656export type SerializedInput = Assign < Input , { dependencies : string [ ] ; dependents : string [ ] } > ;
5757export type SerializedOutput = Assign < Output , { inputs : string [ ] } > ;
5858
59+ export type Log = {
60+ bundler ?: BundlerFullName ;
61+ pluginName : string ;
62+ type : LogLevel ;
63+ message : string ;
64+ time : number ;
65+ } ;
5966export type LogTags = string [ ] ;
6067export type Timer = {
6168 label : string ;
@@ -71,18 +78,12 @@ export type BuildMetadata = {
7178} ;
7279
7380export type BuildReport = {
74- bundler : Omit < BundlerReport , 'outDir' | 'rawConfig' > ;
75- errors : string [ ] ;
76- warnings : string [ ] ;
77- logs : {
78- bundler : BundlerFullName ;
79- pluginName : string ;
80- type : LogLevel ;
81- message : string ;
82- time : number ;
83- } [ ] ;
84- metadata : BuildMetadata ;
85- timings : Timer [ ] ;
81+ bundler : GlobalData [ 'bundler' ] ;
82+ errors : GlobalStores [ 'errors' ] ;
83+ warnings : GlobalStores [ 'warnings' ] ;
84+ logs : GlobalStores [ 'logs' ] ;
85+ timings : GlobalStores [ 'timings' ] ;
86+ metadata : GlobalData [ 'metadata' ] ;
8687 entries ?: Entry [ ] ;
8788 inputs ?: Input [ ] ;
8889 outputs ?: Output [ ] ;
@@ -104,13 +105,9 @@ export type SerializedBuildReport = Assign<
104105
105106export type BundlerFullName = ( typeof FULL_NAME_BUNDLERS ) [ number ] ;
106107export type BundlerName = ( typeof SUPPORTED_BUNDLERS ) [ number ] ;
107- export type BundlerReport = {
108- name : BundlerName ;
109- fullName : BundlerFullName ;
108+ export type BundlerReport = GlobalData [ 'bundler' ] & {
110109 outDir : string ;
111110 rawConfig ?: any ;
112- variant ?: string ; // e.g. Major version of the bundler (webpack 4, webpack 5)
113- version : string ;
114111} ;
115112
116113export type InjectedValue = string | ( ( ) => Promise < string > ) ;
@@ -140,13 +137,21 @@ export type TimeLog = (
140137 opts ?: { level ?: LogLevel ; start ?: boolean | number ; log ?: boolean ; tags ?: LogTags } ,
141138) => TimeLogger ;
142139export type GetLogger = ( name : string ) => Logger ;
140+ export type LogOptions = { forward ?: boolean } ;
141+ export type LoggerFn = ( text : any , opts ?: LogOptions ) => void ;
143142export type Logger = {
144143 getLogger : GetLogger ;
145144 time : TimeLog ;
146- error : ( text : any ) => void ;
147- warn : ( text : any ) => void ;
148- info : ( text : any ) => void ;
149- debug : ( text : any ) => void ;
145+ error : LoggerFn ;
146+ warn : LoggerFn ;
147+ info : LoggerFn ;
148+ debug : LoggerFn ;
149+ } ;
150+ type RestContext = string | string [ ] | number | boolean ;
151+ export type LogData = Record < string , RestContext | Record < string , RestContext > > ;
152+ export type DdLogOptions = {
153+ message : string ;
154+ context ?: LogData ;
150155} ;
151156export type Env = ( typeof ALL_ENVS ) [ number ] ;
152157export type TriggerHook < R > = < K extends keyof CustomHooks > (
@@ -159,16 +164,17 @@ export type GlobalContext = {
159164 build : BuildReport ;
160165 bundler : BundlerReport ;
161166 cwd : string ;
162- env : Env ;
167+ env : GlobalData [ 'env' ] ;
163168 getLogger : GetLogger ;
164169 git ?: RepositoryData ;
165170 hook : TriggerHook < void > ;
166171 inject : ( item : ToInjectItem ) => void ;
167172 pluginNames : string [ ] ;
168173 plugins : ( PluginOptions | CustomPluginOptions ) [ ] ;
169- sendLog : ( message : string , ctx ?: any ) => Promise < void > ;
174+ queue : ( promise : Promise < any > ) => void ;
175+ sendLog : ( args : DdLogOptions ) => Promise < void > ;
170176 start : number ;
171- version : string ;
177+ version : GlobalData [ 'version' ] ;
172178} ;
173179
174180export type FactoryMeta = {
@@ -206,6 +212,8 @@ export type GetPluginsArg = {
206212 bundler : any ;
207213 context : GlobalContext ;
208214 options : Options ;
215+ data : GlobalData ;
216+ stores : GlobalStores ;
209217} ;
210218export type GetPlugins = ( arg : GetPluginsArg ) => PluginOptions [ ] ;
211219export type GetCustomPlugins = ( arg : GetPluginsArg ) => CustomPluginOptions [ ] ;
@@ -265,3 +273,24 @@ export type FileValidity = {
265273 empty : boolean ;
266274 exists : boolean ;
267275} ;
276+
277+ export type GlobalData = {
278+ bundler : {
279+ name : BundlerName ;
280+ fullName : BundlerFullName ;
281+ variant : string ; // e.g. Major version of the bundler (webpack 4, webpack 5)
282+ version : string ;
283+ } ;
284+ env : Env ;
285+ metadata : BuildMetadata ;
286+ packageName : string ;
287+ version : string ;
288+ } ;
289+
290+ export type GlobalStores = {
291+ errors : string [ ] ;
292+ logs : Log [ ] ;
293+ queue : Promise < any > [ ] ;
294+ timings : Timer [ ] ;
295+ warnings : string [ ] ;
296+ } ;
0 commit comments