From 9fcb206220174af1c20fcc041e127409a41c3593 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Thu, 2 Nov 2023 11:44:21 -0500 Subject: [PATCH 1/9] fix(deps): testSetup has non ts-sinon dependency --- src/testSetup.ts | 68 +++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/testSetup.ts b/src/testSetup.ts index 959ca57d71..aa8d0c4007 100644 --- a/src/testSetup.ts +++ b/src/testSetup.ts @@ -17,7 +17,6 @@ import { basename, join as pathJoin, dirname } from 'path'; import * as util from 'util'; import { SinonSandbox, SinonStatic, SinonStub } from 'sinon'; -import { stubMethod } from '@salesforce/ts-sinon'; import { AnyFunction, AnyJson, @@ -291,9 +290,12 @@ export class TestContext { ); const orgMap = new Map(entries); - stubMethod(this.SANDBOX, OrgAccessor.prototype, 'getAllFiles').resolves([...orgMap.keys()].map((o) => `${o}.json`)); + // @ts-expect-error because private method + this.SANDBOX.stub(OrgAccessor.prototype, 'getAllFiles').resolves([...orgMap.keys()].map((o) => `${o}.json`)); - stubMethod(this.SANDBOX, OrgAccessor.prototype, 'hasFile').callsFake((username: string) => orgMap.has(username)); + this.SANDBOX.stub(OrgAccessor.prototype, 'hasFile').callsFake((username: string) => + Promise.resolve(orgMap.has(username)) + ); const retrieveContents = async function (this: { path: string }): Promise { const username = basename(this.path.replace('.json', '')); @@ -338,7 +340,8 @@ export class TestContext { }) ); - stubMethod(this.SANDBOX, User.prototype, 'retrieve').callsFake( + this.SANDBOX.stub(User.prototype, 'retrieve').callsFake( + // @ts-expect-error the real method guarantees a user, but find might not return one (username): Promise => Promise.resolve(mockUsers.find((org) => org.username === username)) ); @@ -359,7 +362,8 @@ export class TestContext { )) as Array<[string, SandboxFields]>; const sandboxMap = new Map(entries); - stubMethod(this.SANDBOX, SandboxAccessor.prototype, 'getAllFiles').resolves( + // @ts-expect-error because private method + this.SANDBOX.stub(SandboxAccessor.prototype, 'getAllFiles').resolves( [...sandboxMap.keys()].map((o) => `${o}.sandbox.json`) ); @@ -531,8 +535,8 @@ export const stubContext = (testContext: TestContext): Record const stubs: Record = {}; // Most core files create a child logger so stub this to return our test logger. - stubMethod(testContext.SANDBOX, Logger, 'child').resolves(testContext.TEST_LOGGER); - stubMethod(testContext.SANDBOX, Logger, 'childFromRoot').returns(testContext.TEST_LOGGER); + testContext.SANDBOX.stub(Logger, 'child').resolves(testContext.TEST_LOGGER); + testContext.SANDBOX.stub(Logger, 'childFromRoot').returns(testContext.TEST_LOGGER); testContext.inProject(true); testContext.SANDBOXES.CONFIG.stub(ConfigFile, 'resolveRootFolder').callsFake((isGlobal: boolean) => testContext.rootPathRetriever(isGlobal, testContext.id) @@ -541,7 +545,8 @@ export const stubContext = (testContext: TestContext): Record testContext.rootPathRetrieverSync(isGlobal, testContext.id) ); - stubMethod(testContext.SANDBOXES.PROJECT, SfProjectJson.prototype, 'doesPackageExist').callsFake(() => true); + // @ts-expect-error using private method + testContext.SANDBOXES.PROJECT.stub(SfProjectJson.prototype, 'doesPackageExist').callsFake(() => true); const initStubForRead = (configFile: ConfigFile): ConfigStub => { const stub: ConfigStub = testContext.configStubs[configFile.constructor.name] ?? {}; @@ -608,13 +613,13 @@ export const stubContext = (testContext: TestContext): Record } }; - stubs.configWriteSync = stubMethod(testContext.SANDBOXES.CONFIG, ConfigFile.prototype, 'writeSync').callsFake( - writeSync - ); + stubs.configWriteSync = testContext.SANDBOXES.CONFIG.stub(ConfigFile.prototype, 'writeSync').callsFake(writeSync); - stubs.configWrite = stubMethod(testContext.SANDBOXES.CONFIG, ConfigFile.prototype, 'write').callsFake(write); + stubs.configWrite = testContext.SANDBOXES.CONFIG.stub(ConfigFile.prototype, 'write').callsFake(write); - stubMethod(testContext.SANDBOXES.CRYPTO, Crypto.prototype, 'getKeyChain').callsFake(() => + // @ts-expect-error: getKeyChain is private + testContext.SANDBOXES.CRYPTO.stub(Crypto.prototype, 'getKeyChain').callsFake(() => + // @ts-expect-error: not the full type Promise.resolve({ setPassword: () => Promise.resolve(), getPassword: (data: Record, cb: AnyFunction) => @@ -622,9 +627,10 @@ export const stubContext = (testContext: TestContext): Record }) ); - stubMethod(testContext.SANDBOXES.CONNECTION, Connection.prototype, 'isResolvable').resolves(true); + testContext.SANDBOXES.CONNECTION.stub(Connection.prototype, 'isResolvable').resolves(true); - stubMethod(testContext.SANDBOXES.CONNECTION, Connection.prototype, 'request').callsFake(function ( + // @ts-expect-error: just enough of an httpResponse for testing + testContext.SANDBOXES.CONNECTION.stub(Connection.prototype, 'request').callsFake(function ( this: Connection, request: string, options?: Dictionary @@ -635,23 +641,25 @@ export const stubContext = (testContext: TestContext): Record return testContext.fakeConnectionRequest.call(this, request, options as AnyJson); }); - stubMethod(testContext.SANDBOX, aliasAccessorEntireFile, 'getFileLocation').returns(getAliasFileLocation()); + testContext.SANDBOX.stub(aliasAccessorEntireFile, 'getFileLocation').returns(getAliasFileLocation()); - stubs.configExists = stubMethod(testContext.SANDBOXES.ORGS, OrgAccessor.prototype, 'exists').callsFake( - async function (this: OrgAccessor, username: string): Promise { - // @ts-expect-error because private member - if ([...this.contents.keys()].includes(username)) return Promise.resolve(true); - else return Promise.resolve(false); - } - ); + stubs.configExists = testContext.SANDBOXES.ORGS.stub(OrgAccessor.prototype, 'exists').callsFake(async function ( + this: OrgAccessor, + username: string + ): Promise { + // @ts-expect-error because private member + if ([...this.contents.keys()].includes(username)) return Promise.resolve(true); + else return Promise.resolve(false); + }); - stubs.configRemove = stubMethod(testContext.SANDBOXES.ORGS, OrgAccessor.prototype, 'remove').callsFake( - async function (this: OrgAccessor, username: string): Promise { - // @ts-expect-error because private member - if ([...this.contents.keys()].includes(username)) return Promise.resolve(true); - else return Promise.resolve(false); - } - ); + stubs.configRemove = testContext.SANDBOXES.ORGS.stub(OrgAccessor.prototype, 'remove').callsFake(async function ( + this: OrgAccessor, + username: string + ): Promise { + // @ts-expect-error because private member + if ([...this.contents.keys()].includes(username)) return Promise.resolve(); + else return Promise.resolve(); + }); // Always start with the default and tests beforeEach or it methods can override it. testContext.fakeConnectionRequest = defaultFakeConnectionRequest; From 599f23c79458b8cf08a6e63b17cd18691dec6818 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Thu, 2 Nov 2023 11:52:25 -0500 Subject: [PATCH 2/9] test: mock throws when no user --- src/testSetup.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/testSetup.ts b/src/testSetup.ts index aa8d0c4007..a7beed37a2 100644 --- a/src/testSetup.ts +++ b/src/testSetup.ts @@ -340,10 +340,11 @@ export class TestContext { }) ); - this.SANDBOX.stub(User.prototype, 'retrieve').callsFake( - // @ts-expect-error the real method guarantees a user, but find might not return one - (username): Promise => Promise.resolve(mockUsers.find((org) => org.username === username)) - ); + this.SANDBOX.stub(User.prototype, 'retrieve').callsFake((username): Promise => { + const user = mockUsers.find((org) => org.username === username); + if (!user) throw new SfError('User not found', 'UserNotFoundError'); + return Promise.resolve(user); + }); const retrieveContents = async function (this: { path: string }): Promise<{ usernames?: string[] }> { const orgId = basename(this.path.replace('.json', '')); From d20ec2a1069a593ef7a7db33b429fc6913ca6d6b Mon Sep 17 00:00:00 2001 From: svc-cli-bot Date: Thu, 2 Nov 2023 17:51:35 +0000 Subject: [PATCH 3/9] chore(release): 5.3.17 [skip ci] --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6fcf3795a..9699d42333 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [5.3.17](https://github.com/forcedotcom/sfdx-core/compare/5.3.16...5.3.17) (2023-11-02) + + +### Bug Fixes + +* **deps:** testSetup has non ts-sinon dependency ([9fcb206](https://github.com/forcedotcom/sfdx-core/commit/9fcb206220174af1c20fcc041e127409a41c3593)) + + + ## [5.3.16](https://github.com/forcedotcom/sfdx-core/compare/5.3.15...5.3.16) (2023-10-29) diff --git a/package.json b/package.json index daaee3da38..2e25af1def 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@salesforce/core", - "version": "5.3.16", + "version": "5.3.17", "description": "Core libraries to interact with SFDX projects, orgs, and APIs.", "main": "lib/exported", "types": "lib/exported.d.ts", From 0041526a97693ca687aba04960b013a9768a580a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Nov 2023 21:30:19 +0000 Subject: [PATCH 4/9] chore(dev-deps): bump eslint from 8.52.0 to 8.53.0 Bumps [eslint](https://github.com/eslint/eslint) from 8.52.0 to 8.53.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.52.0...v8.53.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 2e25af1def..d936c7dd97 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "benchmark": "^2.1.4", "chai": "^4.3.10", "chai-string": "^1.5.0", - "eslint": "^8.52.0", + "eslint": "^8.53.0", "eslint-config-prettier": "^8.10.0", "eslint-config-salesforce": "^2.0.2", "eslint-config-salesforce-license": "^0.2.0", diff --git a/yarn.lock b/yarn.lock index 45ec55dfb7..aaa95cbfb4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -392,10 +392,10 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.6.2.tgz#1816b5f6948029c5eaacb0703b850ee0cb37d8f8" integrity sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw== -"@eslint/eslintrc@^2.1.2": - version "2.1.2" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.2.tgz#c6936b4b328c64496692f76944e755738be62396" - integrity sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g== +"@eslint/eslintrc@^2.1.3": + version "2.1.3" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.3.tgz#797470a75fe0fbd5a53350ee715e85e87baff22d" + integrity sha512-yZzuIG+jnVu6hNSzFEN07e8BxF3uAzYtQb6uDkaYZLo6oYZDCq454c5kB8zxnzfCYyP4MIuyBn10L0DqwujTmA== dependencies: ajv "^6.12.4" debug "^4.3.2" @@ -407,10 +407,10 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@8.52.0": - version "8.52.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.52.0.tgz#78fe5f117840f69dc4a353adf9b9cd926353378c" - integrity sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA== +"@eslint/js@8.53.0": + version "8.53.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.53.0.tgz#bea56f2ed2b5baea164348ff4d5a879f6f81f20d" + integrity sha512-Kn7K8dx/5U6+cT1yEhpX1w4PCSg0M+XyRILPgvwcEBjerFWCwQj5sbr3/VmxqV0JGHCBCzyd6LxypEuehypY1w== "@humanwhocodes/config-array@^0.11.13": version "0.11.13" @@ -1991,15 +1991,15 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4 resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint@^8.41.0, eslint@^8.52.0: - version "8.52.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.52.0.tgz#d0cd4a1fac06427a61ef9242b9353f36ea7062fc" - integrity sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg== +eslint@^8.41.0, eslint@^8.53.0: + version "8.53.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.53.0.tgz#14f2c8244298fcae1f46945459577413ba2697ce" + integrity sha512-N4VuiPjXDUa4xVeV/GC/RV3hQW9Nw+Y463lkWaKKXKYMvmRiRDAtfpuPFLN+E1/6ZhyR8J2ig+eVREnYgUsiag== dependencies: "@eslint-community/eslint-utils" "^4.2.0" "@eslint-community/regexpp" "^4.6.1" - "@eslint/eslintrc" "^2.1.2" - "@eslint/js" "8.52.0" + "@eslint/eslintrc" "^2.1.3" + "@eslint/js" "8.53.0" "@humanwhocodes/config-array" "^0.11.13" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" From c00387c4861f419e6a0e840d59db3148230fe79d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Nov 2023 21:30:40 +0000 Subject: [PATCH 5/9] chore(dev-deps): bump @types/chai-string from 1.4.3 to 1.4.4 Bumps [@types/chai-string](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/chai-string) from 1.4.3 to 1.4.4. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/chai-string) --- updated-dependencies: - dependency-name: "@types/chai-string" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2e25af1def..ad46cfca56 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@salesforce/prettier-config": "^0.0.3", "@salesforce/ts-sinon": "^1.4.18", "@types/benchmark": "^2.1.3", - "@types/chai-string": "^1.4.3", + "@types/chai-string": "^1.4.4", "@types/jsonwebtoken": "9.0.3", "@types/lodash": "^4.14.200", "@types/proper-lockfile": "^4.1.2", diff --git a/yarn.lock b/yarn.lock index 45ec55dfb7..2535176abb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -701,10 +701,10 @@ resolved "https://registry.yarnpkg.com/@types/benchmark/-/benchmark-2.1.3.tgz#7f62084640c509d5619ad33f4d4a29be044ecbe2" integrity sha512-psuUawgwIy/hSjO4AUDiPBJhJx72e3cBL+YzmVK/5ofRJC02R0NmvrSenGRuSmJc++0j95y2T01xKKNz50FGZw== -"@types/chai-string@^1.4.3": - version "1.4.3" - resolved "https://registry.yarnpkg.com/@types/chai-string/-/chai-string-1.4.3.tgz#06e02d74deed77c2bfccccae44ece6e57a8ecedd" - integrity sha512-bLp5xMQ7Ml0fWa05IPpLjIznTkNbuBE3GtRTzKrp0d10IavlBFcu9vXP2liWaXta79unO693q3kuRxD7g2YYGw== +"@types/chai-string@^1.4.4": + version "1.4.4" + resolved "https://registry.yarnpkg.com/@types/chai-string/-/chai-string-1.4.4.tgz#d0f332715d8c5bf890cbd9fa312292637945de31" + integrity sha512-dVLg4ukDw9y2uEtjq9nHV9pSOomguOhW5AxlWxEU7kYU6chZ0xGC1C7YptkCFEinFVoomJ8WCRUfmTipUqOOXw== dependencies: "@types/chai" "*" From a3be3922f96f8420eb871c413858eac395a95ad3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Nov 2023 21:30:49 +0000 Subject: [PATCH 6/9] fix(deps): bump @types/semver from 7.5.3 to 7.5.4 Bumps [@types/semver](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/semver) from 7.5.3 to 7.5.4. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/semver) --- updated-dependencies: - dependency-name: "@types/semver" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2e25af1def..98da77f13c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@salesforce/kit": "^3.0.15", "@salesforce/schemas": "^1.6.1", "@salesforce/ts-types": "^2.0.9", - "@types/semver": "^7.5.3", + "@types/semver": "^7.5.4", "ajv": "^8.12.0", "change-case": "^4.1.2", "faye": "^1.4.0", diff --git a/yarn.lock b/yarn.lock index 45ec55dfb7..debc6d55cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -795,10 +795,10 @@ resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.2.tgz#ed279a64fa438bb69f2480eda44937912bb7480a" integrity sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow== -"@types/semver@^7.3.12", "@types/semver@^7.5.3": - version "7.5.3" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.3.tgz#9a726e116beb26c24f1ccd6850201e1246122e04" - integrity sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw== +"@types/semver@^7.3.12", "@types/semver@^7.5.4": + version "7.5.4" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.4.tgz#0a41252ad431c473158b22f9bfb9a63df7541cff" + integrity sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ== "@types/shelljs@0.8.13": version "0.8.13" From 33a5e928f7f6a9210147f512fbe884449b8b6f35 Mon Sep 17 00:00:00 2001 From: svc-cli-bot Date: Sun, 5 Nov 2023 02:45:37 +0000 Subject: [PATCH 7/9] chore(release): 5.3.18 [skip ci] --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9699d42333..15d2731240 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [5.3.18](https://github.com/forcedotcom/sfdx-core/compare/5.3.17...5.3.18) (2023-11-05) + + +### Bug Fixes + +* **deps:** bump @types/semver from 7.5.3 to 7.5.4 ([a3be392](https://github.com/forcedotcom/sfdx-core/commit/a3be3922f96f8420eb871c413858eac395a95ad3)) + + + ## [5.3.17](https://github.com/forcedotcom/sfdx-core/compare/5.3.16...5.3.17) (2023-11-02) diff --git a/package.json b/package.json index 98da77f13c..864d11fc3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@salesforce/core", - "version": "5.3.17", + "version": "5.3.18", "description": "Core libraries to interact with SFDX projects, orgs, and APIs.", "main": "lib/exported", "types": "lib/exported.d.ts", From c2ef3a0f8fea0518b5eec2f6f515064e9741b46e Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Tue, 7 Nov 2023 14:41:38 -0700 Subject: [PATCH 8/9] fix: use memory logger instance when disabled --- src/logger/logger.ts | 6 ++++-- test/unit/loggerTest.ts | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/logger/logger.ts b/src/logger/logger.ts index f3ddad6b82..2ac684ee51 100644 --- a/src/logger/logger.ts +++ b/src/logger/logger.ts @@ -147,6 +147,8 @@ export class Logger { * `Logger`. */ public constructor(optionsOrName: LoggerOptions | string) { + const enabled = process.env.SFDX_DISABLE_LOG_FILE !== 'true' && process.env.SF_DISABLE_LOG_FILE !== 'true'; + const options: LoggerOptions = typeof optionsOrName === 'string' ? { name: optionsOrName, level: Logger.DEFAULT_LEVEL, fields: {} } @@ -167,9 +169,9 @@ export class Logger { name: options.name ?? Logger.ROOT_NAME, base: options.fields ?? {}, level, - enabled: process.env.SFDX_DISABLE_LOG_FILE !== 'true' && process.env.SF_DISABLE_LOG_FILE !== 'true', + enabled, }; - if (options.useMemoryLogger || Global.getEnvironmentMode() === Mode.TEST) { + if (options.useMemoryLogger || Global.getEnvironmentMode() === Mode.TEST || !enabled) { this.memoryLogger = new MemoryLogger(); this.pinoLogger = pino( { diff --git a/test/unit/loggerTest.ts b/test/unit/loggerTest.ts index c4e701a4af..68dbaeef76 100644 --- a/test/unit/loggerTest.ts +++ b/test/unit/loggerTest.ts @@ -45,6 +45,23 @@ describe('Logger', () => { const logger2 = await Logger.root(); expect(logger2).to.not.equal(logger1); }); + + describe('DISABLE_LOG_FILE', () => { + const LOG_FILES_DISABLED = process.env.SF_DISABLE_LOG_FILE; + before(() => { + process.env.SF_DISABLE_LOG_FILE = 'true'; + }); + after(() => { + process.env.SF_DISABLE_LOG_FILE = LOG_FILES_DISABLED; + }); + it('should construct a new named logger', async () => { + const logger1 = new Logger({ name: 'testLogger-noop' }); + expect(logger1).to.be.instanceof(Logger); + // @ts-expect-error testing a private property + expect(logger1.memoryLogger).to.be.ok; + expect(logger1.getName()).to.equal('testLogger-noop'); + }); + }); }); describe('levels', () => { From b3c1d6b38aed89b063858352a0b9bc845e814a0f Mon Sep 17 00:00:00 2001 From: svc-cli-bot Date: Wed, 8 Nov 2023 15:21:35 +0000 Subject: [PATCH 9/9] chore(release): 5.3.19 [skip ci] --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15d2731240..15581f7083 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [5.3.19](https://github.com/forcedotcom/sfdx-core/compare/5.3.18...5.3.19) (2023-11-08) + + +### Bug Fixes + +* use memory logger instance when disabled ([c2ef3a0](https://github.com/forcedotcom/sfdx-core/commit/c2ef3a0f8fea0518b5eec2f6f515064e9741b46e)) + + + ## [5.3.18](https://github.com/forcedotcom/sfdx-core/compare/5.3.17...5.3.18) (2023-11-05) diff --git a/package.json b/package.json index 78dbc152af..f0599099d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@salesforce/core", - "version": "5.3.18", + "version": "5.3.19", "description": "Core libraries to interact with SFDX projects, orgs, and APIs.", "main": "lib/exported", "types": "lib/exported.d.ts",