From a7d29119d27bb1df114d9d0d78f2f2eb41fa4a20 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Fri, 3 Oct 2025 14:28:24 -0400 Subject: [PATCH 1/3] Add the ability to get the original value. --- .../main_2025-10-03-18-24.json | 10 ++++ common/reviews/api/heft-config-file.api.md | 1 + .../src/ConfigurationFileBase.ts | 60 +++++++++++++------ .../src/test/ConfigurationFile.test.ts | 25 ++++++++ .../ConfigurationFile.test.ts.snap | 10 ++++ .../src/test/complexConfigFile/pluginsA.json | 2 +- .../src/test/complexConfigFile/pluginsB.json | 2 +- .../src/test/complexConfigFile/pluginsC.json | 2 +- .../src/test/complexConfigFile/pluginsD.json | 2 +- 9 files changed, 92 insertions(+), 22 deletions(-) create mode 100644 common/changes/@rushstack/heft-config-file/main_2025-10-03-18-24.json diff --git a/common/changes/@rushstack/heft-config-file/main_2025-10-03-18-24.json b/common/changes/@rushstack/heft-config-file/main_2025-10-03-18-24.json new file mode 100644 index 00000000000..983c84c9330 --- /dev/null +++ b/common/changes/@rushstack/heft-config-file/main_2025-10-03-18-24.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/heft-config-file", + "comment": "Add the ability to get the original value of the `$schema` property.", + "type": "minor" + } + ], + "packageName": "@rushstack/heft-config-file" +} \ No newline at end of file diff --git a/common/reviews/api/heft-config-file.api.md b/common/reviews/api/heft-config-file.api.md index bfad3503db6..f432abc2fca 100644 --- a/common/reviews/api/heft-config-file.api.md +++ b/common/reviews/api/heft-config-file.api.md @@ -20,6 +20,7 @@ export abstract class ConfigurationFileBase string; getObjectSourceFilePath(obj: TObject): string | undefined; getPropertyOriginalValue(options: IOriginalValueOptions): TValue | undefined; + getSchemaPropertyOriginalValue(obj: TObject): string | undefined; // (undocumented) protected _loadConfigurationFileInnerWithCache(terminal: ITerminal, resolvedConfigurationFilePath: string, projectFolderPath: string | undefined, onConfigurationFileNotFound?: IOnConfigurationFileNotFoundCallback): TConfigurationFile; // (undocumented) diff --git a/libraries/heft-config-file/src/ConfigurationFileBase.ts b/libraries/heft-config-file/src/ConfigurationFileBase.ts index d21e0c0d476..a1524b566b6 100644 --- a/libraries/heft-config-file/src/ConfigurationFileBase.ts +++ b/libraries/heft-config-file/src/ConfigurationFileBase.ts @@ -160,15 +160,32 @@ export const CONFIGURATION_FILE_FIELD_ANNOTATION: unique symbol = Symbol( 'configuration-file-field-annotation' ); -export interface IAnnotatedField { - [CONFIGURATION_FILE_FIELD_ANNOTATION]: IConfigurationFileFieldAnnotation; +export interface IAnnotatedField< + TField, + TConfigurationFileFieldAnnotation extends + IConfigurationFileFieldAnnotation = IConfigurationFileFieldAnnotation +> { + [CONFIGURATION_FILE_FIELD_ANNOTATION]: TConfigurationFileFieldAnnotation; } +type IAnnotatedObject = Partial>; +type IRootAnnotatedObject = Partial< + IAnnotatedField> +>; + interface IConfigurationFileFieldAnnotation { configurationFilePath: string | undefined; originalValues: { [propertyName in keyof TField]: unknown }; } +interface IRootConfigurationFileFieldAnnotation extends IConfigurationFileFieldAnnotation { + schemaPropertyOriginalValue?: string; +} + +interface IObjectWithSchema { + $schema?: string; +} + /** * Options provided to the custom resolver specified in {@link ICustomJsonPathMetadata}. * @@ -453,15 +470,8 @@ export abstract class ConfigurationFileBase(obj: TObject): string | undefined { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const annotation: IConfigurationFileFieldAnnotation | undefined = (obj as any)[ - CONFIGURATION_FILE_FIELD_ANNOTATION - ]; - if (annotation) { - return annotation.configurationFilePath; - } - - return undefined; + const { [CONFIGURATION_FILE_FIELD_ANNOTATION]: annotation }: IAnnotatedObject = obj; + return annotation?.configurationFilePath; } /** @@ -471,15 +481,22 @@ export abstract class ConfigurationFileBase( options: IOriginalValueOptions ): TValue | undefined { - const { - [CONFIGURATION_FILE_FIELD_ANNOTATION]: annotation - }: { [CONFIGURATION_FILE_FIELD_ANNOTATION]?: IConfigurationFileFieldAnnotation } = - options.parentObject; - if (annotation?.originalValues.hasOwnProperty(options.propertyName)) { - return annotation.originalValues[options.propertyName] as TValue; + const { parentObject, propertyName } = options; + const { [CONFIGURATION_FILE_FIELD_ANNOTATION]: annotation }: IAnnotatedObject = + parentObject; + if (annotation?.originalValues.hasOwnProperty(propertyName)) { + return annotation.originalValues[propertyName] as TValue; } } + /** + * Get the original value of the `$schema` property from the original configuration file, it one was present. + */ + public getSchemaPropertyOriginalValue(obj: TObject): string | undefined { + const { [CONFIGURATION_FILE_FIELD_ANNOTATION]: annotation }: IRootAnnotatedObject = obj; + return annotation?.schemaPropertyOriginalValue; + } + protected _loadConfigurationFileInnerWithCache( terminal: ITerminal, resolvedConfigurationFilePath: string, @@ -979,7 +996,7 @@ export abstract class ConfigurationFileBase = this._mergeObjects( parentConfiguration as { [key: string]: unknown }, configurationJson as { [key: string]: unknown }, resolvedConfigurationFilePath, @@ -987,6 +1004,13 @@ export abstract class ConfigurationFileBase, ignoreProperties ) as Partial; + + const schemaPropertyOriginalValue: string | undefined = (configurationJson as IObjectWithSchema).$schema; + (result as unknown as Required>)[ + CONFIGURATION_FILE_FIELD_ANNOTATION + ].schemaPropertyOriginalValue = schemaPropertyOriginalValue; + + return result; } private _mergeObjects( diff --git a/libraries/heft-config-file/src/test/ConfigurationFile.test.ts b/libraries/heft-config-file/src/test/ConfigurationFile.test.ts index 12e130d11ec..8f099ad44d6 100644 --- a/libraries/heft-config-file/src/test/ConfigurationFile.test.ts +++ b/libraries/heft-config-file/src/test/ConfigurationFile.test.ts @@ -1140,6 +1140,31 @@ describe('ConfigurationFile', () => { nodeJsPath.resolve(__dirname, secondConfigFilePath) ); }); + + it('Can get the original $schema property value', async () => { + async function testForFilename(filename: string, expectedSchema: string): Promise { + const projectRelativeFilePath: string = `complexConfigFile/${filename}`; + const jsonSchemaPath: string = nodeJsPath.resolve( + __dirname, + 'complexConfigFile', + 'plugins.schema.json' + ); + + const configFileLoader: ProjectConfigurationFile = + new ProjectConfigurationFile({ + projectRelativeFilePath, + jsonSchemaPath + }); + const loadedConfigFile: IComplexConfigFile = + await configFileLoader.loadConfigurationFileForProjectAsync(terminal, __dirname); + expect(configFileLoader.getSchemaPropertyOriginalValue(loadedConfigFile)).toEqual(expectedSchema); + } + + await testForFilename('pluginsA.json', 'http://schema.net/A'); + await testForFilename('pluginsB.json', 'http://schema.net/B'); + await testForFilename('pluginsC.json', 'http://schema.net/C'); + await testForFilename('pluginsD.json', 'http://schema.net/D'); + }); }); describe('a complex file with inheritance type annotations', () => { diff --git a/libraries/heft-config-file/src/test/__snapshots__/ConfigurationFile.test.ts.snap b/libraries/heft-config-file/src/test/__snapshots__/ConfigurationFile.test.ts.snap index 5748f708a98..04cdb9dff85 100644 --- a/libraries/heft-config-file/src/test/__snapshots__/ConfigurationFile.test.ts.snap +++ b/libraries/heft-config-file/src/test/__snapshots__/ConfigurationFile.test.ts.snap @@ -1,5 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`ConfigurationFile A complex config file Can get the original $schema property value 1`] = ` +Object { + "debug": "", + "error": "", + "log": "", + "verbose": "", + "warning": "", +} +`; + exports[`ConfigurationFile A complex config file Correctly loads a complex config file (Deprecated PathResolutionMethod.NodeResolve) 1`] = ` Object { "debug": "", diff --git a/libraries/heft-config-file/src/test/complexConfigFile/pluginsA.json b/libraries/heft-config-file/src/test/complexConfigFile/pluginsA.json index c18a3595864..37a1be91f2e 100644 --- a/libraries/heft-config-file/src/test/complexConfigFile/pluginsA.json +++ b/libraries/heft-config-file/src/test/complexConfigFile/pluginsA.json @@ -1,5 +1,5 @@ { - "$schema": "http://schema.net/", + "$schema": "http://schema.net/A", "plugins": [ { diff --git a/libraries/heft-config-file/src/test/complexConfigFile/pluginsB.json b/libraries/heft-config-file/src/test/complexConfigFile/pluginsB.json index 12c3a5ce521..24cc40fa261 100644 --- a/libraries/heft-config-file/src/test/complexConfigFile/pluginsB.json +++ b/libraries/heft-config-file/src/test/complexConfigFile/pluginsB.json @@ -1,5 +1,5 @@ { - "$schema": "http://schema.net/", + "$schema": "http://schema.net/B", "extends": "./pluginsA.json", diff --git a/libraries/heft-config-file/src/test/complexConfigFile/pluginsC.json b/libraries/heft-config-file/src/test/complexConfigFile/pluginsC.json index 1319215f110..9d24ea71f15 100644 --- a/libraries/heft-config-file/src/test/complexConfigFile/pluginsC.json +++ b/libraries/heft-config-file/src/test/complexConfigFile/pluginsC.json @@ -1,5 +1,5 @@ { - "$schema": "http://schema.net/", + "$schema": "http://schema.net/C", "extends": "./pluginsB.json" } diff --git a/libraries/heft-config-file/src/test/complexConfigFile/pluginsD.json b/libraries/heft-config-file/src/test/complexConfigFile/pluginsD.json index ae25f280294..08840447fef 100644 --- a/libraries/heft-config-file/src/test/complexConfigFile/pluginsD.json +++ b/libraries/heft-config-file/src/test/complexConfigFile/pluginsD.json @@ -1,5 +1,5 @@ { - "$schema": "http://schema.net/", + "$schema": "http://schema.net/D", "extends": "./pluginsC.json" } From 1e0a97a10e79d77baa289087538807c347f9fb7a Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Fri, 3 Oct 2025 14:53:35 -0400 Subject: [PATCH 2/3] Fix dropping of the $schema property. --- .../changes/@microsoft/rush/main_2025-10-03-18-53.json | 10 ++++++++++ common/reviews/api/rush-lib.api.md | 4 +++- .../src/logic/pnpm/PnpmOptionsConfiguration.ts | 10 ++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 common/changes/@microsoft/rush/main_2025-10-03-18-53.json diff --git a/common/changes/@microsoft/rush/main_2025-10-03-18-53.json b/common/changes/@microsoft/rush/main_2025-10-03-18-53.json new file mode 100644 index 00000000000..9cc586bbbdf --- /dev/null +++ b/common/changes/@microsoft/rush/main_2025-10-03-18-53.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix an issue where the `$schema` property is dropped from `common/config/rush/pnpm-config.json` when running `rush-pnpm patch-commit ...`", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/common/reviews/api/rush-lib.api.md b/common/reviews/api/rush-lib.api.md index 58ddeefaf83..cdad7dd3b7a 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -761,6 +761,8 @@ export interface IPnpmLockfilePolicies { // @internal export interface _IPnpmOptionsJson extends IPackageManagerOptionsJsonBase { + // (undocumented) + $schema?: string; alwaysFullInstall?: boolean; alwaysInjectDependenciesFromOtherSubspaces?: boolean; autoInstallPeers?: boolean; @@ -1183,7 +1185,7 @@ export class PnpmOptionsConfiguration extends PackageManagerOptionsConfiguration // (undocumented) readonly jsonFilename: string | undefined; // @internal (undocumented) - static loadFromJsonFileOrThrow(jsonFilename: string, commonTempFolder: string): PnpmOptionsConfiguration; + static loadFromJsonFileOrThrow(jsonFilePath: string, commonTempFolder: string): PnpmOptionsConfiguration; // @internal (undocumented) static loadFromJsonObject(json: _IPnpmOptionsJson, commonTempFolder: string): PnpmOptionsConfiguration; readonly pnpmLockfilePolicies: IPnpmLockfilePolicies | undefined; diff --git a/libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts b/libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts index 92009e39c84..571a7855b3c 100644 --- a/libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts +++ b/libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts @@ -81,6 +81,7 @@ export interface IPnpmPackageExtension { * @internal */ export interface IPnpmOptionsJson extends IPackageManagerOptionsJsonBase { + $schema?: string; /** * {@inheritDoc PnpmOptionsConfiguration.pnpmStore} */ @@ -431,7 +432,7 @@ export class PnpmOptionsConfiguration extends PackageManagerOptionsConfiguration /** @internal */ public static loadFromJsonFileOrThrow( - jsonFilename: string, + jsonFilePath: string, commonTempFolder: string ): PnpmOptionsConfiguration { // TODO: plumb through the terminal @@ -441,11 +442,12 @@ export class PnpmOptionsConfiguration extends PackageManagerOptionsConfiguration new NonProjectConfigurationFile({ jsonSchemaObject: schemaJson }); - const pnpmOptionJson: IPnpmOptionsJson = pnpmOptionsConfigFile.loadConfigurationFile( + const pnpmConfigJson: IPnpmOptionsJson = pnpmOptionsConfigFile.loadConfigurationFile( terminal, - jsonFilename + jsonFilePath ); - return new PnpmOptionsConfiguration(pnpmOptionJson || {}, commonTempFolder, jsonFilename); + pnpmConfigJson.$schema = pnpmOptionsConfigFile.getSchemaPropertyOriginalValue(pnpmConfigJson); + return new PnpmOptionsConfiguration(pnpmConfigJson || {}, commonTempFolder, jsonFilePath); } /** @internal */ From d83c5e372faf738d95eedd1d3d618f6c38da857d Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Fri, 3 Oct 2025 14:56:38 -0400 Subject: [PATCH 3/3] Clean up usage of node path in the configiration file tests. --- .../src/test/ConfigurationFile.test.ts | 224 +++--------------- 1 file changed, 39 insertions(+), 185 deletions(-) diff --git a/libraries/heft-config-file/src/test/ConfigurationFile.test.ts b/libraries/heft-config-file/src/test/ConfigurationFile.test.ts index 8f099ad44d6..2afb977e9e7 100644 --- a/libraries/heft-config-file/src/test/ConfigurationFile.test.ts +++ b/libraries/heft-config-file/src/test/ConfigurationFile.test.ts @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -/* eslint-disable max-lines */ - -import * as nodeJsPath from 'node:path'; +import nodeJsPath from 'node:path'; import { FileSystem, JsonFile, Path, Text } from '@rushstack/node-core-library'; import { StringBufferTerminalProvider, Terminal } from '@rushstack/terminal'; import { RigConfig } from '@rushstack/rig-package'; @@ -13,7 +11,7 @@ import { PathResolutionMethod, InheritanceType, ConfigurationFileBase } from '.. import { NonProjectConfigurationFile } from '../NonProjectConfigurationFile'; describe('ConfigurationFile', () => { - const projectRoot: string = nodeJsPath.resolve(__dirname, '..', '..'); + const projectRoot: string = nodeJsPath.resolve(__dirname, '../..'); let terminalProvider: StringBufferTerminalProvider; let terminal: Terminal; @@ -241,11 +239,7 @@ describe('ConfigurationFile', () => { describe('A simple config file containing an array and an object', () => { const configFileFolderName: string = 'simpleConfigFile'; const projectRelativeFilePath: string = `${configFileFolderName}/simpleConfigFile.json`; - const schemaPath: string = nodeJsPath.resolve( - __dirname, - configFileFolderName, - 'simpleConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/${configFileFolderName}/simpleConfigFile.schema.json`; interface ISimpleConfigFile { things: string[]; @@ -432,11 +426,7 @@ describe('ConfigurationFile', () => { describe('A simple config file with "extends"', () => { const configFileFolderName: string = 'simpleConfigFileWithExtends'; const projectRelativeFilePath: string = `${configFileFolderName}/simpleConfigFileWithExtends.json`; - const schemaPath: string = nodeJsPath.resolve( - __dirname, - configFileFolderName, - 'simpleConfigFileWithExtends.schema.json' - ); + const schemaPath: string = `${__dirname}/${configFileFolderName}/simpleConfigFileWithExtends.schema.json`; interface ISimpleConfigFile { things: string[]; @@ -821,7 +811,7 @@ describe('ConfigurationFile', () => { 'complexConfigFile', 'pluginsB.json' ); - const schemaPath: string = nodeJsPath.resolve(__dirname, 'complexConfigFile', 'plugins.schema.json'); + const schemaPath: string = `${__dirname}/complexConfigFile/plugins.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ @@ -904,7 +894,7 @@ describe('ConfigurationFile', () => { 'complexConfigFile', 'pluginsB.json' ); - const schemaPath: string = nodeJsPath.resolve(__dirname, 'complexConfigFile', 'plugins.schema.json'); + const schemaPath: string = `${__dirname}/complexConfigFile/plugins.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ @@ -985,7 +975,7 @@ describe('ConfigurationFile', () => { 'complexConfigFile', 'pluginsB.json' ); - const schemaPath: string = nodeJsPath.resolve(__dirname, 'complexConfigFile', 'plugins.schema.json'); + const schemaPath: string = `${__dirname}/complexConfigFile/plugins.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ @@ -1068,7 +1058,7 @@ describe('ConfigurationFile', () => { 'complexConfigFile', 'pluginsB.json' ); - const schemaPath: string = nodeJsPath.resolve(__dirname, 'complexConfigFile', 'plugins.schema.json'); + const schemaPath: string = `${__dirname}/complexConfigFile/plugins.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ @@ -1222,11 +1212,7 @@ describe('ConfigurationFile', () => { 'inheritanceTypeConfigFile', 'inheritanceTypeConfigFileB.json' ); - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'inheritanceTypeConfigFile', - 'inheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/inheritanceTypeConfigFile/inheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ @@ -1314,11 +1300,7 @@ describe('ConfigurationFile', () => { 'inheritanceTypeConfigFile', 'inheritanceTypeConfigFileB.json' ); - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'inheritanceTypeConfigFile', - 'inheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/inheritanceTypeConfigFile/inheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ @@ -1405,11 +1387,7 @@ describe('ConfigurationFile', () => { 'simpleInheritanceTypeConfigFile', 'simpleInheritanceTypeConfigFileB.json' ); - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ @@ -1452,11 +1430,7 @@ describe('ConfigurationFile', () => { }); it("throws an error when an array uses the 'merge' inheritance type", () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileA.json', jsonSchemaPath: schemaPath @@ -1468,11 +1442,7 @@ describe('ConfigurationFile', () => { }); it("throws an error when an array uses the 'merge' inheritance type async", async () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileA.json', jsonSchemaPath: schemaPath @@ -1484,11 +1454,7 @@ describe('ConfigurationFile', () => { }); it("throws an error when a keyed object uses the 'append' inheritance type", () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileB.json', jsonSchemaPath: schemaPath @@ -1500,11 +1466,7 @@ describe('ConfigurationFile', () => { }); it("throws an error when a keyed object uses the 'append' inheritance type async", async () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileB.json', jsonSchemaPath: schemaPath @@ -1516,11 +1478,7 @@ describe('ConfigurationFile', () => { }); it('throws an error when a non-object property uses an inheritance type', () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileC.json', jsonSchemaPath: schemaPath @@ -1532,11 +1490,7 @@ describe('ConfigurationFile', () => { }); it('throws an error when a non-object property uses an inheritance type async', async () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileC.json', jsonSchemaPath: schemaPath @@ -1548,11 +1502,7 @@ describe('ConfigurationFile', () => { }); it('throws an error when an inheritance type is specified for an unspecified property', () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileD.json', jsonSchemaPath: schemaPath @@ -1564,11 +1514,7 @@ describe('ConfigurationFile', () => { }); it('throws an error when an inheritance type is specified for an unspecified property async', async () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileD.json', jsonSchemaPath: schemaPath @@ -1580,11 +1526,7 @@ describe('ConfigurationFile', () => { }); it('throws an error when an unsupported inheritance type is specified', () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileE.json', jsonSchemaPath: schemaPath @@ -1596,11 +1538,7 @@ describe('ConfigurationFile', () => { }); it('throws an error when an unsupported inheritance type is specified async', async () => { - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simpleInheritanceTypeConfigFile', - 'simpleInheritanceTypeConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simpleInheritanceTypeConfigFile/simpleInheritanceTypeConfigFile.schema.json`; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: 'simpleInheritanceTypeConfigFile/badInheritanceTypeConfigFileE.json', jsonSchemaPath: schemaPath @@ -1613,14 +1551,10 @@ describe('ConfigurationFile', () => { }); describe('loading a rig', () => { - const projectFolder: string = nodeJsPath.resolve(__dirname, 'project-referencing-rig'); + const projectFolder: string = `${__dirname}/project-referencing-rig`; const rigConfig: RigConfig = RigConfig.loadForProjectFolder({ projectFolderPath: projectFolder }); - const schemaPath: string = nodeJsPath.resolve( - __dirname, - 'simplestConfigFile', - 'simplestConfigFile.schema.json' - ); + const schemaPath: string = `${__dirname}/simplestConfigFile/simplestConfigFile.schema.json`; interface ISimplestConfigFile { thing: string; @@ -1769,12 +1703,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'invalidType'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/notExist.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); expect(() => @@ -1786,12 +1715,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'invalidType'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/notExist.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); await expect( @@ -1803,12 +1727,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'invalidType'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/notExist.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); expect(configFileLoader.tryLoadConfigurationFileForProject(terminal, __dirname)).toBeUndefined(); @@ -1818,12 +1737,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'invalidType'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/notExist.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); await expect( @@ -1847,12 +1761,7 @@ describe('ConfigurationFile', () => { const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: configFilePath, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); // The synchronous code path on Windows somehow determines that the unexpected character is @@ -1883,12 +1792,7 @@ describe('ConfigurationFile', () => { const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: configFilePath, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); await expect( @@ -1904,12 +1808,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'invalidType'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/config.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); expect(() => @@ -1921,12 +1820,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'invalidType'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/config.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); await expect( @@ -1938,12 +1832,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'circularReference'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/config1.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); expect(() => @@ -1955,12 +1844,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'circularReference'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/config1.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); await expect( @@ -1972,12 +1856,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'extendsNotExist'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/config.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); expect(() => @@ -1989,12 +1868,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'extendsNotExist'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/config.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); await expect( @@ -2006,12 +1880,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'invalidCombinedFile'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/config1.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); expect(() => @@ -2023,12 +1892,7 @@ describe('ConfigurationFile', () => { const errorCaseFolderName: string = 'invalidCombinedFile'; const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/${errorCaseFolderName}/config1.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - errorCaseFolderName, - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/${errorCaseFolderName}/config.schema.json` }); await expect( @@ -2039,12 +1903,7 @@ describe('ConfigurationFile', () => { it("Throws an error when a requested file doesn't exist", () => { const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/folderThatDoesntExist/config.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - 'invalidCombinedFile', - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/invalidCombinedFile/config.schema.json` }); expect(() => @@ -2055,12 +1914,7 @@ describe('ConfigurationFile', () => { it("Throws an error when a requested file doesn't exist async", async () => { const configFileLoader: ProjectConfigurationFile = new ProjectConfigurationFile({ projectRelativeFilePath: `${errorCasesFolderName}/folderThatDoesntExist/config.json`, - jsonSchemaPath: nodeJsPath.resolve( - __dirname, - errorCasesFolderName, - 'invalidCombinedFile', - 'config.schema.json' - ) + jsonSchemaPath: `${__dirname}/${errorCasesFolderName}/invalidCombinedFile/config.schema.json` }); await expect(