-
Notifications
You must be signed in to change notification settings - Fork 681
Expand file tree
/
Copy pathPublishConfiguration.ts
More file actions
74 lines (68 loc) · 2.44 KB
/
PublishConfiguration.ts
File metadata and controls
74 lines (68 loc) · 2.44 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// 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 rushPublishSchemaJson from '../schemas/rush-publish.schema.json';
/**
* Represents a single publish provider entry in the `providers` array.
* @public
*/
export interface IRushPublishProviderEntry {
/**
* The name of the publish provider (e.g. 'npm', 'vsix').
*/
name: string;
/**
* Provider-specific configuration options.
*/
options?: Record<string, unknown>;
}
/**
* Represents the parsed contents of a project's `config/rush-publish.json` file.
* @public
*/
export interface IRushPublishJson {
/**
* An array of publish provider entries. Each entry specifies a provider name
* and an optional set of provider-specific configuration options.
*/
providers?: IRushPublishProviderEntry[];
}
/**
* The `ProjectConfigurationFile` instance for loading `config/rush-publish.json` with
* rig resolution and property inheritance.
*
* @remarks
* The `providers` property uses custom inheritance with name-based deduplication:
* parent entries whose name does not appear in the child array are prepended,
* followed by the child entries. This means a project can override specific
* provider configs from a rig while inheriting others.
*
* @internal
*/
export const RUSH_PUBLISH_CONFIGURATION_FILE: ProjectConfigurationFile<IRushPublishJson> =
new ProjectConfigurationFile<IRushPublishJson>({
projectRelativeFilePath: 'config/rush-publish.json',
jsonSchemaObject: rushPublishSchemaJson,
propertyInheritance: {
providers: {
inheritanceType: InheritanceType.custom,
inheritanceFunction: (
child: IRushPublishProviderEntry[] | undefined,
parent: IRushPublishProviderEntry[] | undefined
): IRushPublishProviderEntry[] | undefined => {
if (!child) {
return parent;
}
if (!parent) {
return child;
}
// Name-based deduplication: inherit parent entries not overridden by child
const childNames: Set<string> = new Set(child.map((entry) => entry.name));
const inherited: IRushPublishProviderEntry[] = parent.filter(
(entry) => !childNames.has(entry.name)
);
return [...inherited, ...child];
}
}
}
});