@@ -144,13 +144,13 @@ export class AssetManifest {
144
144
}
145
145
146
146
function makeEntries < A , B , C > (
147
- assets : Record < string , { source : A ; destinations : Record < string , B > } > ,
148
- ctor : new ( id : DestinationIdentifier , source : A , destination : B ) => C ,
147
+ assets : Record < string , { source : A ; displayName ?: string ; destinations : Record < string , B > } > ,
148
+ ctor : new ( id : DestinationIdentifier , displayName : string | undefined , source : A , destination : B ) => C ,
149
149
) : C [ ] {
150
150
const ret = new Array < C > ( ) ;
151
151
for ( const [ assetId , asset ] of Object . entries ( assets ) ) {
152
152
for ( const [ destId , destination ] of Object . entries ( asset . destinations ) ) {
153
- ret . push ( new ctor ( new DestinationIdentifier ( assetId , destId ) , asset . source , destination ) ) ;
153
+ ret . push ( new ctor ( new DestinationIdentifier ( assetId , destId ) , asset . displayName , asset . source , destination ) ) ;
154
154
}
155
155
}
156
156
return ret ;
@@ -183,6 +183,20 @@ export interface IManifestEntry {
183
183
* Type-dependent destination data
184
184
*/
185
185
readonly genericDestination : unknown ;
186
+
187
+ /**
188
+ * Return a display name for this asset
189
+ *
190
+ * The `includeDestination` parameter controls whether or not to include the
191
+ * destination ID in the display name.
192
+ *
193
+ * - Pass `false` if you are displaying notifications about building the
194
+ * asset, or if you are describing the work of building the asset and publishing
195
+ * to all destinations at the same time.
196
+ * - Pass `true` if you are displaying notifications about publishing to a
197
+ * specific destination.
198
+ */
199
+ displayName ( includeDestination : boolean ) : string ;
186
200
}
187
201
188
202
/**
@@ -196,6 +210,7 @@ export class FileManifestEntry implements IManifestEntry {
196
210
constructor (
197
211
/** Identifier for this asset */
198
212
public readonly id : DestinationIdentifier ,
213
+ private readonly _displayName : string | undefined ,
199
214
/** Source of the file asset */
200
215
public readonly source : FileSource ,
201
216
/** Destination for the file asset */
@@ -204,6 +219,14 @@ export class FileManifestEntry implements IManifestEntry {
204
219
this . genericSource = source ;
205
220
this . genericDestination = destination ;
206
221
}
222
+
223
+ public displayName ( includeDestination : boolean ) : string {
224
+ if ( includeDestination ) {
225
+ return this . _displayName ? `${ this . _displayName } (${ this . id . destinationId } )` : `${ this . id } ` ;
226
+ } else {
227
+ return this . _displayName ? this . _displayName : this . id . assetId ;
228
+ }
229
+ }
207
230
}
208
231
209
232
/**
@@ -217,6 +240,7 @@ export class DockerImageManifestEntry implements IManifestEntry {
217
240
constructor (
218
241
/** Identifier for this asset */
219
242
public readonly id : DestinationIdentifier ,
243
+ private readonly _displayName : string | undefined ,
220
244
/** Source of the file asset */
221
245
public readonly source : DockerImageSource ,
222
246
/** Destination for the file asset */
@@ -225,13 +249,28 @@ export class DockerImageManifestEntry implements IManifestEntry {
225
249
this . genericSource = source ;
226
250
this . genericDestination = destination ;
227
251
}
252
+
253
+ public displayName ( includeDestination : boolean ) : string {
254
+ if ( includeDestination ) {
255
+ return this . _displayName ? `${ this . _displayName } (${ this . id . destinationId } )` : `${ this . id } ` ;
256
+ } else {
257
+ return this . _displayName ? this . _displayName : this . id . assetId ;
258
+ }
259
+ }
228
260
}
229
261
230
262
/**
231
263
* Identify an asset destination in an asset manifest
232
264
*
233
- * When stringified, this will be a combination of the source
234
- * and destination IDs.
265
+ * This class is used to identify both an asset to be built as well as a
266
+ * destination where an asset will be published. However, when reasoning about
267
+ * building assets the destination part can be ignored, because the same asset
268
+ * being sent to multiple destinations will only need to be built once and their
269
+ * assetIds are all the same.
270
+ *
271
+ * When stringified, this will be a combination of the source and destination
272
+ * IDs; if a string representation of the source is necessary, use `id.assetId`
273
+ * instead.
235
274
*/
236
275
export class DestinationIdentifier {
237
276
/**
0 commit comments