-
Notifications
You must be signed in to change notification settings - Fork 680
Expand file tree
/
Copy pathPublishConfiguration.ts
More file actions
53 lines (49 loc) · 1.84 KB
/
PublishConfiguration.ts
File metadata and controls
53 lines (49 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import { ProjectConfigurationFile, InheritanceType } from '@rushstack/heft-config-file';
import publishSchemaJson from '../schemas/publish.schema.json';
/**
* Represents the parsed contents of a project's `config/publish.json` file.
* @public
*/
export interface IPublishJson {
/**
* An object whose keys are publish target names (e.g. 'npm', 'vsix') and whose
* values are provider-specific configuration objects.
*/
providers?: Record<string, Record<string, unknown>>;
}
/**
* The `ProjectConfigurationFile` instance for loading `config/publish.json` with
* rig resolution and property inheritance.
*
* @remarks
* The `providers` property uses custom inheritance: child provider sections are
* shallow-merged over parent provider sections. This means a project can override
* specific provider configs from a rig while inheriting others.
*
* @internal
*/
export const PUBLISH_CONFIGURATION_FILE: ProjectConfigurationFile<IPublishJson> =
new ProjectConfigurationFile<IPublishJson>({
projectRelativeFilePath: 'config/publish.json',
jsonSchemaObject: publishSchemaJson,
propertyInheritance: {
providers: {
inheritanceType: InheritanceType.custom,
inheritanceFunction: (
child: Record<string, Record<string, unknown>> | undefined,
parent: Record<string, Record<string, unknown>> | undefined
): Record<string, Record<string, unknown>> | undefined => {
if (!child) {
return parent;
}
if (!parent) {
return child;
}
// Shallow merge: child provider sections override parent provider sections
return { ...parent, ...child };
}
}
}
});