Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/api-extractor/config/heft.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for standard
* settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*/
"extends": "decoupled-local-node-rig/profiles/default/config/heft.json",

Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/schemas/heft-legacy.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},

"extends": {
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects.",
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects. To delete an inherited setting, set it to `null` in this file.",
"type": "string"
},

Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/schemas/heft.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
},

"extends": {
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects.",
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects. To delete an inherited setting, set it to `null` in this file.",
"type": "string"
},

Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/schemas/node-service.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},

"extends": {
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects.",
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects. To delete an inherited setting, set it to `null` in this file.",
"type": "string"
},

Expand Down
2 changes: 2 additions & 0 deletions apps/heft/src/schemas/templates/heft.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for standard
* settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*/
// "extends": "base-project/config/heft.json",

Expand Down
2 changes: 2 additions & 0 deletions apps/lockfile-explorer-web/config/heft.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for standard
* settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*/
"extends": "local-web-rig/profiles/app/config/heft.json",

Expand Down
2 changes: 2 additions & 0 deletions apps/lockfile-explorer/config/heft.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for standard
* settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*/
"extends": "local-node-rig/profiles/default/config/heft.json",

Expand Down
2 changes: 2 additions & 0 deletions apps/lockfile-explorer/config/node-service.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for standard
* settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*/
// "extends": "base-project/config/serve-command.json",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Optionally specifies another JSON config file that this file extends from. This provides a way for
* standard settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
* resolved using NodeJS require().
Expand Down
2 changes: 2 additions & 0 deletions build-tests/heft-fastify-test/config/node-service.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for standard
* settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*/
// "extends": "base-project/config/serve-command.json",

Expand Down
2 changes: 2 additions & 0 deletions build-tests/localization-plugin-test-01/config/heft.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for standard
* settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*/
"extends": "local-node-rig/profiles/default/config/heft.json",

Expand Down
2 changes: 2 additions & 0 deletions build-tests/localization-plugin-test-02/config/heft.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for standard
* settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*/
"extends": "local-node-rig/profiles/default/config/heft.json",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Update documentation for `extends`",
"type": "patch",
"packageName": "@microsoft/api-extractor"
}
],
"packageName": "@microsoft/api-extractor",
"email": "dmichon-msft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Update documentation for `extends`",
"type": "none",
"packageName": "@microsoft/rush"
}
],
"packageName": "@microsoft/rush",
"email": "dmichon-msft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Update documentation for `extends`",
"type": "patch",
"packageName": "@rushstack/heft-api-extractor-plugin"
}
],
"packageName": "@rushstack/heft-api-extractor-plugin",
"email": "dmichon-msft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-config-file",
"comment": "Allow use of the value `null` to discard any value set for the property from a parent config file..",
"type": "minor"
}
],
"packageName": "@rushstack/heft-config-file"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Update documentation for `extends`",
"type": "patch",
"packageName": "@rushstack/heft-node-rig"
}
],
"packageName": "@rushstack/heft-node-rig",
"email": "dmichon-msft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Update documentation for `extends`",
"type": "patch",
"packageName": "@rushstack/heft-sass-plugin"
}
],
"packageName": "@rushstack/heft-sass-plugin",
"email": "dmichon-msft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Update documentation for `extends`",
"type": "patch",
"packageName": "@rushstack/heft-typescript-plugin"
}
],
"packageName": "@rushstack/heft-typescript-plugin",
"email": "dmichon-msft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Update documentation for `extends`",
"type": "patch",
"packageName": "@rushstack/heft-web-rig"
}
],
"packageName": "@rushstack/heft-web-rig",
"email": "dmichon-msft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Update documentation for `extends`",
"type": "patch",
"packageName": "@rushstack/heft"
}
],
"packageName": "@rushstack/heft",
"email": "dmichon-msft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Update documentation for `extends`",
"type": "patch",
"packageName": "@rushstack/lockfile-explorer"
}
],
"packageName": "@rushstack/lockfile-explorer",
"email": "dmichon-msft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},

"extends": {
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects.",
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects. To delete an inherited setting, set it to `null` in this file.",
"type": "string"
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},

"extends": {
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects.",
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects. To delete an inherited setting, set it to `null` in this file.",
"type": "string"
},

Expand Down
2 changes: 2 additions & 0 deletions heft-plugins/heft-sass-plugin/src/templates/sass.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for standard
* settings to be shared across multiple projects.
*
* To delete an inherited setting, set it to `null` in this file.
*/
// "extends": "base-project/config/serve-command.json",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},

"extends": {
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects.",
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects. To delete an inherited setting, set it to `null` in this file.",
"type": "string"
},

