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
6 changes: 3 additions & 3 deletions src/commands/git/merge/driver/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PLUGIN_NAME } from '../../../../constant/pluginConstant.js'
import { MergeDriver } from '../../../../driver/MergeDriver.js'
import type { MergeConfig } from '../../../../types/conflictTypes.js'
import { log } from '../../../../utils/LoggingDecorator.js'
import { Logger } from '../../../../utils/LoggingService.js'
import { Logger, lazy } from '../../../../utils/LoggingService.js'

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
const messages = Messages.loadMessages(PLUGIN_NAME, 'run')
Expand Down Expand Up @@ -84,8 +84,8 @@ export default class Run extends SfCommand<void> {
otherConflictTag: flags['other-conflict-tag'],
}

Logger.debug(`flags: ${JSON.stringify(flags)}`)
Logger.debug(`config: ${JSON.stringify(config)}`)
Logger.debug(lazy`flags: ${() => JSON.stringify(flags)}`)
Logger.debug(lazy`config: ${() => JSON.stringify(config)}`)

const mergeDriver = new MergeDriver(config)
const hasConflict = await mergeDriver.mergeFiles(
Expand Down
42 changes: 0 additions & 42 deletions src/utils/LoggingDecorator.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,6 @@
/** biome-ignore-all lint/suspicious/noExplicitAny: it is dynamic by definition */
import { Logger, lazy } from './LoggingService.js'

export function stringify(value: unknown): string {
if (hasCustomToString(value)) {
return value.toString()
}
return JSON.stringify(value, replacer)
}

function replacer(_key: string, value: unknown): unknown {
if (value instanceof Map) {
return Array.from(value.entries())
}
if (value instanceof Set) {
return Array.from(value)
}
return value
}

export function hasCustomToString(
obj: unknown
): obj is { toString: () => string } {
if (obj === null || typeof obj !== 'object') return false

const toStringFn = (obj as any).toString
if (typeof toStringFn !== 'function') return false

if (Object.hasOwn(obj, 'toString')) {
return toStringFn !== Object.prototype.toString
}
const proto = Object.getPrototypeOf(obj)
const protoToString = proto.toString
return (
typeof protoToString === 'function' &&
protoToString !== Object.prototype.toString
)
}

export function log(
target: any,
propertyKey: string,
Expand All @@ -46,16 +10,10 @@ export function log(

descriptor.value = function (...args: any[]) {
Logger.trace(lazy`${target.constructor.name}.${propertyKey}: entry`)
Logger.debug(
lazy`${target.constructor.name}.${propertyKey}: arguments : ${stringify(args)}`
)

const call = () => original.call(this, ...args)

const logResult = (result: any) => {
Logger.debug(
lazy`${target.constructor.name}.${propertyKey}: result : ${stringify(result)}`
)
Logger.trace(lazy`${target.constructor.name}.${propertyKey}: exit`)
return result
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit/service/MetadataService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,12 @@ describe('MetadataService', () => {
testObject: { fullName: 'TestCustomFieldValue' },
expected: 'TestCustomFieldValue',
},
{
name: 'handles valueSettings with valueName (CustomField)',
metadataType: 'valueSettings',
testObject: { valueName: 'TestValueSetting' },
expected: 'TestValueSetting',
},
]

it.each(testCases)('$name', ({ metadataType, testObject, expected }) => {
Expand Down
Loading
Loading