@rushstack/heft-config-file
Advanced tools
Comparing version 0.9.6 to 0.10.0
@@ -13,2 +13,3 @@ import { ITerminal } from '@rushstack/node-core-library'; | ||
private readonly _propertyInheritanceTypes; | ||
private readonly _defaultPropertyInheritance; | ||
private __schema; | ||
@@ -76,2 +77,7 @@ private get _schema(); | ||
propertyInheritance?: IPropertiesInheritance<TConfigurationFile>; | ||
/** | ||
* Use this property to control how specific property types are handled between parent and child | ||
* configuration files. | ||
*/ | ||
propertyInheritanceDefaults?: IPropertyInheritanceDefaults; | ||
} | ||
@@ -186,2 +192,10 @@ | ||
*/ | ||
export declare interface IPropertyInheritanceDefaults { | ||
array?: IPropertyInheritance<InheritanceType.append | InheritanceType.replace>; | ||
object?: IPropertyInheritance<InheritanceType.merge | InheritanceType.replace>; | ||
} | ||
/** | ||
* @beta | ||
*/ | ||
export declare enum PathResolutionMethod { | ||
@@ -188,0 +202,0 @@ /** |
@@ -115,2 +115,9 @@ import { ITerminal } from '@rushstack/node-core-library'; | ||
*/ | ||
export interface IPropertyInheritanceDefaults { | ||
array?: IPropertyInheritance<InheritanceType.append | InheritanceType.replace>; | ||
object?: IPropertyInheritance<InheritanceType.merge | InheritanceType.replace>; | ||
} | ||
/** | ||
* @beta | ||
*/ | ||
export declare type IJsonPathMetadata = ICustomJsonPathMetadata | INonCustomJsonPathMetadata; | ||
@@ -147,2 +154,7 @@ /** | ||
propertyInheritance?: IPropertiesInheritance<TConfigurationFile>; | ||
/** | ||
* Use this property to control how specific property types are handled between parent and child | ||
* configuration files. | ||
*/ | ||
propertyInheritanceDefaults?: IPropertyInheritanceDefaults; | ||
} | ||
@@ -165,2 +177,3 @@ /** | ||
private readonly _propertyInheritanceTypes; | ||
private readonly _defaultPropertyInheritance; | ||
private __schema; | ||
@@ -167,0 +180,0 @@ private get _schema(); |
@@ -100,2 +100,3 @@ "use strict"; | ||
this._propertyInheritanceTypes = options.propertyInheritance || {}; | ||
this._defaultPropertyInheritance = options.propertyInheritanceDefaults || {}; | ||
} | ||
@@ -334,6 +335,6 @@ get _schema() { | ||
// strings, TypeScript doesn't. | ||
return this._mergeObjects(parentConfiguration, configurationJson, resolvedConfigurationFilePath, this._propertyInheritanceTypes, ignoreProperties); | ||
return this._mergeObjects(parentConfiguration, configurationJson, resolvedConfigurationFilePath, this._defaultPropertyInheritance, this._propertyInheritanceTypes, ignoreProperties); | ||
} | ||
_mergeObjects(parentObject, currentObject, resolvedConfigurationFilePath, configuredPropertyInheritance, ignoreProperties) { | ||
var _a; | ||
_mergeObjects(parentObject, currentObject, resolvedConfigurationFilePath, defaultPropertyInheritance, configuredPropertyInheritance, ignoreProperties) { | ||
var _a, _b, _c; | ||
const resultAnnotation = { | ||
@@ -433,11 +434,31 @@ configurationFilePath: resolvedConfigurationFilePath, | ||
else if (propertyValue !== undefined && parentPropertyValue !== undefined) { | ||
// If the property is an inheritance type annotation, use it. Fallback to the configuration file inheritance | ||
// behavior, and if one isn't specified, use the default. | ||
let propertyInheritance = inheritanceTypeMap.get(propertyName); | ||
// If the property is an inheritance type annotation, use it, otherwise fallback to the configured | ||
// top-level property inheritance, if one is specified. | ||
let propertyInheritance = (_a = inheritanceTypeMap.get(propertyName)) !== null && _a !== void 0 ? _a : configuredPropertyInheritance === null || configuredPropertyInheritance === void 0 ? void 0 : configuredPropertyInheritance[propertyName]; | ||
if (!propertyInheritance) { | ||
const bothAreArrays = Array.isArray(propertyValue) && Array.isArray(parentPropertyValue); | ||
propertyInheritance = | ||
(_a = configuredPropertyInheritance === null || configuredPropertyInheritance === void 0 ? void 0 : configuredPropertyInheritance[propertyName]) !== null && _a !== void 0 ? _a : (bothAreArrays | ||
? { inheritanceType: InheritanceType.append } | ||
: { inheritanceType: InheritanceType.replace }); | ||
if (bothAreArrays) { | ||
// If both are arrays, use the configured default array inheritance and fallback to appending | ||
// if one is not specified | ||
propertyInheritance = (_b = defaultPropertyInheritance.array) !== null && _b !== void 0 ? _b : { | ||
inheritanceType: InheritanceType.append | ||
}; | ||
} | ||
else { | ||
const bothAreObjects = propertyValue && | ||
parentPropertyValue && | ||
typeof propertyValue === 'object' && | ||
typeof parentPropertyValue === 'object'; | ||
if (bothAreObjects) { | ||
// If both are objects, use the configured default object inheritance and fallback to replacing | ||
// if one is not specified | ||
propertyInheritance = (_c = defaultPropertyInheritance.object) !== null && _c !== void 0 ? _c : { | ||
inheritanceType: InheritanceType.replace | ||
}; | ||
} | ||
else { | ||
// Fall back to replacing if they are of different types, since we don't know how to merge these | ||
propertyInheritance = { inheritanceType: InheritanceType.replace }; | ||
} | ||
} | ||
} | ||
@@ -478,3 +499,3 @@ switch (propertyInheritance.inheritanceType) { | ||
// that it must be a string-keyed object, since the JSON spec requires it. | ||
newValue = this._mergeObjects(parentPropertyValue, propertyValue, resolvedConfigurationFilePath); | ||
newValue = this._mergeObjects(parentPropertyValue, propertyValue, resolvedConfigurationFilePath, defaultPropertyInheritance); | ||
break; | ||
@@ -481,0 +502,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export { ConfigurationFile, IConfigurationFileOptions, ICustomJsonPathMetadata, ICustomPropertyInheritance, IJsonPathMetadata, IJsonPathsMetadata, InheritanceType, INonCustomJsonPathMetadata, IOriginalValueOptions, IPropertiesInheritance, IPropertyInheritance, PathResolutionMethod, PropertyInheritanceCustomFunction } from './ConfigurationFile'; | ||
export { ConfigurationFile, IConfigurationFileOptions, ICustomJsonPathMetadata, ICustomPropertyInheritance, IJsonPathMetadata, IJsonPathsMetadata, InheritanceType, INonCustomJsonPathMetadata, IOriginalValueOptions, IPropertiesInheritance, IPropertyInheritance, IPropertyInheritanceDefaults, PathResolutionMethod, PropertyInheritanceCustomFunction } from './ConfigurationFile'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@rushstack/heft-config-file", | ||
"version": "0.9.6", | ||
"version": "0.10.0", | ||
"description": "Configuration file loader for @rushstack/heft", | ||
@@ -18,3 +18,3 @@ "repository": { | ||
"dependencies": { | ||
"@rushstack/node-core-library": "3.51.2", | ||
"@rushstack/node-core-library": "3.52.0", | ||
"@rushstack/rig-package": "0.3.15", | ||
@@ -25,3 +25,3 @@ "jsonpath-plus": "~4.0.0" | ||
"@rushstack/eslint-config": "3.0.1", | ||
"@rushstack/heft": "0.47.0", | ||
"@rushstack/heft": "0.47.9", | ||
"@rushstack/heft-node-rig": "1.10.0", | ||
@@ -28,0 +28,0 @@ "@types/heft-jest": "1.0.1", |
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
99421
978
+ Added@rushstack/node-core-library@3.52.0(transitive)
- Removed@rushstack/node-core-library@3.51.2(transitive)