Expand Down
18 changes: 16 additions & 2 deletions libraries/heft-config-file/src/ConfigurationFileBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface IConfigurationJson {
* @beta
*
* The set of possible mechanisms for merging properties from parent configuration files.
* If a child configuration file sets a property value to `null`, that will always delete the value
* specified in the parent configuration file, regardless of the inheritance type.
*/
const InheritanceType = {
/**
Expand Down Expand Up @@ -251,6 +253,7 @@ export interface ICustomPropertyInheritance<TObject> extends IPropertyInheritanc
* Provides a custom inheritance function. This function takes two arguments: the first is the
* child file's object, and the second is the parent file's object. The function should return
* the resulting combined object.
* This function will not be invoked if the current value is `null`, the property will simply be deleted.
*/
inheritanceFunction: PropertyInheritanceCustomFunction<TObject>;
}
Expand Down Expand Up @@ -1085,7 +1088,15 @@ export abstract class ConfigurationFileBase<TConfigurationFile, TExtraOptions ex
newValue = parentPropertyValue;
};

if (propertyValue !== undefined && parentPropertyValue === undefined) {
if (propertyValue === null) {
if (parentPropertyValue !== undefined) {
resultAnnotation.originalValues[propertyName] = this.getPropertyOriginalValue({
parentObject: parentObject,
propertyName: propertyName
});
}
newValue = undefined;
} else if (propertyValue !== undefined && parentPropertyValue === undefined) {
usePropertyValue();
} else if (parentPropertyValue !== undefined && propertyValue === undefined) {
useParentPropertyValue();
Expand Down Expand Up @@ -1207,7 +1218,10 @@ export abstract class ConfigurationFileBase<TConfigurationFile, TExtraOptions ex
}
}

result[propertyName] = newValue;
if (newValue !== undefined) {
// Don't attach the key for undefined values so that they don't enumerate.
result[propertyName] = newValue;
}
}

return result;
Expand Down
20 changes: 14 additions & 6 deletions libraries/heft-config-file/src/test/ConfigurationFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ describe('ConfigurationFile', () => {
things: string[];
thingsObj: { A: { B: string }; D: { E: string } };
booleanProp: boolean;
stringProp?: string;
}

it('Correctly loads the config file', () => {
Expand All @@ -266,7 +267,8 @@ describe('ConfigurationFile', () => {
const expectedConfigFile: ISimpleConfigFile = {
things: ['A', 'B', 'C'],
thingsObj: { A: { B: 'C' }, D: { E: 'F' } },
booleanProp: true
booleanProp: true,
stringProp: 'someValue'
};
expect(JSON.stringify(loadedConfigFile)).toEqual(JSON.stringify(expectedConfigFile));
});
Expand All @@ -284,7 +286,8 @@ describe('ConfigurationFile', () => {
const expectedConfigFile: ISimpleConfigFile = {
things: ['A', 'B', 'C'],
thingsObj: { A: { B: 'C' }, D: { E: 'F' } },
booleanProp: true
booleanProp: true,
stringProp: 'someValue'
};
expect(JSON.stringify(loadedConfigFile)).toEqual(JSON.stringify(expectedConfigFile));
});
Expand Down Expand Up @@ -317,7 +320,8 @@ describe('ConfigurationFile', () => {
A: { B: nodeJsPath.resolve(__dirname, configFileFolderName, 'C') },
D: { E: nodeJsPath.resolve(__dirname, configFileFolderName, 'F') }
},
booleanProp: true
booleanProp: true,
stringProp: 'someValue'
};
expect(JSON.stringify(loadedConfigFile)).toEqual(JSON.stringify(expectedConfigFile));
});
Expand Down Expand Up @@ -350,7 +354,8 @@ describe('ConfigurationFile', () => {
A: { B: nodeJsPath.resolve(__dirname, configFileFolderName, 'C') },
D: { E: nodeJsPath.resolve(__dirname, configFileFolderName, 'F') }
},
booleanProp: true
booleanProp: true,
stringProp: 'someValue'
};
expect(JSON.stringify(loadedConfigFile)).toEqual(JSON.stringify(expectedConfigFile));
});
Expand Down Expand Up @@ -383,7 +388,8 @@ describe('ConfigurationFile', () => {
A: { B: nodeJsPath.resolve(projectRoot, 'C') },
D: { E: nodeJsPath.resolve(projectRoot, 'F') }
},
booleanProp: true
booleanProp: true,
stringProp: 'someValue'
};
expect(JSON.stringify(loadedConfigFile)).toEqual(JSON.stringify(expectedConfigFile));
});
Expand Down Expand Up @@ -416,7 +422,8 @@ describe('ConfigurationFile', () => {
A: { B: nodeJsPath.resolve(projectRoot, 'C') },
D: { E: nodeJsPath.resolve(projectRoot, 'F') }
},
booleanProp: true
booleanProp: true,
stringProp: 'someValue'
};
expect(JSON.stringify(loadedConfigFile)).toEqual(JSON.stringify(expectedConfigFile));
});
Expand All @@ -435,6 +442,7 @@ describe('ConfigurationFile', () => {
things: string[];
thingsObj: { A: { B?: string; D?: string }; D?: { E: string }; F?: { G: string } };
booleanProp: boolean;
stringProp?: string;
}

it('Correctly loads the config file with default config meta', () => {
Expand Down
Loading
Loading