rflib-plugin 0.13.3 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/lib/commands/rflib/logging/apex/instrument.d.ts +3 -0
- package/lib/commands/rflib/logging/apex/instrument.js +30 -3
- package/lib/commands/rflib/logging/apex/instrument.js.map +1 -1
- package/lib/commands/rflib/logging/aura/instrument.d.ts +3 -0
- package/lib/commands/rflib/logging/aura/instrument.js +44 -10
- package/lib/commands/rflib/logging/aura/instrument.js.map +1 -1
- package/lib/commands/rflib/logging/flow/instrument.d.ts +3 -0
- package/lib/commands/rflib/logging/flow/instrument.js +28 -5
- package/lib/commands/rflib/logging/flow/instrument.js.map +1 -1
- package/lib/commands/rflib/logging/lwc/instrument.d.ts +3 -0
- package/lib/commands/rflib/logging/lwc/instrument.js +26 -3
- package/lib/commands/rflib/logging/lwc/instrument.js.map +1 -1
- package/messages/rflib.logging.apex.instrument.md +16 -0
- package/messages/rflib.logging.aura.instrument.md +16 -0
- package/messages/rflib.logging.flow.instrument.md +16 -0
- package/messages/rflib.logging.lwc.instrument.md +16 -0
- package/oclif.lock +132 -131
- package/oclif.manifest.json +69 -1
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/aura/instrument.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAmBrC,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,Q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AE,CAAC;YAC3B,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,IAAI,CAAC;oBACH,MAAM,YAAY,GAAG,mBAAmB,CAAC,QAAQ;wBAC/C,CAAC,CAAC,MAAM,0BAA0B,CAAC,aAAa,CAAC,OAAO,CAAC;wBACzD,CAAC,CAAC,OAAO,CAAC;oBAEZ,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;oBAEpD,IAAI,mBAAmB,CAAC,QAAQ,EAAE,CAAC;wBACjC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;wBAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,QAAQ,EAAE,CAAC,CAAC;oBAC1D,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAC;oBAC5C,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,QAAQ,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;oBAC5G,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;oBAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,QAAQ,EAAE,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { SfCommand, Flags } from '@salesforce/sf-plugins-core';\nimport { Messages, Logger } from '@salesforce/core';\nimport * as prettier from 'prettier';\n\ntype IfCondition = {\n readonly condition: string;\n readonly position: number;\n}\n\ntype InstrumentationOptions = {\n readonly prettier: boolean;\n readonly noIf: boolean;\n readonly skipInstrumented: boolean;\n}\n\nexport type RflibLoggingAuraInstrumentResult = {\n processedFiles: number;\n modifiedFiles: number;\n formattedFiles: number;\n}\n\nMessages.importMessagesDirectoryFromMetaUrl(import.meta.url);\nconst messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.aura.instrument');\n\nclass AuraInstrumentationService {\n public static readonly ATTRIBUTE_REGEX = /<aura:attribute[^>]*>/g;\n public static readonly LOGGER_COMPONENT_REGEX =\n /<c:rflibLoggerCmp\\s+aura:id=\"([^\"]+)\"\\s+name=\"([^\"]+)\"\\s+appendComponentId=\"([^\"]+)\"\\s*\\/>/;\n\n private static readonly LOGGER_VAR_REGEX = /var\\s+(\\w+)\\s*=\\s*\\w+\\.find\\(['\"](\\w+)['\"]\\);/;\n private static readonly METHOD_REGEX =\n /(\\b\\w+)\\s*:\\s*function\\s*\\((.*?)\\)\\s*{((?:[^{}]|{(?:[^{}]|{(?:[^{}]|{(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})*})*})*?)}/g;\n private static readonly PROMISE_CHAIN_REGEX = /\\.(then|catch|finally)\\s*\\(\\s*function\\s*\\(([^)]*)\\)\\s*{([\\s\\S]*?)}/g;\n private static readonly TRY_CATCH_BLOCK_REGEX = /try\\s*{[\\s\\S]*?}\\s*catch\\s*\\(([^)]*)\\)\\s*{/g;\n private static readonly IF_STATEMENT_REGEX =\n /if\\s*\\((.*?)\\)\\s*(?:{([^]*?(?:(?<!{){(?:[^]*?)}(?!})[^]*?)*)}|([^{].*?)(?=\\s*(?:;|$));)/g;\n private static readonly ELSE_REGEX =\n /}\\s*else(?!\\s+if\\b)\\s*(?:{((?:[^{}]|{(?:[^{}]|{[^{}]*})*})*)}|([^{].*?)(?=\\n|;|$))/g;\n private static readonly CONSOLE_LOG_REGEX = /console\\.(log|debug|info|warn|error)\\s*\\(\\s*([^)]+)\\s*\\)\\s*;?/g;\n\n private static readonly PRETTIER_CONFIG: prettier.Options = {\n parser: 'babel',\n printWidth: 120,\n tabWidth: 4,\n useTabs: false,\n singleQuote: true,\n trailingComma: 'none',\n };\n\n public static isInstrumented(content: string, loggerId: string): boolean {\n return new RegExp(`\\\\.find\\\\(['\"]${loggerId}['\"]\\\\)`, 'g').test(content);\n }\n\n public static async formatContent(content: string): Promise<string> {\n try {\n return await prettier.format(content, this.PRETTIER_CONFIG);\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Formatting failed: ${error.message}`);\n }\n throw new Error('Formatting failed with unknown error');\n }\n }\n\n public static processMethodLogging(content: string, loggerId: string, isHelper: boolean, noIf: boolean): string {\n return content.replace(this.METHOD_REGEX, (match: string, methodName: string, params: string, body: string) => {\n const paramList = params\n .split(',')\n .map((p) => p.trim())\n .filter(Boolean);\n let loggerVar = 'logger';\n let bodyContent = body;\n\n const paramsToLog = isHelper ? paramList : paramList.slice(1, 2);\n const placeholders = paramsToLog.map((_, i) => `{${i}}`).join(', ');\n const logParams = paramsToLog.length > 0 ? `, [${paramsToLog.join(', ')}]` : '';\n\n const loggerMatch = body.match(this.LOGGER_VAR_REGEX);\n if (loggerMatch && loggerMatch[2] === loggerId) {\n loggerVar = loggerMatch[1];\n const loggerIndex = body.indexOf(loggerMatch[0]) + loggerMatch[0].length;\n bodyContent = `${body.slice(0, loggerIndex)}\\n ${loggerVar}.info('${methodName}(${placeholders})'${logParams});${body.slice(loggerIndex)}`;\n } else {\n const loggerInit = `var ${loggerVar} = ${paramList[0]}.find('${loggerId}');\\n`;\n bodyContent = `\\n ${loggerInit} ${loggerVar}.info('${methodName}(${placeholders})'${logParams});${body}`;\n }\n\n if (!noIf) {\n bodyContent = this.processIfStatements(bodyContent, loggerVar);\n }\n\n bodyContent = AuraInstrumentationService.processPromiseChains(bodyContent, loggerVar);\n bodyContent = AuraInstrumentationService.processConsoleStatements(bodyContent, loggerVar);\n\n return `${methodName}: function(${params}) {${bodyContent}}`;\n });\n }\n\n public static processPromiseChains(content: string, loggerVar: string): string {\n return content.replace(\n this.PROMISE_CHAIN_REGEX,\n (match: string, type: string, param: string, blockBody: string) => {\n const logStatement = this.processPromiseType(type, param?.trim() || '', loggerVar);\n\n return match.replace(blockBody, `\\n ${logStatement}\\n ${blockBody}`);\n },\n );\n }\n\n public static processTryCatchBlocks(content: string): string {\n return content.replace(this.TRY_CATCH_BLOCK_REGEX, (match: string, exceptionVar: string) => {\n const errorVar = exceptionVar.trim().split(' ')[0] || 'error';\n return match.replace(\n /catch\\s*\\(([^)]*)\\)\\s*{/,\n `catch(${exceptionVar}) {\n logger.error('An error occurred', ${errorVar});`,\n );\n });\n }\n\n private static processPromiseType(type: string, paramName: string, loggerVar: string): string {\n switch (type) {\n case 'then':\n return `${loggerVar}.info('Promise resolved. Result={0}', ${paramName});`;\n case 'catch':\n return `${loggerVar}.error('An error occurred', ${paramName});`;\n case 'finally':\n return `${loggerVar}.info('Promise chain completed');`;\n default:\n throw new Error(`Unsupported promise type: ${type}`);\n }\n }\n\n private static processIfStatements(content: string, loggerName: string): string {\n const conditions: IfCondition[] = [];\n\n let modified = content.replace(\n this.IF_STATEMENT_REGEX,\n (match: string, condition: string, blockBody: string, singleLineBody: string, offset: number) => {\n const cleanedUpCondition = condition.trim().replaceAll(\"'\", \"\\\\'\");\n conditions.push({ condition: cleanedUpCondition, position: offset });\n\n const logStatement = `${loggerName}.debug('if (${cleanedUpCondition})');\\n `;\n\n if (blockBody) {\n return `if (${condition}) {\\n ${logStatement}${blockBody}}`;\n } else if (singleLineBody) {\n const cleanBody = singleLineBody.replace(/;$/, '').trim();\n return `if (${condition}) {\\n ${logStatement}${cleanBody};\\n }`;\n }\n return match;\n },\n );\n\n modified = modified.replace(\n this.ELSE_REGEX,\n (match: string, blockBody: string, singleLineBody: string, offset: number) => {\n const nearestIf = conditions\n .filter((c) => c.position < offset)\n .reduce((prev, curr) => (!prev || curr.position > prev.position ? curr : prev));\n\n const logStatement = nearestIf\n ? `${loggerName}.debug('else for if (${nearestIf.condition})');\\n `\n : `${loggerName}.debug('else statement');\\n `;\n\n if (blockBody) {\n return `} else {\\n ${logStatement}${blockBody}}`;\n } else if (singleLineBody) {\n return `} else {\\n ${logStatement}${singleLineBody};\\n }`;\n }\n return match;\n },\n );\n\n return modified;\n }\n\n private static processConsoleStatements(methodBody: string, loggerName: string): string {\n return methodBody.replace(this.CONSOLE_LOG_REGEX, (match: string, logType: string, argument: string) => {\n const logLevel = logType === 'info' || logType === 'warn' || logType === 'error' ? logType : 'debug';\n return `${loggerName}.${logLevel}(${argument});`;\n });\n }\n}\n\nexport default class RflibLoggingAuraInstrument extends SfCommand<RflibLoggingAuraInstrumentResult> {\n public static readonly summary = messages.getMessage('summary');\n public static readonly description = messages.getMessage('description');\n public static readonly examples = messages.getMessages('examples');\n\n public static readonly flags = {\n sourcepath: Flags.string({\n char: 's',\n required: true,\n summary: messages.getMessage('flags.sourcepath.summary'),\n description: messages.getMessage('flags.sourcepath.description'),\n }),\n dryrun: Flags.boolean({\n char: 'd',\n default: false,\n summary: messages.getMessage('flags.dryrun.summary'),\n description: messages.getMessage('flags.dryrun.description'),\n }),\n prettier: Flags.boolean({\n char: 'p',\n default: false,\n summary: messages.getMessage('flags.prettier.summary'),\n description: messages.getMessage('flags.prettier.description'),\n }),\n 'no-if': Flags.boolean({\n summary: messages.getMessage('flags.no-if.summary'),\n description: messages.getMessage('flags.no-if.description'),\n default: false,\n }),\n 'skip-instrumented': Flags.boolean({\n summary: messages.getMessage('flags.skip-instrumented.summary'),\n description: messages.getMessage('flags.skip-instrumented.description'),\n default: false,\n }),\n };\n\n private logger!: Logger;\n private readonly stats: RflibLoggingAuraInstrumentResult = {\n processedFiles: 0,\n modifiedFiles: 0,\n formattedFiles: 0,\n };\n\n public async run(): Promise<RflibLoggingAuraInstrumentResult> {\n this.logger = await Logger.child(this.ctor.name);\n const { flags } = await this.parse(RflibLoggingAuraInstrument);\n\n const instrumentationOpts: InstrumentationOptions = {\n prettier: flags.prettier,\n noIf: flags['no-if'],\n skipInstrumented: flags['skip-instrumented'],\n };\n\n this.log(`Starting Aura component instrumentation in ${flags.sourcepath}`);\n this.logger.debug(`Dry run mode: ${flags.dryrun}`);\n\n this.spinner.start('Running...');\n\n const components = await this.findAllAuraComponents(flags.sourcepath);\n await Promise.all(\n components.map(async (component) => {\n await this.processAuraComponent(component.path, component.name, flags.dryrun, instrumentationOpts);\n })\n );\n\n this.spinner.stop();\n\n this.log('\\nInstrumentation complete.');\n this.log(`Processed files: ${this.stats.processedFiles}`);\n this.log(`Modified files: ${this.stats.modifiedFiles}`);\n this.log(`Formatted files: ${this.stats.formattedFiles}`);\n\n return { ...this.stats };\n }\n\n private async findAllAuraComponents(dirPath: string): Promise<Array<{ path: string; name: string }>> {\n this.logger.debug(`Scanning directory: ${dirPath}`);\n\n const dirName = path.basename(dirPath);\n const parentName = path.basename(path.dirname(dirPath));\n\n // Case 1: The sourcepath points directly to a component (inside an 'aura' folder)\n if (parentName === 'aura') {\n return [{\n path: dirPath,\n name: dirName\n }];\n }\n\n // Case 2: The sourcepath points to an 'aura' folder\n if (dirName === 'aura') {\n const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });\n const components = await Promise.all(\n entries\n .filter(entry => entry.isDirectory())\n .map(entry => ({\n path: path.join(dirPath, entry.name),\n name: entry.name\n }))\n );\n return components;\n }\n\n // Case 3: Recursion\n const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });\n const results = await Promise.all(\n entries.map(async (entry) => {\n if (entry.isDirectory()) {\n return this.findAllAuraComponents(path.join(dirPath, entry.name));\n }\n return [];\n })\n );\n\n return results.flat();\n }\n\n private async processAuraComponent(\n componentPath: string,\n componentName: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n this.logger.info(`Processing Aura component: ${componentName}`);\n\n const cmpPath = path.join(componentPath, `${componentName}.cmp`);\n const controllerPath = path.join(componentPath, `${componentName}Controller.js`);\n const helperPath = path.join(componentPath, `${componentName}Helper.js`);\n const rendererPath = path.join(componentPath, `${componentName}Renderer.js`);\n\n try {\n const loggerId = await this.instrumentCmpFile(cmpPath, componentName, isDryRun);\n this.logger.debug(`Using logger ID: ${loggerId}`);\n\n await Promise.all([\n this.instrumentJsFile(controllerPath, loggerId, isDryRun, instrumentationOpts),\n this.instrumentJsFile(helperPath, loggerId, isDryRun, instrumentationOpts),\n this.instrumentJsFile(rendererPath, loggerId, isDryRun, instrumentationOpts),\n ]);\n } catch (error) {\n this.logger.error(`Error processing Aura component ${componentName}`, error);\n throw error;\n }\n }\n\n private async instrumentCmpFile(filePath: string, componentName: string, isDryRun: boolean): Promise<string> {\n if (!fs.existsSync(filePath)) {\n this.logger.warn(`Component file not found: ${filePath}`);\n return 'logger';\n }\n\n this.logger.debug(`Instrumenting component file: ${filePath}`);\n this.stats.processedFiles++;\n\n let content = await fs.promises.readFile(filePath, 'utf8');\n const originalContent = content;\n\n const loggerMatch = content.match(AuraInstrumentationService.LOGGER_COMPONENT_REGEX);\n if (loggerMatch) {\n return loggerMatch[1];\n }\n\n const lastAttributeMatch = [...content.matchAll(AuraInstrumentationService.ATTRIBUTE_REGEX)].pop();\n if (lastAttributeMatch) {\n const insertPosition = lastAttributeMatch.index + lastAttributeMatch[0].length;\n const loggerComponent = `\\n <c:rflibLoggerCmp aura:id=\"logger\" name=\"${componentName}\" appendComponentId=\"false\" />`;\n content = content.slice(0, insertPosition) + loggerComponent + content.slice(insertPosition);\n }\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n if (!isDryRun) {\n await fs.promises.writeFile(filePath, content, 'utf8');\n this.logger.info(`Modified component file: ${filePath}`);\n } else {\n this.logger.info(`Would modify component file: ${filePath}`);\n }\n }\n\n return 'logger';\n }\n\n private async instrumentJsFile(\n filePath: string,\n loggerId: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n if (!fs.existsSync(filePath)) {\n this.logger.debug(`JavaScript file not found: ${filePath}`);\n return;\n }\n\n this.logger.debug(`Instrumenting JavaScript file: ${filePath}`);\n this.stats.processedFiles++;\n\n let content = await fs.promises.readFile(filePath, 'utf8');\n\n if (instrumentationOpts.skipInstrumented && AuraInstrumentationService.isInstrumented(content, loggerId)) {\n this.logger.info(`Skipping instrumented file: ${filePath}`);\n return;\n }\n\n const originalContent = content;\n const isHelper = filePath.endsWith('Helper.js');\n\n // Process methods and other patterns\n content = AuraInstrumentationService.processMethodLogging(content, loggerId, isHelper, instrumentationOpts.noIf);\n content = AuraInstrumentationService.processTryCatchBlocks(content);\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n if (!isDryRun) {\n try {\n const finalContent = instrumentationOpts.prettier\n ? await AuraInstrumentationService.formatContent(content)\n : content;\n\n await fs.promises.writeFile(filePath, finalContent);\n\n if (instrumentationOpts.prettier) {\n this.stats.formattedFiles++;\n this.logger.info(`Modified and formatted: ${filePath}`);\n } else {\n this.logger.info(`Modified: ${filePath}`);\n }\n } catch (error) {\n this.logger.warn(`Failed to format ${filePath}: ${error instanceof Error ? error.message : String(error)}`);\n await fs.promises.writeFile(filePath, content);\n this.logger.info(`Modified without formatting: ${filePath}`);\n }\n } else {\n this.logger.info(`Would modify: ${filePath}`);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/aura/instrument.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAsBtC,QA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E,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;gBAC9C,IAAI,mBAAmB,CAAC,OAAO,EAAE,CAAC;oBAChC,IAAI,CAAC,GAAG,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { SfCommand, Flags } from '@salesforce/sf-plugins-core';\nimport { Messages, Logger } from '@salesforce/core';\nimport * as prettier from 'prettier';\nimport { minimatch } from 'minimatch';\n\ntype IfCondition = {\n readonly condition: string;\n readonly position: number;\n}\n\ntype InstrumentationOptions = {\n readonly prettier: boolean;\n readonly noIf: boolean;\n readonly skipInstrumented: boolean;\n readonly verbose: boolean;\n readonly exclude?: string;\n}\n\nexport type RflibLoggingAuraInstrumentResult = {\n processedFiles: number;\n modifiedFiles: number;\n formattedFiles: number;\n modifiedFilePaths?: string[];\n}\n\nMessages.importMessagesDirectoryFromMetaUrl(import.meta.url);\nconst messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.aura.instrument');\n\nclass AuraInstrumentationService {\n public static readonly ATTRIBUTE_REGEX = /<aura:attribute[^>]*>/g;\n public static readonly LOGGER_COMPONENT_REGEX =\n /<c:rflibLoggerCmp\\s+aura:id=\"([^\"]+)\"\\s+name=\"([^\"]+)\"\\s+appendComponentId=\"([^\"]+)\"\\s*\\/>/;\n\n private static readonly LOGGER_VAR_REGEX = /var\\s+(\\w+)\\s*=\\s*\\w+\\.find\\(['\"](\\w+)['\"]\\);/;\n private static readonly METHOD_REGEX =\n /(\\b\\w+)\\s*:\\s*function\\s*\\((.*?)\\)\\s*{((?:[^{}]|{(?:[^{}]|{(?:[^{}]|{(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})*})*})*?)}/g;\n private static readonly PROMISE_CHAIN_REGEX = /\\.(then|catch|finally)\\s*\\(\\s*function\\s*\\(([^)]*)\\)\\s*{([\\s\\S]*?)}/g;\n private static readonly TRY_CATCH_BLOCK_REGEX = /try\\s*{[\\s\\S]*?}\\s*catch\\s*\\(([^)]*)\\)\\s*{/g;\n private static readonly IF_STATEMENT_REGEX =\n /if\\s*\\((.*?)\\)\\s*(?:{([^]*?(?:(?<!{){(?:[^]*?)}(?!})[^]*?)*)}|([^{].*?)(?=\\s*(?:;|$));)/g;\n private static readonly ELSE_REGEX =\n /}\\s*else(?!\\s+if\\b)\\s*(?:{((?:[^{}]|{(?:[^{}]|{[^{}]*})*})*)}|([^{].*?)(?=\\n|;|$))/g;\n private static readonly CONSOLE_LOG_REGEX = /console\\.(log|debug|info|warn|error)\\s*\\(\\s*([^)]+)\\s*\\)\\s*;?/g;\n\n private static readonly PRETTIER_CONFIG: prettier.Options = {\n parser: 'babel',\n printWidth: 120,\n tabWidth: 4,\n useTabs: false,\n singleQuote: true,\n trailingComma: 'none',\n };\n\n public static isInstrumented(content: string, loggerId: string): boolean {\n return new RegExp(`\\\\.find\\\\(['\"]${loggerId}['\"]\\\\)`, 'g').test(content);\n }\n\n public static async formatContent(content: string): Promise<string> {\n try {\n return await prettier.format(content, this.PRETTIER_CONFIG);\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Formatting failed: ${error.message}`);\n }\n throw new Error('Formatting failed with unknown error');\n }\n }\n\n public static processMethodLogging(content: string, loggerId: string, isHelper: boolean, noIf: boolean): string {\n return content.replace(this.METHOD_REGEX, (match: string, methodName: string, params: string, body: string) => {\n const paramList = params\n .split(',')\n .map((p) => p.trim())\n .filter(Boolean);\n let loggerVar = 'logger';\n let bodyContent = body;\n\n const paramsToLog = isHelper ? paramList : paramList.slice(1, 2);\n const placeholders = paramsToLog.map((_, i) => `{${i}}`).join(', ');\n const logParams = paramsToLog.length > 0 ? `, [${paramsToLog.join(', ')}]` : '';\n\n const loggerMatch = body.match(this.LOGGER_VAR_REGEX);\n if (loggerMatch && loggerMatch[2] === loggerId) {\n loggerVar = loggerMatch[1];\n const loggerIndex = body.indexOf(loggerMatch[0]) + loggerMatch[0].length;\n bodyContent = `${body.slice(0, loggerIndex)}\\n ${loggerVar}.info('${methodName}(${placeholders})'${logParams});${body.slice(loggerIndex)}`;\n } else {\n const loggerInit = `var ${loggerVar} = ${paramList[0]}.find('${loggerId}');\\n`;\n bodyContent = `\\n ${loggerInit} ${loggerVar}.info('${methodName}(${placeholders})'${logParams});${body}`;\n }\n\n if (!noIf) {\n bodyContent = this.processIfStatements(bodyContent, loggerVar);\n }\n\n bodyContent = AuraInstrumentationService.processPromiseChains(bodyContent, loggerVar);\n bodyContent = AuraInstrumentationService.processConsoleStatements(bodyContent, loggerVar);\n\n return `${methodName}: function(${params}) {${bodyContent}}`;\n });\n }\n\n public static processPromiseChains(content: string, loggerVar: string): string {\n return content.replace(\n this.PROMISE_CHAIN_REGEX,\n (match: string, type: string, param: string, blockBody: string) => {\n const logStatement = this.processPromiseType(type, param?.trim() || '', loggerVar);\n\n return match.replace(blockBody, `\\n ${logStatement}\\n ${blockBody}`);\n },\n );\n }\n\n public static processTryCatchBlocks(content: string): string {\n return content.replace(this.TRY_CATCH_BLOCK_REGEX, (match: string, exceptionVar: string) => {\n const errorVar = exceptionVar.trim().split(' ')[0] || 'error';\n return match.replace(\n /catch\\s*\\(([^)]*)\\)\\s*{/,\n `catch(${exceptionVar}) {\n logger.error('An error occurred', ${errorVar});`,\n );\n });\n }\n\n private static processPromiseType(type: string, paramName: string, loggerVar: string): string {\n switch (type) {\n case 'then':\n return `${loggerVar}.info('Promise resolved. Result={0}', ${paramName});`;\n case 'catch':\n return `${loggerVar}.error('An error occurred', ${paramName});`;\n case 'finally':\n return `${loggerVar}.info('Promise chain completed');`;\n default:\n throw new Error(`Unsupported promise type: ${type}`);\n }\n }\n\n private static processIfStatements(content: string, loggerName: string): string {\n const conditions: IfCondition[] = [];\n\n let modified = content.replace(\n this.IF_STATEMENT_REGEX,\n (match: string, condition: string, blockBody: string, singleLineBody: string, offset: number) => {\n const cleanedUpCondition = condition.trim().replaceAll(\"'\", \"\\\\'\");\n conditions.push({ condition: cleanedUpCondition, position: offset });\n\n const logStatement = `${loggerName}.debug('if (${cleanedUpCondition})');\\n `;\n\n if (blockBody) {\n return `if (${condition}) {\\n ${logStatement}${blockBody}}`;\n } else if (singleLineBody) {\n const cleanBody = singleLineBody.replace(/;$/, '').trim();\n return `if (${condition}) {\\n ${logStatement}${cleanBody};\\n }`;\n }\n return match;\n },\n );\n\n modified = modified.replace(\n this.ELSE_REGEX,\n (match: string, blockBody: string, singleLineBody: string, offset: number) => {\n const nearestIf = conditions\n .filter((c) => c.position < offset)\n .reduce((prev, curr) => (!prev || curr.position > prev.position ? curr : prev));\n\n const logStatement = nearestIf\n ? `${loggerName}.debug('else for if (${nearestIf.condition})');\\n `\n : `${loggerName}.debug('else statement');\\n `;\n\n if (blockBody) {\n return `} else {\\n ${logStatement}${blockBody}}`;\n } else if (singleLineBody) {\n return `} else {\\n ${logStatement}${singleLineBody};\\n }`;\n }\n return match;\n },\n );\n\n return modified;\n }\n\n private static processConsoleStatements(methodBody: string, loggerName: string): string {\n return methodBody.replace(this.CONSOLE_LOG_REGEX, (match: string, logType: string, argument: string) => {\n const logLevel = logType === 'info' || logType === 'warn' || logType === 'error' ? logType : 'debug';\n return `${loggerName}.${logLevel}(${argument});`;\n });\n }\n}\n\nexport default class RflibLoggingAuraInstrument extends SfCommand<RflibLoggingAuraInstrumentResult> {\n public static readonly summary = messages.getMessage('summary');\n public static readonly description = messages.getMessage('description');\n public static readonly examples = messages.getMessages('examples');\n\n public static readonly flags = {\n sourcepath: Flags.string({\n char: 's',\n required: true,\n summary: messages.getMessage('flags.sourcepath.summary'),\n description: messages.getMessage('flags.sourcepath.description'),\n }),\n dryrun: Flags.boolean({\n char: 'd',\n default: false,\n summary: messages.getMessage('flags.dryrun.summary'),\n description: messages.getMessage('flags.dryrun.description'),\n }),\n prettier: Flags.boolean({\n char: 'p',\n default: false,\n summary: messages.getMessage('flags.prettier.summary'),\n description: messages.getMessage('flags.prettier.description'),\n }),\n 'no-if': Flags.boolean({\n summary: messages.getMessage('flags.no-if.summary'),\n description: messages.getMessage('flags.no-if.description'),\n default: false,\n }),\n 'skip-instrumented': Flags.boolean({\n summary: messages.getMessage('flags.skip-instrumented.summary'),\n description: messages.getMessage('flags.skip-instrumented.description'),\n default: false,\n }),\n verbose: Flags.boolean({\n summary: messages.getMessage('flags.verbose.summary'),\n description: messages.getMessage('flags.verbose.description'),\n char: 'v',\n default: false,\n }),\n exclude: Flags.string({\n summary: messages.getMessage('flags.exclude.summary'),\n description: messages.getMessage('flags.exclude.description'),\n char: 'e',\n }),\n };\n\n private logger!: Logger;\n private readonly stats: RflibLoggingAuraInstrumentResult = {\n processedFiles: 0,\n modifiedFiles: 0,\n formattedFiles: 0,\n modifiedFilePaths: [],\n };\n\n public async run(): Promise<RflibLoggingAuraInstrumentResult> {\n this.logger = await Logger.child(this.ctor.name);\n const { flags } = await this.parse(RflibLoggingAuraInstrument);\n\n const instrumentationOpts: InstrumentationOptions = {\n prettier: flags.prettier,\n noIf: flags['no-if'],\n skipInstrumented: flags['skip-instrumented'],\n verbose: flags.verbose,\n exclude: flags.exclude,\n };\n\n this.log(`Starting Aura component instrumentation in ${flags.sourcepath}`);\n this.logger.debug(`Dry run mode: ${flags.dryrun}`);\n\n this.spinner.start('Running...');\n\n const components = await this.findAllAuraComponents(flags.sourcepath, instrumentationOpts.exclude);\n await Promise.all(\n components.map(async (component) => {\n await this.processAuraComponent(component.path, component.name, flags.dryrun, instrumentationOpts);\n })\n );\n\n this.spinner.stop();\n\n this.log('\\nInstrumentation complete.');\n this.log(`Processed files: ${this.stats.processedFiles}`);\n this.log(`Modified files: ${this.stats.modifiedFiles}`);\n this.log(`Formatted files: ${this.stats.formattedFiles}`);\n\n return { ...this.stats };\n }\n\n private async findAllAuraComponents(dirPath: string, excludePattern?: string): Promise<Array<{ path: string; name: string }>> {\n this.logger.debug(`Scanning directory: ${dirPath}`);\n\n const dirName = path.basename(dirPath);\n const parentName = path.basename(path.dirname(dirPath));\n\n // Case 1: The sourcepath points directly to a component (inside an 'aura' folder)\n if (parentName === 'aura') {\n if (excludePattern && minimatch(dirPath, excludePattern, { matchBase: true })) {\n this.logger.debug(`Skipping excluded path: ${dirPath}`);\n return [];\n }\n return [{\n path: dirPath,\n name: dirName\n }];\n }\n\n // Case 2: The sourcepath points to an 'aura' folder\n if (dirName === 'aura') {\n const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });\n const components = await Promise.all(\n entries\n .filter(entry => entry.isDirectory())\n .map(entry => {\n const cmpPath = path.join(dirPath, entry.name);\n if (excludePattern && minimatch(cmpPath, excludePattern, { matchBase: true })) {\n this.logger.debug(`Skipping excluded path: ${cmpPath}`);\n return null;\n }\n return {\n path: cmpPath,\n name: entry.name\n };\n })\n );\n return components.filter((c): c is { path: string; name: string } => c !== null);\n }\n\n // Case 3: Recursion\n const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });\n const results = await Promise.all(\n entries.map(async (entry) => {\n if (entry.isDirectory()) {\n return this.findAllAuraComponents(path.join(dirPath, entry.name), excludePattern);\n }\n return [];\n })\n );\n\n return results.flat();\n }\n\n private async processAuraComponent(\n componentPath: string,\n componentName: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n this.logger.info(`Processing Aura component: ${componentName}`);\n\n const cmpPath = path.join(componentPath, `${componentName}.cmp`);\n const controllerPath = path.join(componentPath, `${componentName}Controller.js`);\n const helperPath = path.join(componentPath, `${componentName}Helper.js`);\n const rendererPath = path.join(componentPath, `${componentName}Renderer.js`);\n\n try {\n const loggerId = await this.instrumentCmpFile(cmpPath, componentName, isDryRun, instrumentationOpts);\n this.logger.debug(`Using logger ID: ${loggerId}`);\n\n await Promise.all([\n this.instrumentJsFile(controllerPath, loggerId, isDryRun, instrumentationOpts),\n this.instrumentJsFile(helperPath, loggerId, isDryRun, instrumentationOpts),\n this.instrumentJsFile(rendererPath, loggerId, isDryRun, instrumentationOpts),\n ]);\n } catch (error) {\n this.logger.error(`Error processing Aura component ${componentName}`, error);\n throw error;\n }\n }\n\n private async instrumentCmpFile(filePath: string, componentName: string, isDryRun: boolean, instrumentationOpts: InstrumentationOptions): Promise<string> {\n if (!fs.existsSync(filePath)) {\n this.logger.warn(`Component file not found: ${filePath}`);\n return 'logger';\n }\n\n this.logger.debug(`Instrumenting component file: ${filePath}`);\n this.stats.processedFiles++;\n\n let content = await fs.promises.readFile(filePath, 'utf8');\n const originalContent = content;\n\n const loggerMatch = content.match(AuraInstrumentationService.LOGGER_COMPONENT_REGEX);\n if (loggerMatch) {\n return loggerMatch[1];\n }\n\n const lastAttributeMatch = [...content.matchAll(AuraInstrumentationService.ATTRIBUTE_REGEX)].pop();\n if (lastAttributeMatch) {\n const insertPosition = lastAttributeMatch.index + lastAttributeMatch[0].length;\n const loggerComponent = `\\n <c:rflibLoggerCmp aura:id=\"logger\" name=\"${componentName}\" appendComponentId=\"false\" />`;\n content = content.slice(0, insertPosition) + loggerComponent + content.slice(insertPosition);\n }\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n this.stats.modifiedFilePaths?.push(filePath);\n if (!isDryRun) {\n await fs.promises.writeFile(filePath, content, 'utf8');\n this.logger.info(`Modified component file: ${filePath}`);\n } else {\n this.logger.info(`Would modify component file: ${filePath}`);\n if (instrumentationOpts.verbose) {\n this.log(`Would modify component file: ${filePath}`);\n }\n }\n }\n\n return 'logger';\n }\n\n private async instrumentJsFile(\n filePath: string,\n loggerId: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n if (!fs.existsSync(filePath)) {\n this.logger.debug(`JavaScript file not found: ${filePath}`);\n return;\n }\n\n this.logger.debug(`Instrumenting JavaScript file: ${filePath}`);\n this.stats.processedFiles++;\n\n let content = await fs.promises.readFile(filePath, 'utf8');\n\n if (instrumentationOpts.skipInstrumented && AuraInstrumentationService.isInstrumented(content, loggerId)) {\n this.logger.info(`Skipping instrumented file: ${filePath}`);\n return;\n }\n\n const originalContent = content;\n const isHelper = filePath.endsWith('Helper.js');\n\n // Process methods and other patterns\n content = AuraInstrumentationService.processMethodLogging(content, loggerId, isHelper, instrumentationOpts.noIf);\n content = AuraInstrumentationService.processTryCatchBlocks(content);\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n this.stats.modifiedFilePaths?.push(filePath);\n if (!isDryRun) {\n try {\n const finalContent = instrumentationOpts.prettier\n ? await AuraInstrumentationService.formatContent(content)\n : content;\n\n await fs.promises.writeFile(filePath, finalContent);\n\n if (instrumentationOpts.prettier) {\n this.stats.formattedFiles++;\n this.logger.info(`Modified and formatted: ${filePath}`);\n } else {\n this.logger.info(`Modified: ${filePath}`);\n }\n } catch (error) {\n this.logger.warn(`Failed to format ${filePath}: ${error instanceof Error ? error.message : String(error)}`);\n await fs.promises.writeFile(filePath, content);\n this.logger.info(`Modified without formatting: ${filePath}`);\n }\n } else {\n this.logger.info(`Would modify: ${filePath}`);\n if (instrumentationOpts.verbose) {\n this.log(`Would modify: ${filePath}`);\n }\n }\n }\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
|
2
2
|
export type RflibLoggingFlowInstrumentResult = {
|
|
3
3
|
processedFiles: number;
|
|
4
4
|
modifiedFiles: number;
|
|
5
|
+
modifiedFilePaths?: string[];
|
|
5
6
|
};
|
|
6
7
|
export declare class FlowInstrumentationService {
|
|
7
8
|
private static readonly parser;
|
|
@@ -29,6 +30,8 @@ export default class RflibLoggingFlowInstrument extends SfCommand<RflibLoggingFl
|
|
|
29
30
|
sourcepath: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
31
|
dryrun: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
31
32
|
'skip-instrumented': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
34
|
+
exclude: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
35
|
};
|
|
33
36
|
private logger;
|
|
34
37
|
private readonly stats;
|
|
@@ -10,6 +10,7 @@ import * as path from 'node:path';
|
|
|
10
10
|
import { Messages, Logger } from '@salesforce/core';
|
|
11
11
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
12
12
|
import * as xml2js from 'xml2js';
|
|
13
|
+
import { minimatch } from 'minimatch';
|
|
13
14
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
14
15
|
const messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.flow.instrument');
|
|
15
16
|
export class FlowInstrumentationService {
|
|
@@ -529,11 +530,23 @@ export default class RflibLoggingFlowInstrument extends SfCommand {
|
|
|
529
530
|
description: messages.getMessage('flags.skip-instrumented.description') || 'Do not instrument flows where RFLIB logging is already present',
|
|
530
531
|
default: false,
|
|
531
532
|
}),
|
|
533
|
+
verbose: Flags.boolean({
|
|
534
|
+
summary: messages.getMessage('flags.verbose.summary'),
|
|
535
|
+
description: messages.getMessage('flags.verbose.description'),
|
|
536
|
+
char: 'v',
|
|
537
|
+
default: false,
|
|
538
|
+
}),
|
|
539
|
+
exclude: Flags.string({
|
|
540
|
+
summary: messages.getMessage('flags.exclude.summary'),
|
|
541
|
+
description: messages.getMessage('flags.exclude.description'),
|
|
542
|
+
char: 'e',
|
|
543
|
+
}),
|
|
532
544
|
};
|
|
533
545
|
logger;
|
|
534
546
|
stats = {
|
|
535
547
|
processedFiles: 0,
|
|
536
548
|
modifiedFiles: 0,
|
|
549
|
+
modifiedFilePaths: [],
|
|
537
550
|
};
|
|
538
551
|
async run() {
|
|
539
552
|
this.logger = await Logger.child(this.ctor.name);
|
|
@@ -542,13 +555,15 @@ export default class RflibLoggingFlowInstrument extends SfCommand {
|
|
|
542
555
|
const sourcePath = flags.sourcepath;
|
|
543
556
|
const isDryRun = flags.dryrun;
|
|
544
557
|
const skipInstrumented = flags['skip-instrumented'];
|
|
558
|
+
const isVerbose = flags.verbose;
|
|
559
|
+
const excludePattern = flags.exclude;
|
|
545
560
|
this.log(`Scanning Flow files in ${sourcePath} and sub directories`);
|
|
546
561
|
this.logger.debug(`Dry run mode: ${isDryRun}`);
|
|
547
562
|
this.logger.debug(`Skip instrumented: ${skipInstrumented}`);
|
|
548
563
|
this.spinner.start('Running...');
|
|
549
|
-
const files = await this.findAllFlowFiles(sourcePath);
|
|
564
|
+
const files = await this.findAllFlowFiles(sourcePath, excludePattern);
|
|
550
565
|
await Promise.all(files.map(async (filePath) => {
|
|
551
|
-
await this.instrumentFlowFile(filePath, isDryRun, skipInstrumented);
|
|
566
|
+
await this.instrumentFlowFile(filePath, isDryRun, skipInstrumented, isVerbose);
|
|
552
567
|
}));
|
|
553
568
|
this.spinner.stop();
|
|
554
569
|
const duration = Date.now() - startTime;
|
|
@@ -558,13 +573,17 @@ export default class RflibLoggingFlowInstrument extends SfCommand {
|
|
|
558
573
|
this.log(`Modified files: ${this.stats.modifiedFiles}`);
|
|
559
574
|
return { ...this.stats };
|
|
560
575
|
}
|
|
561
|
-
async findAllFlowFiles(dirPath) {
|
|
576
|
+
async findAllFlowFiles(dirPath, excludePattern) {
|
|
562
577
|
this.logger.debug(`Scanning directory: ${dirPath}`);
|
|
563
578
|
const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
|
|
564
579
|
const results = await Promise.all(entries.map(async (entry) => {
|
|
565
580
|
const filePath = path.join(dirPath, entry.name);
|
|
581
|
+
if (excludePattern && minimatch(filePath, excludePattern, { matchBase: true })) {
|
|
582
|
+
this.logger.debug(`Skipping excluded path: ${filePath}`);
|
|
583
|
+
return [];
|
|
584
|
+
}
|
|
566
585
|
if (entry.isDirectory()) {
|
|
567
|
-
return this.findAllFlowFiles(filePath);
|
|
586
|
+
return this.findAllFlowFiles(filePath, excludePattern);
|
|
568
587
|
}
|
|
569
588
|
if (entry.name.endsWith('.flow-meta.xml')) {
|
|
570
589
|
return [filePath];
|
|
@@ -573,7 +592,7 @@ export default class RflibLoggingFlowInstrument extends SfCommand {
|
|
|
573
592
|
}));
|
|
574
593
|
return results.flat();
|
|
575
594
|
}
|
|
576
|
-
async instrumentFlowFile(filePath, isDryRun, skipInstrumented) {
|
|
595
|
+
async instrumentFlowFile(filePath, isDryRun, skipInstrumented, isVerbose) {
|
|
577
596
|
const flowName = path.basename(filePath, '.flow-meta.xml');
|
|
578
597
|
this.logger.debug(`Processing flow: ${flowName}`);
|
|
579
598
|
try {
|
|
@@ -594,12 +613,16 @@ export default class RflibLoggingFlowInstrument extends SfCommand {
|
|
|
594
613
|
const newContent = FlowInstrumentationService.buildFlowContent(instrumentedFlow);
|
|
595
614
|
if (content !== newContent) {
|
|
596
615
|
this.stats.modifiedFiles++;
|
|
616
|
+
this.stats.modifiedFilePaths?.push(filePath);
|
|
597
617
|
if (!isDryRun) {
|
|
598
618
|
await fs.promises.writeFile(filePath, newContent);
|
|
599
619
|
this.logger.info(`Modified: ${filePath}`);
|
|
600
620
|
}
|
|
601
621
|
else {
|
|
602
622
|
this.logger.info(`Would modify: ${filePath}`);
|
|
623
|
+
if (isVerbose) {
|
|
624
|
+
this.log(`Would modify: ${filePath}`);
|
|
625
|
+
}
|
|
603
626
|
}
|
|
604
627
|
}
|
|
605
628
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/flow/instrument.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,oDAAoD;AACpD,uDAAuD;AACvD,sDAAsD;AACtD,4DAA4D;AAC5D,wDAAwD;AACxD,+DAA+D;AAC/D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE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BAAgB,CAAC,CAAC;YACxG,MAAM,UAAU,GAAG,0BAA0B,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;YAEjF,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3B,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;gBAC3B,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACd,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;oBAClD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAC;gBAC5C,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;YAC9D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC","sourcesContent":["/* eslint-disable sf-plugin/only-extend-SfCommand */\n/* eslint-disable @typescript-eslint/return-await */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { Messages, Logger } from '@salesforce/core';\nimport { SfCommand, Flags } from '@salesforce/sf-plugins-core';\nimport * as xml2js from 'xml2js';\n\nexport type RflibLoggingFlowInstrumentResult = {\n processedFiles: number;\n modifiedFiles: number;\n};\n\nMessages.importMessagesDirectoryFromMetaUrl(import.meta.url);\nconst messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.flow.instrument');\n\nexport class FlowInstrumentationService {\n private static readonly parser = new xml2js.Parser({\n explicitArray: false,\n preserveChildrenOrder: true,\n xmlns: false\n });\n\n private static readonly builder = new xml2js.Builder({\n xmldec: { version: '1.0', encoding: 'UTF-8' },\n cdata: true,\n renderOpts: {\n pretty: true,\n indent: ' ',\n newline: '\\n'\n }\n });\n\n public static async parseFlowContent(content: string): Promise<any> {\n try {\n return await this.parser.parseStringPromise(content);\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Flow parsing failed: ${error.message}`);\n }\n throw new Error('Flow parsing failed with unknown error');\n }\n }\n\n public static buildFlowContent(flowObj: any): string {\n try {\n if (!flowObj?.Flow) {\n throw new Error('Invalid flow object structure');\n }\n\n // Create a new Flow object with ordered properties\n const orderedFlow = {\n '$': { 'xmlns': 'http://soap.sforce.com/2006/04/metadata' }\n } as Record<string, unknown>;\n\n // Add actionCalls first if it exists\n if (flowObj.Flow.actionCalls) {\n orderedFlow.actionCalls = flowObj.Flow.actionCalls;\n }\n\n // Add all other properties in their original order\n Object.entries(flowObj.Flow as Record<string, unknown>).forEach(([key, value]) => {\n if (key !== 'actionCalls' && key !== '$') {\n orderedFlow[key] = value;\n }\n });\n\n // Use the builder with just the Flow object, not wrapped in another object\n return this.builder.buildObject({ Flow: orderedFlow });\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Flow building failed: ${error.message}`);\n }\n throw new Error('Flow building failed with unknown error');\n }\n }\n\n // Helper to check if flow already contains RFLIB logger\n public static hasRFLIBLogger(flowObj: any): boolean {\n if (!flowObj?.Flow?.actionCalls) {\n return false;\n }\n\n const actionCalls = Array.isArray(flowObj.Flow.actionCalls)\n ? flowObj.Flow.actionCalls\n : [flowObj.Flow.actionCalls];\n\n return actionCalls.some(\n (action: any) =>\n action.actionName === 'rflib:Logger' ||\n action.actionName === 'rflib_LoggerFlowAction' ||\n action.actionName === 'rflib_ApplicationEventLoggerAction' ||\n (action.name && typeof action.name === 'string' && action.name.startsWith('RFLIB_Flow_Logger'))\n );\n }\n\n // Helper to check if flow has a supported process type for instrumentation\n public static isSupportedProcessType(flowObj: any): boolean {\n const processType = flowObj?.Flow?.processType;\n const triggerType = flowObj?.Flow?.start?.triggerType;\n\n return processType === 'Flow' ||\n (processType === 'AutoLaunchedFlow' && triggerType === 'RecordAfterSave');\n }\n\n // Main instrumentation function\n public static instrumentFlow(flowObj: any, flowName: string, skipInstrumented = false): any {\n // Deep clone the object to avoid modifying the original\n const instrumentedFlow = JSON.parse(JSON.stringify(flowObj));\n\n // Skip if already instrumented and skipInstrumented flag is set\n if (skipInstrumented && this.hasRFLIBLogger(instrumentedFlow)) {\n return instrumentedFlow;\n }\n\n // Make sure Flow exists in the object\n if (!instrumentedFlow.Flow) {\n return instrumentedFlow;\n }\n\n // Create logging action element\n let loggingAction = this.createLoggingAction(flowName);\n\n // Add variables to the logging message if available\n loggingAction = this.enhanceLoggingWithVariables(loggingAction, instrumentedFlow);\n\n // Add logging action to actionCalls\n if (!instrumentedFlow.Flow.actionCalls) {\n instrumentedFlow.Flow.actionCalls = loggingAction;\n } else if (Array.isArray(instrumentedFlow.Flow.actionCalls)) {\n instrumentedFlow.Flow.actionCalls.unshift(loggingAction);\n } else {\n instrumentedFlow.Flow.actionCalls = [loggingAction, instrumentedFlow.Flow.actionCalls];\n }\n\n // Find startElementReference or start element and connect logger to it\n if (instrumentedFlow.Flow.startElementReference) {\n // Save the original start reference\n const startNodeReference = instrumentedFlow.Flow.startElementReference;\n\n // Create connector between logger and original start element\n loggingAction.connector = {\n targetReference: startNodeReference\n };\n\n // Update flow startElementReference to point to our logger\n instrumentedFlow.Flow.startElementReference = loggingAction.name;\n } else if (instrumentedFlow.Flow.start?.connector?.targetReference) {\n // Handle flow with start element: create connector and update start reference\n const startElement = instrumentedFlow.Flow.start;\n const originalTarget = startElement.connector.targetReference;\n\n // Create connector between logger and the original target\n loggingAction.connector = {\n targetReference: originalTarget\n };\n\n // Update the start element connector to point to our logger\n startElement.connector.targetReference = loggingAction.name;\n }\n\n // Set the CanvasMode to AUTO_LAYOUT_CANVAS\n this.setCanvasMode(instrumentedFlow);\n\n // Instrument decisions with logging for each outcome\n if (instrumentedFlow.Flow.decisions) {\n this.instrumentDecisions(instrumentedFlow, flowName);\n }\n\n // Reorder Flow properties\n const originalFlow = instrumentedFlow.Flow as Record<string, unknown>;\n const orderedFlow: Record<string, unknown> = {\n $: originalFlow.$,\n actionCalls: originalFlow.actionCalls\n };\n\n Object.keys(originalFlow).forEach(key => {\n if (key !== 'actionCalls' && key !== '$') {\n orderedFlow[key] = originalFlow[key];\n }\n });\n\n instrumentedFlow.Flow = orderedFlow;\n return instrumentedFlow;\n }\n\n // Helper to instrument decision paths with logging\n private static instrumentDecisions(flowObj: any, flowName: string): void {\n if (!flowObj.Flow.decisions) {\n return;\n }\n\n // Convert to array if there's only one decision\n const decisions = Array.isArray(flowObj.Flow.decisions)\n ? flowObj.Flow.decisions\n : [flowObj.Flow.decisions];\n\n // Process each decision\n decisions.forEach((decision: any) => {\n // Support decision name as 'name' or legacy 'n'\n const decisionNameRaw = decision.name ?? decision.n;\n if (!decisionNameRaw) {\n return;\n }\n const decisionName = decisionNameRaw;\n const decisionLabel = decision.label || decisionName;\n\n // Process default connector if it exists\n if (decision.defaultConnector?.targetReference) {\n const defaultTarget = decision.defaultConnector.targetReference;\n const defaultConnectorLabel = decision.defaultConnectorLabel || 'Default Outcome';\n\n // Create a logger for the default path\n const defaultLogger = this.createDecisionPathLogger(\n flowName,\n String(decisionName),\n String(decisionLabel),\n 'default',\n String(defaultConnectorLabel)\n );\n\n // Connect logger to the original target\n defaultLogger.connector = {\n targetReference: defaultTarget\n };\n\n // Add logger to actionCalls first, before updating the decision connector\n this.addActionCallToFlow(flowObj, defaultLogger);\n\n // Update the decision's default connector to point to our logger\n // We're inside a forEach callback, so we have to modify the original object\n /* eslint-disable no-param-reassign */\n decision.defaultConnector.targetReference = defaultLogger.name;\n /* eslint-enable no-param-reassign */\n }\n\n // Process each rule if they exist\n if (decision.rules) {\n const rules = Array.isArray(decision.rules) ? decision.rules : [decision.rules];\n\n rules.forEach((rule: any) => {\n // Skip if rule doesn't have a connector or name (support 'name' or legacy 'n')\n const ruleNameRaw = rule.name ?? rule.n;\n if (!rule.connector?.targetReference || !ruleNameRaw) {\n return;\n }\n const ruleTarget = rule.connector.targetReference;\n const ruleName = ruleNameRaw;\n const ruleLabel = rule.label || ruleName;\n\n // Create a logger for this rule outcome\n const ruleLogger = this.createDecisionPathLogger(\n flowName,\n String(decisionName),\n String(decisionLabel),\n String(ruleName),\n String(ruleLabel)\n );\n\n // Connect logger to the original target\n ruleLogger.connector = {\n targetReference: ruleTarget\n };\n\n // Add logger to actionCalls first, before updating the rule connector\n this.addActionCallToFlow(flowObj, ruleLogger);\n\n // Update the rule's connector to point to our logger\n // We're inside a forEach callback, so we have to modify the original object\n /* eslint-disable no-param-reassign */\n rule.connector.targetReference = ruleLogger.name;\n /* eslint-enable no-param-reassign */\n });\n }\n });\n }\n\n // Helper to add action calls to the flow object\n // Note: This method does modify the parameter directly - we accepted the eslint warning\n // since we need to modify the flow object within callback functions where returning a new value isn't possible\n private static addActionCallToFlow(flowObj: any, actionCall: any): void {\n /* eslint-disable no-param-reassign */\n if (!flowObj.Flow.actionCalls) {\n flowObj.Flow.actionCalls = actionCall;\n } else if (Array.isArray(flowObj.Flow.actionCalls)) {\n // Add new action at the beginning of the array\n flowObj.Flow.actionCalls.unshift(actionCall);\n } else {\n // If only one action exists, convert to array with new action first\n flowObj.Flow.actionCalls = [actionCall, flowObj.Flow.actionCalls];\n }\n /* eslint-enable no-param-reassign */\n }\n\n // Helper to create a logging action for decision paths\n private static createDecisionPathLogger(\n flowName: string,\n decisionName: string,\n decisionLabel: string,\n outcomeName: string,\n outcomeLabel: string\n ): any {\n const loggerId = this.generateUniqueId();\n\n // Ensure we're working with strings\n const decisionNameStr = String(decisionName);\n const outcomeNameStr = String(outcomeName);\n const decisionLabelStr = String(decisionLabel);\n const outcomeLabelStr = String(outcomeLabel);\n\n // Calculate maximum lengths to stay under 80 characters\n const prefixLength = 'RFLIB_Flow_Logger_Decision_'.length;\n const separatorsLength = 2; // Two underscores\n const maxTotalNameLength = 80 - prefixLength - loggerId.length - separatorsLength;\n\n // Allocate half of available space to each name (decision and outcome)\n const maxIndividualLength = Math.floor(maxTotalNameLength / 2);\n\n // Sanitize names to fit Salesforce naming rules\n const sanitizedDecisionName = this.sanitizeForName(decisionNameStr, maxIndividualLength);\n const sanitizedOutcomeName = this.sanitizeForName(outcomeNameStr, maxIndividualLength);\n\n // Create a name that's guaranteed to be under 80 chars and follow Salesforce rules\n const name = `RFLIB_Flow_Logger_Decision_${sanitizedDecisionName}_${sanitizedOutcomeName}_${loggerId}`;\n\n // Create and truncate the label to ensure it's under 80 chars\n const label = this.truncateLabel(`Log Decision: ${decisionLabelStr} - ${outcomeLabelStr}`);\n\n // Fallback if still too long\n if (name.length > 80) {\n return {\n actionName: 'rflib_LoggerFlowAction',\n actionType: 'apex',\n name: `RFLIBLogDec${loggerId}`,\n label,\n locationX: 176,\n locationY: 50,\n inputParameters: [\n {\n name: 'context',\n value: {\n stringValue: flowName,\n },\n },\n {\n name: 'logLevel',\n value: {\n stringValue: 'INFO',\n },\n },\n {\n name: 'message',\n value: {\n stringValue: `Decision '${decisionLabelStr}' outcome: ${outcomeLabelStr}`,\n },\n },\n ],\n };\n }\n\n return {\n actionName: 'rflib_LoggerFlowAction',\n actionType: 'apex',\n name,\n label,\n locationX: 176,\n locationY: 50,\n inputParameters: [\n {\n name: 'context',\n value: {\n stringValue: flowName,\n },\n },\n {\n name: 'logLevel',\n value: {\n stringValue: 'INFO',\n },\n },\n {\n name: 'message',\n value: {\n stringValue: `Decision '${decisionLabelStr}' outcome: ${outcomeLabelStr}`,\n },\n },\n ],\n };\n }\n\n // Helper to generate unique IDs for new flow elements (compact for 80-char limit)\n // that follow Salesforce Flow Action naming rules\n private static generateUniqueId(): string {\n // Use timestamp in base36 + 4 random chars to keep it short but unique\n // Ensure we don't start with a number or have consecutive/trailing underscores\n const timestamp = Date.now().toString(36);\n const random = Math.random().toString(36).substring(2, 6);\n\n // Combine parts without underscore to avoid potential consecutive underscores\n return `ID${timestamp}${random}`;\n }\n\n // Helper to sanitize and truncate text to fit within the 80-char name limit\n // and to follow Salesforce Flow Action naming rules:\n // - Only alphanumeric characters and underscores\n // - Must begin with a letter\n // - No spaces\n // - No underscore at the end\n // - No consecutive underscores\n private static sanitizeForName(text: string, maxLength: number): string {\n if (!text) {\n return 'X'; // Default to 'X' for empty inputs to ensure we start with a letter\n }\n\n // First, replace any non-alphanumeric characters with underscores\n let sanitized = text.replace(/[^a-zA-Z0-9_]/g, '_');\n\n // Ensure it starts with a letter\n if (!/^[a-zA-Z]/.test(sanitized)) {\n sanitized = 'X' + sanitized;\n }\n\n // Replace consecutive underscores with a single underscore\n sanitized = sanitized.replace(/__+/g, '_');\n\n // Remove trailing underscore if present\n sanitized = sanitized.replace(/_+$/, '');\n\n // If empty after sanitization, return a default value\n if (!sanitized) {\n return 'X';\n }\n\n // Truncate if longer than maxLength\n if (sanitized.length > maxLength) {\n // Truncate and ensure it doesn't end with an underscore\n sanitized = sanitized.substring(0, maxLength).replace(/_+$/, '');\n\n // If we removed trailing underscores and now it's empty or too short, add a fallback\n if (sanitized.length < 1) {\n sanitized = 'X';\n }\n }\n\n return sanitized;\n }\n\n // Helper to truncate label text to fit within the 80-char limit\n private static truncateLabel(label: string, maxLength: number = 80): string {\n if (!label || label.length <= maxLength) {\n return label;\n }\n\n // If text is too long, truncate it and add ellipsis\n return label.substring(0, maxLength - 3) + '...';\n }\n\n // Helper to create a logging action element\n private static createLoggingAction(flowName: string): any {\n const loggerId = this.generateUniqueId();\n\n // Create a name for the flow invocation logger (omit flowName to avoid conflicts)\n const name = `RFLIB_Flow_Logger_${loggerId}`;\n\n // Create and truncate the label to ensure it's under 80 chars\n const label = this.truncateLabel(`Log Flow Invocation: ${flowName}`);\n\n // Verify name length\n if (name.length > 80) {\n // If still too long, use a simpler naming scheme (fallback)\n return {\n actionName: 'rflib_LoggerFlowAction',\n actionType: 'apex',\n name: `RFLIBLogger${loggerId}`,\n label,\n locationX: 176,\n locationY: 50,\n inputParameters: [\n {\n name: 'context',\n value: {\n stringValue: flowName,\n },\n },\n {\n name: 'logLevel',\n value: {\n stringValue: 'INFO',\n },\n },\n {\n name: 'message',\n value: {\n stringValue: `Flow ${flowName} started`,\n },\n },\n ],\n };\n }\n\n return {\n actionName: 'rflib_LoggerFlowAction',\n actionType: 'apex',\n name,\n label,\n locationX: 176,\n locationY: 50,\n inputParameters: [\n {\n name: 'context',\n value: {\n stringValue: flowName,\n },\n },\n {\n name: 'logLevel',\n value: {\n stringValue: 'INFO',\n },\n },\n {\n name: 'message',\n value: {\n stringValue: `Flow ${flowName} started`,\n },\n },\n ],\n };\n }\n\n // Helper to set CanvasMode to AUTO_LAYOUT_CANVAS for better flow layout\n private static setCanvasMode(flowObj: any): void {\n // No longer automatically setting canvas mode - preserve original mode\n if (!flowObj.Flow) {\n return;\n }\n\n // Preserve original processMetadataValues state\n const originalMeta = flowObj.Flow.processMetadataValues;\n const hadProcessMetadataValues = !!originalMeta;\n // Normalize to array\n const metadataValues = !originalMeta\n ? []\n : Array.isArray(originalMeta)\n ? originalMeta\n : [originalMeta];\n\n // Prepare CanvasMode entry\n const canvasModeEntry = {\n name: 'CanvasMode',\n value: {\n stringValue: 'AUTO_LAYOUT_CANVAS'\n }\n };\n // Check if CanvasMode metadata exists\n const canvasModeIndex = metadataValues.findIndex((meta: any) =>\n meta.name === 'CanvasMode'\n );\n\n if (canvasModeIndex === -1) {\n // Add AUTO_LAYOUT_CANVAS entry\n metadataValues.push(canvasModeEntry);\n // Duplicate entry for flows that had no metadata to ensure array output on single entry\n if (!hadProcessMetadataValues) {\n metadataValues.push({\n name: canvasModeEntry.name,\n value: { stringValue: canvasModeEntry.value.stringValue }\n });\n }\n } else {\n metadataValues[canvasModeIndex].value.stringValue = 'AUTO_LAYOUT_CANVAS';\n }\n\n // Assign back the potentially modified array\n /* eslint-disable no-param-reassign */\n flowObj.Flow.processMetadataValues = metadataValues;\n /* eslint-enable no-param-reassign */\n }\n\n // Helper to add variable references to the logging message when available\n private static enhanceLoggingWithVariables(loggingAction: any, flowObj: any): any {\n // Find input variables or parameters that might be useful to log\n const variables = flowObj.Flow.variables || [];\n const inputVariables = Array.isArray(variables)\n ? variables.filter((v: any) => v.isInput === 'true' || v.isCollection === 'true')\n : (variables.isInput === 'true' || variables.isCollection === 'true' ? [variables] : []);\n\n if (inputVariables.length > 0) {\n // Find the message parameter - case insensitive search\n const messageParamIndex = loggingAction.inputParameters.findIndex(\n (p: any) => p.name?.toLowerCase() === 'message'\n );\n\n if (messageParamIndex >= 0) {\n // Enhance the message with variable information\n const varRefs = inputVariables\n .map((v: any) => `${v.name}: {!${v.name}}`)\n .join(', ');\n\n const baseMessage = loggingAction.inputParameters[messageParamIndex];\n const originalMessage = baseMessage.value.stringValue;\n baseMessage.value.stringValue = `${originalMessage} with ${varRefs}`;\n }\n }\n\n return loggingAction;\n }\n}\n\nexport default class RflibLoggingFlowInstrument extends SfCommand<RflibLoggingFlowInstrumentResult> {\n public static readonly summary = messages.getMessage('summary');\n public static readonly description = messages.getMessage('description');\n public static readonly examples = messages.getMessages('examples');\n\n public static readonly flags = {\n sourcepath: Flags.string({\n summary: messages.getMessage('flags.sourcepath.summary'),\n description: messages.getMessage('flags.sourcepath.description'),\n char: 's',\n required: true,\n }),\n dryrun: Flags.boolean({\n summary: messages.getMessage('flags.dryrun.summary'),\n description: messages.getMessage('flags.dryrun.description'),\n char: 'd',\n default: false,\n }),\n 'skip-instrumented': Flags.boolean({\n summary: messages.getMessage('flags.skip-instrumented.summary') || 'Skip flows that already have RFLIB logging',\n description: messages.getMessage('flags.skip-instrumented.description') || 'Do not instrument flows where RFLIB logging is already present',\n default: false,\n }),\n };\n\n private logger!: Logger;\n private readonly stats: RflibLoggingFlowInstrumentResult = {\n processedFiles: 0,\n modifiedFiles: 0,\n };\n\n public async run(): Promise<RflibLoggingFlowInstrumentResult> {\n this.logger = await Logger.child(this.ctor.name);\n const startTime = Date.now();\n\n const { flags } = await this.parse(RflibLoggingFlowInstrument);\n const sourcePath = flags.sourcepath;\n const isDryRun = flags.dryrun;\n const skipInstrumented = flags['skip-instrumented'];\n\n this.log(`Scanning Flow files in ${sourcePath} and sub directories`);\n this.logger.debug(`Dry run mode: ${isDryRun}`);\n this.logger.debug(`Skip instrumented: ${skipInstrumented}`);\n\n this.spinner.start('Running...');\n\n const files = await this.findAllFlowFiles(sourcePath);\n await Promise.all(\n files.map(async (filePath) => {\n await this.instrumentFlowFile(filePath, isDryRun, skipInstrumented);\n })\n );\n\n this.spinner.stop();\n\n const duration = Date.now() - startTime;\n this.logger.debug(`Completed instrumentation in ${duration}ms`);\n\n this.log('\\nInstrumentation complete.');\n this.log(`Processed files: ${this.stats.processedFiles}`);\n this.log(`Modified files: ${this.stats.modifiedFiles}`);\n\n return { ...this.stats };\n }\n\n private async findAllFlowFiles(dirPath: string): Promise<string[]> {\n this.logger.debug(`Scanning directory: ${dirPath}`);\n const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });\n\n const results = await Promise.all(\n entries.map(async (entry) => {\n const filePath = path.join(dirPath, entry.name);\n\n if (entry.isDirectory()) {\n return this.findAllFlowFiles(filePath);\n }\n\n if (entry.name.endsWith('.flow-meta.xml')) {\n return [filePath];\n }\n\n return [];\n })\n );\n\n return results.flat();\n }\n\n private async instrumentFlowFile(filePath: string, isDryRun: boolean, skipInstrumented: boolean): Promise<void> {\n const flowName = path.basename(filePath, '.flow-meta.xml');\n this.logger.debug(`Processing flow: ${flowName}`);\n\n try {\n this.stats.processedFiles++;\n const content = await fs.promises.readFile(filePath, 'utf8');\n const flowObj = await FlowInstrumentationService.parseFlowContent(content);\n\n // Only instrument flows with supported process types\n if (!FlowInstrumentationService.isSupportedProcessType(flowObj)) {\n this.logger.debug(`Skipping unsupported flow type: ${flowName} (processType=${flowObj?.Flow?.processType || 'undefined'})`);\n return;\n }\n\n // Check if flow already has RFLIB logging and skip if needed\n if (skipInstrumented && FlowInstrumentationService.hasRFLIBLogger(flowObj)) {\n this.logger.info(`Skipping already instrumented flow: ${flowName}`);\n return;\n }\n\n const instrumentedFlow = FlowInstrumentationService.instrumentFlow(flowObj, flowName, skipInstrumented);\n const newContent = FlowInstrumentationService.buildFlowContent(instrumentedFlow);\n\n if (content !== newContent) {\n this.stats.modifiedFiles++;\n if (!isDryRun) {\n await fs.promises.writeFile(filePath, newContent);\n this.logger.info(`Modified: ${filePath}`);\n } else {\n this.logger.info(`Would modify: ${filePath}`);\n }\n }\n } catch (error) {\n this.logger.error(`Error processing flow ${flowName}`, error);\n throw error;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/flow/instrument.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,oDAAoD;AACpD,uDAAuD;AACvD,sDAAsD;AACtD,4DAA4D;AAC5D,wDAAwD;AACxD,+DAA+D;AAC/D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAQtC,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,+BAA+B,CAAC,CAAC;AAExF,MAAM,OAAO,0BAA0B;IAC7B,MAAM,CAAU,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC;QACjD,aAAa,EAAE,KAAK;QACpB,qBAAqB,EAAE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,CAAC;IACH,CAAC","sourcesContent":["/* eslint-disable sf-plugin/only-extend-SfCommand */\n/* eslint-disable @typescript-eslint/return-await */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { Messages, Logger } from '@salesforce/core';\nimport { SfCommand, Flags } from '@salesforce/sf-plugins-core';\nimport * as xml2js from 'xml2js';\nimport { minimatch } from 'minimatch';\n\nexport type RflibLoggingFlowInstrumentResult = {\n processedFiles: number;\n modifiedFiles: number;\n modifiedFilePaths?: string[];\n};\n\nMessages.importMessagesDirectoryFromMetaUrl(import.meta.url);\nconst messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.flow.instrument');\n\nexport class FlowInstrumentationService {\n private static readonly parser = new xml2js.Parser({\n explicitArray: false,\n preserveChildrenOrder: true,\n xmlns: false\n });\n\n private static readonly builder = new xml2js.Builder({\n xmldec: { version: '1.0', encoding: 'UTF-8' },\n cdata: true,\n renderOpts: {\n pretty: true,\n indent: ' ',\n newline: '\\n'\n }\n });\n\n public static async parseFlowContent(content: string): Promise<any> {\n try {\n return await this.parser.parseStringPromise(content);\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Flow parsing failed: ${error.message}`);\n }\n throw new Error('Flow parsing failed with unknown error');\n }\n }\n\n public static buildFlowContent(flowObj: any): string {\n try {\n if (!flowObj?.Flow) {\n throw new Error('Invalid flow object structure');\n }\n\n // Create a new Flow object with ordered properties\n const orderedFlow = {\n '$': { 'xmlns': 'http://soap.sforce.com/2006/04/metadata' }\n } as Record<string, unknown>;\n\n // Add actionCalls first if it exists\n if (flowObj.Flow.actionCalls) {\n orderedFlow.actionCalls = flowObj.Flow.actionCalls;\n }\n\n // Add all other properties in their original order\n Object.entries(flowObj.Flow as Record<string, unknown>).forEach(([key, value]) => {\n if (key !== 'actionCalls' && key !== '$') {\n orderedFlow[key] = value;\n }\n });\n\n // Use the builder with just the Flow object, not wrapped in another object\n return this.builder.buildObject({ Flow: orderedFlow });\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Flow building failed: ${error.message}`);\n }\n throw new Error('Flow building failed with unknown error');\n }\n }\n\n // Helper to check if flow already contains RFLIB logger\n public static hasRFLIBLogger(flowObj: any): boolean {\n if (!flowObj?.Flow?.actionCalls) {\n return false;\n }\n\n const actionCalls = Array.isArray(flowObj.Flow.actionCalls)\n ? flowObj.Flow.actionCalls\n : [flowObj.Flow.actionCalls];\n\n return actionCalls.some(\n (action: any) =>\n action.actionName === 'rflib:Logger' ||\n action.actionName === 'rflib_LoggerFlowAction' ||\n action.actionName === 'rflib_ApplicationEventLoggerAction' ||\n (action.name && typeof action.name === 'string' && action.name.startsWith('RFLIB_Flow_Logger'))\n );\n }\n\n // Helper to check if flow has a supported process type for instrumentation\n public static isSupportedProcessType(flowObj: any): boolean {\n const processType = flowObj?.Flow?.processType;\n const triggerType = flowObj?.Flow?.start?.triggerType;\n\n return processType === 'Flow' ||\n (processType === 'AutoLaunchedFlow' && triggerType === 'RecordAfterSave');\n }\n\n // Main instrumentation function\n public static instrumentFlow(flowObj: any, flowName: string, skipInstrumented = false): any {\n // Deep clone the object to avoid modifying the original\n const instrumentedFlow = JSON.parse(JSON.stringify(flowObj));\n\n // Skip if already instrumented and skipInstrumented flag is set\n if (skipInstrumented && this.hasRFLIBLogger(instrumentedFlow)) {\n return instrumentedFlow;\n }\n\n // Make sure Flow exists in the object\n if (!instrumentedFlow.Flow) {\n return instrumentedFlow;\n }\n\n // Create logging action element\n let loggingAction = this.createLoggingAction(flowName);\n\n // Add variables to the logging message if available\n loggingAction = this.enhanceLoggingWithVariables(loggingAction, instrumentedFlow);\n\n // Add logging action to actionCalls\n if (!instrumentedFlow.Flow.actionCalls) {\n instrumentedFlow.Flow.actionCalls = loggingAction;\n } else if (Array.isArray(instrumentedFlow.Flow.actionCalls)) {\n instrumentedFlow.Flow.actionCalls.unshift(loggingAction);\n } else {\n instrumentedFlow.Flow.actionCalls = [loggingAction, instrumentedFlow.Flow.actionCalls];\n }\n\n // Find startElementReference or start element and connect logger to it\n if (instrumentedFlow.Flow.startElementReference) {\n // Save the original start reference\n const startNodeReference = instrumentedFlow.Flow.startElementReference;\n\n // Create connector between logger and original start element\n loggingAction.connector = {\n targetReference: startNodeReference\n };\n\n // Update flow startElementReference to point to our logger\n instrumentedFlow.Flow.startElementReference = loggingAction.name;\n } else if (instrumentedFlow.Flow.start?.connector?.targetReference) {\n // Handle flow with start element: create connector and update start reference\n const startElement = instrumentedFlow.Flow.start;\n const originalTarget = startElement.connector.targetReference;\n\n // Create connector between logger and the original target\n loggingAction.connector = {\n targetReference: originalTarget\n };\n\n // Update the start element connector to point to our logger\n startElement.connector.targetReference = loggingAction.name;\n }\n\n // Set the CanvasMode to AUTO_LAYOUT_CANVAS\n this.setCanvasMode(instrumentedFlow);\n\n // Instrument decisions with logging for each outcome\n if (instrumentedFlow.Flow.decisions) {\n this.instrumentDecisions(instrumentedFlow, flowName);\n }\n\n // Reorder Flow properties\n const originalFlow = instrumentedFlow.Flow as Record<string, unknown>;\n const orderedFlow: Record<string, unknown> = {\n $: originalFlow.$,\n actionCalls: originalFlow.actionCalls\n };\n\n Object.keys(originalFlow).forEach(key => {\n if (key !== 'actionCalls' && key !== '$') {\n orderedFlow[key] = originalFlow[key];\n }\n });\n\n instrumentedFlow.Flow = orderedFlow;\n return instrumentedFlow;\n }\n\n // Helper to instrument decision paths with logging\n private static instrumentDecisions(flowObj: any, flowName: string): void {\n if (!flowObj.Flow.decisions) {\n return;\n }\n\n // Convert to array if there's only one decision\n const decisions = Array.isArray(flowObj.Flow.decisions)\n ? flowObj.Flow.decisions\n : [flowObj.Flow.decisions];\n\n // Process each decision\n decisions.forEach((decision: any) => {\n // Support decision name as 'name' or legacy 'n'\n const decisionNameRaw = decision.name ?? decision.n;\n if (!decisionNameRaw) {\n return;\n }\n const decisionName = decisionNameRaw;\n const decisionLabel = decision.label || decisionName;\n\n // Process default connector if it exists\n if (decision.defaultConnector?.targetReference) {\n const defaultTarget = decision.defaultConnector.targetReference;\n const defaultConnectorLabel = decision.defaultConnectorLabel || 'Default Outcome';\n\n // Create a logger for the default path\n const defaultLogger = this.createDecisionPathLogger(\n flowName,\n String(decisionName),\n String(decisionLabel),\n 'default',\n String(defaultConnectorLabel)\n );\n\n // Connect logger to the original target\n defaultLogger.connector = {\n targetReference: defaultTarget\n };\n\n // Add logger to actionCalls first, before updating the decision connector\n this.addActionCallToFlow(flowObj, defaultLogger);\n\n // Update the decision's default connector to point to our logger\n // We're inside a forEach callback, so we have to modify the original object\n /* eslint-disable no-param-reassign */\n decision.defaultConnector.targetReference = defaultLogger.name;\n /* eslint-enable no-param-reassign */\n }\n\n // Process each rule if they exist\n if (decision.rules) {\n const rules = Array.isArray(decision.rules) ? decision.rules : [decision.rules];\n\n rules.forEach((rule: any) => {\n // Skip if rule doesn't have a connector or name (support 'name' or legacy 'n')\n const ruleNameRaw = rule.name ?? rule.n;\n if (!rule.connector?.targetReference || !ruleNameRaw) {\n return;\n }\n const ruleTarget = rule.connector.targetReference;\n const ruleName = ruleNameRaw;\n const ruleLabel = rule.label || ruleName;\n\n // Create a logger for this rule outcome\n const ruleLogger = this.createDecisionPathLogger(\n flowName,\n String(decisionName),\n String(decisionLabel),\n String(ruleName),\n String(ruleLabel)\n );\n\n // Connect logger to the original target\n ruleLogger.connector = {\n targetReference: ruleTarget\n };\n\n // Add logger to actionCalls first, before updating the rule connector\n this.addActionCallToFlow(flowObj, ruleLogger);\n\n // Update the rule's connector to point to our logger\n // We're inside a forEach callback, so we have to modify the original object\n /* eslint-disable no-param-reassign */\n rule.connector.targetReference = ruleLogger.name;\n /* eslint-enable no-param-reassign */\n });\n }\n });\n }\n\n // Helper to add action calls to the flow object\n // Note: This method does modify the parameter directly - we accepted the eslint warning\n // since we need to modify the flow object within callback functions where returning a new value isn't possible\n private static addActionCallToFlow(flowObj: any, actionCall: any): void {\n /* eslint-disable no-param-reassign */\n if (!flowObj.Flow.actionCalls) {\n flowObj.Flow.actionCalls = actionCall;\n } else if (Array.isArray(flowObj.Flow.actionCalls)) {\n // Add new action at the beginning of the array\n flowObj.Flow.actionCalls.unshift(actionCall);\n } else {\n // If only one action exists, convert to array with new action first\n flowObj.Flow.actionCalls = [actionCall, flowObj.Flow.actionCalls];\n }\n /* eslint-enable no-param-reassign */\n }\n\n // Helper to create a logging action for decision paths\n private static createDecisionPathLogger(\n flowName: string,\n decisionName: string,\n decisionLabel: string,\n outcomeName: string,\n outcomeLabel: string\n ): any {\n const loggerId = this.generateUniqueId();\n\n // Ensure we're working with strings\n const decisionNameStr = String(decisionName);\n const outcomeNameStr = String(outcomeName);\n const decisionLabelStr = String(decisionLabel);\n const outcomeLabelStr = String(outcomeLabel);\n\n // Calculate maximum lengths to stay under 80 characters\n const prefixLength = 'RFLIB_Flow_Logger_Decision_'.length;\n const separatorsLength = 2; // Two underscores\n const maxTotalNameLength = 80 - prefixLength - loggerId.length - separatorsLength;\n\n // Allocate half of available space to each name (decision and outcome)\n const maxIndividualLength = Math.floor(maxTotalNameLength / 2);\n\n // Sanitize names to fit Salesforce naming rules\n const sanitizedDecisionName = this.sanitizeForName(decisionNameStr, maxIndividualLength);\n const sanitizedOutcomeName = this.sanitizeForName(outcomeNameStr, maxIndividualLength);\n\n // Create a name that's guaranteed to be under 80 chars and follow Salesforce rules\n const name = `RFLIB_Flow_Logger_Decision_${sanitizedDecisionName}_${sanitizedOutcomeName}_${loggerId}`;\n\n // Create and truncate the label to ensure it's under 80 chars\n const label = this.truncateLabel(`Log Decision: ${decisionLabelStr} - ${outcomeLabelStr}`);\n\n // Fallback if still too long\n if (name.length > 80) {\n return {\n actionName: 'rflib_LoggerFlowAction',\n actionType: 'apex',\n name: `RFLIBLogDec${loggerId}`,\n label,\n locationX: 176,\n locationY: 50,\n inputParameters: [\n {\n name: 'context',\n value: {\n stringValue: flowName,\n },\n },\n {\n name: 'logLevel',\n value: {\n stringValue: 'INFO',\n },\n },\n {\n name: 'message',\n value: {\n stringValue: `Decision '${decisionLabelStr}' outcome: ${outcomeLabelStr}`,\n },\n },\n ],\n };\n }\n\n return {\n actionName: 'rflib_LoggerFlowAction',\n actionType: 'apex',\n name,\n label,\n locationX: 176,\n locationY: 50,\n inputParameters: [\n {\n name: 'context',\n value: {\n stringValue: flowName,\n },\n },\n {\n name: 'logLevel',\n value: {\n stringValue: 'INFO',\n },\n },\n {\n name: 'message',\n value: {\n stringValue: `Decision '${decisionLabelStr}' outcome: ${outcomeLabelStr}`,\n },\n },\n ],\n };\n }\n\n // Helper to generate unique IDs for new flow elements (compact for 80-char limit)\n // that follow Salesforce Flow Action naming rules\n private static generateUniqueId(): string {\n // Use timestamp in base36 + 4 random chars to keep it short but unique\n // Ensure we don't start with a number or have consecutive/trailing underscores\n const timestamp = Date.now().toString(36);\n const random = Math.random().toString(36).substring(2, 6);\n\n // Combine parts without underscore to avoid potential consecutive underscores\n return `ID${timestamp}${random}`;\n }\n\n // Helper to sanitize and truncate text to fit within the 80-char name limit\n // and to follow Salesforce Flow Action naming rules:\n // - Only alphanumeric characters and underscores\n // - Must begin with a letter\n // - No spaces\n // - No underscore at the end\n // - No consecutive underscores\n private static sanitizeForName(text: string, maxLength: number): string {\n if (!text) {\n return 'X'; // Default to 'X' for empty inputs to ensure we start with a letter\n }\n\n // First, replace any non-alphanumeric characters with underscores\n let sanitized = text.replace(/[^a-zA-Z0-9_]/g, '_');\n\n // Ensure it starts with a letter\n if (!/^[a-zA-Z]/.test(sanitized)) {\n sanitized = 'X' + sanitized;\n }\n\n // Replace consecutive underscores with a single underscore\n sanitized = sanitized.replace(/__+/g, '_');\n\n // Remove trailing underscore if present\n sanitized = sanitized.replace(/_+$/, '');\n\n // If empty after sanitization, return a default value\n if (!sanitized) {\n return 'X';\n }\n\n // Truncate if longer than maxLength\n if (sanitized.length > maxLength) {\n // Truncate and ensure it doesn't end with an underscore\n sanitized = sanitized.substring(0, maxLength).replace(/_+$/, '');\n\n // If we removed trailing underscores and now it's empty or too short, add a fallback\n if (sanitized.length < 1) {\n sanitized = 'X';\n }\n }\n\n return sanitized;\n }\n\n // Helper to truncate label text to fit within the 80-char limit\n private static truncateLabel(label: string, maxLength: number = 80): string {\n if (!label || label.length <= maxLength) {\n return label;\n }\n\n // If text is too long, truncate it and add ellipsis\n return label.substring(0, maxLength - 3) + '...';\n }\n\n // Helper to create a logging action element\n private static createLoggingAction(flowName: string): any {\n const loggerId = this.generateUniqueId();\n\n // Create a name for the flow invocation logger (omit flowName to avoid conflicts)\n const name = `RFLIB_Flow_Logger_${loggerId}`;\n\n // Create and truncate the label to ensure it's under 80 chars\n const label = this.truncateLabel(`Log Flow Invocation: ${flowName}`);\n\n // Verify name length\n if (name.length > 80) {\n // If still too long, use a simpler naming scheme (fallback)\n return {\n actionName: 'rflib_LoggerFlowAction',\n actionType: 'apex',\n name: `RFLIBLogger${loggerId}`,\n label,\n locationX: 176,\n locationY: 50,\n inputParameters: [\n {\n name: 'context',\n value: {\n stringValue: flowName,\n },\n },\n {\n name: 'logLevel',\n value: {\n stringValue: 'INFO',\n },\n },\n {\n name: 'message',\n value: {\n stringValue: `Flow ${flowName} started`,\n },\n },\n ],\n };\n }\n\n return {\n actionName: 'rflib_LoggerFlowAction',\n actionType: 'apex',\n name,\n label,\n locationX: 176,\n locationY: 50,\n inputParameters: [\n {\n name: 'context',\n value: {\n stringValue: flowName,\n },\n },\n {\n name: 'logLevel',\n value: {\n stringValue: 'INFO',\n },\n },\n {\n name: 'message',\n value: {\n stringValue: `Flow ${flowName} started`,\n },\n },\n ],\n };\n }\n\n // Helper to set CanvasMode to AUTO_LAYOUT_CANVAS for better flow layout\n private static setCanvasMode(flowObj: any): void {\n // No longer automatically setting canvas mode - preserve original mode\n if (!flowObj.Flow) {\n return;\n }\n\n // Preserve original processMetadataValues state\n const originalMeta = flowObj.Flow.processMetadataValues;\n const hadProcessMetadataValues = !!originalMeta;\n // Normalize to array\n const metadataValues = !originalMeta\n ? []\n : Array.isArray(originalMeta)\n ? originalMeta\n : [originalMeta];\n\n // Prepare CanvasMode entry\n const canvasModeEntry = {\n name: 'CanvasMode',\n value: {\n stringValue: 'AUTO_LAYOUT_CANVAS'\n }\n };\n // Check if CanvasMode metadata exists\n const canvasModeIndex = metadataValues.findIndex((meta: any) =>\n meta.name === 'CanvasMode'\n );\n\n if (canvasModeIndex === -1) {\n // Add AUTO_LAYOUT_CANVAS entry\n metadataValues.push(canvasModeEntry);\n // Duplicate entry for flows that had no metadata to ensure array output on single entry\n if (!hadProcessMetadataValues) {\n metadataValues.push({\n name: canvasModeEntry.name,\n value: { stringValue: canvasModeEntry.value.stringValue }\n });\n }\n } else {\n metadataValues[canvasModeIndex].value.stringValue = 'AUTO_LAYOUT_CANVAS';\n }\n\n // Assign back the potentially modified array\n /* eslint-disable no-param-reassign */\n flowObj.Flow.processMetadataValues = metadataValues;\n /* eslint-enable no-param-reassign */\n }\n\n // Helper to add variable references to the logging message when available\n private static enhanceLoggingWithVariables(loggingAction: any, flowObj: any): any {\n // Find input variables or parameters that might be useful to log\n const variables = flowObj.Flow.variables || [];\n const inputVariables = Array.isArray(variables)\n ? variables.filter((v: any) => v.isInput === 'true' || v.isCollection === 'true')\n : (variables.isInput === 'true' || variables.isCollection === 'true' ? [variables] : []);\n\n if (inputVariables.length > 0) {\n // Find the message parameter - case insensitive search\n const messageParamIndex = loggingAction.inputParameters.findIndex(\n (p: any) => p.name?.toLowerCase() === 'message'\n );\n\n if (messageParamIndex >= 0) {\n // Enhance the message with variable information\n const varRefs = inputVariables\n .map((v: any) => `${v.name}: {!${v.name}}`)\n .join(', ');\n\n const baseMessage = loggingAction.inputParameters[messageParamIndex];\n const originalMessage = baseMessage.value.stringValue;\n baseMessage.value.stringValue = `${originalMessage} with ${varRefs}`;\n }\n }\n\n return loggingAction;\n }\n}\n\nexport default class RflibLoggingFlowInstrument extends SfCommand<RflibLoggingFlowInstrumentResult> {\n public static readonly summary = messages.getMessage('summary');\n public static readonly description = messages.getMessage('description');\n public static readonly examples = messages.getMessages('examples');\n\n public static readonly flags = {\n sourcepath: Flags.string({\n summary: messages.getMessage('flags.sourcepath.summary'),\n description: messages.getMessage('flags.sourcepath.description'),\n char: 's',\n required: true,\n }),\n dryrun: Flags.boolean({\n summary: messages.getMessage('flags.dryrun.summary'),\n description: messages.getMessage('flags.dryrun.description'),\n char: 'd',\n default: false,\n }),\n 'skip-instrumented': Flags.boolean({\n summary: messages.getMessage('flags.skip-instrumented.summary') || 'Skip flows that already have RFLIB logging',\n description: messages.getMessage('flags.skip-instrumented.description') || 'Do not instrument flows where RFLIB logging is already present',\n default: false,\n }),\n verbose: Flags.boolean({\n summary: messages.getMessage('flags.verbose.summary'),\n description: messages.getMessage('flags.verbose.description'),\n char: 'v',\n default: false,\n }),\n exclude: Flags.string({\n summary: messages.getMessage('flags.exclude.summary'),\n description: messages.getMessage('flags.exclude.description'),\n char: 'e',\n }),\n };\n\n private logger!: Logger;\n private readonly stats: RflibLoggingFlowInstrumentResult = {\n processedFiles: 0,\n modifiedFiles: 0,\n modifiedFilePaths: [],\n };\n\n public async run(): Promise<RflibLoggingFlowInstrumentResult> {\n this.logger = await Logger.child(this.ctor.name);\n const startTime = Date.now();\n\n const { flags } = await this.parse(RflibLoggingFlowInstrument);\n const sourcePath = flags.sourcepath;\n const isDryRun = flags.dryrun;\n const skipInstrumented = flags['skip-instrumented'];\n const isVerbose = flags.verbose;\n const excludePattern = flags.exclude;\n\n this.log(`Scanning Flow files in ${sourcePath} and sub directories`);\n this.logger.debug(`Dry run mode: ${isDryRun}`);\n this.logger.debug(`Skip instrumented: ${skipInstrumented}`);\n\n this.spinner.start('Running...');\n\n const files = await this.findAllFlowFiles(sourcePath, excludePattern);\n await Promise.all(\n files.map(async (filePath) => {\n await this.instrumentFlowFile(filePath, isDryRun, skipInstrumented, isVerbose);\n })\n );\n\n this.spinner.stop();\n\n const duration = Date.now() - startTime;\n this.logger.debug(`Completed instrumentation in ${duration}ms`);\n\n this.log('\\nInstrumentation complete.');\n this.log(`Processed files: ${this.stats.processedFiles}`);\n this.log(`Modified files: ${this.stats.modifiedFiles}`);\n\n return { ...this.stats };\n }\n\n private async findAllFlowFiles(dirPath: string, excludePattern?: string): Promise<string[]> {\n this.logger.debug(`Scanning directory: ${dirPath}`);\n const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });\n\n const results = await Promise.all(\n entries.map(async (entry) => {\n const filePath = path.join(dirPath, entry.name);\n\n if (excludePattern && minimatch(filePath, excludePattern, { matchBase: true })) {\n this.logger.debug(`Skipping excluded path: ${filePath}`);\n return [];\n }\n\n if (entry.isDirectory()) {\n return this.findAllFlowFiles(filePath, excludePattern);\n }\n\n if (entry.name.endsWith('.flow-meta.xml')) {\n return [filePath];\n }\n\n return [];\n })\n );\n\n return results.flat();\n }\n\n private async instrumentFlowFile(filePath: string, isDryRun: boolean, skipInstrumented: boolean, isVerbose: boolean): Promise<void> {\n const flowName = path.basename(filePath, '.flow-meta.xml');\n this.logger.debug(`Processing flow: ${flowName}`);\n\n try {\n this.stats.processedFiles++;\n const content = await fs.promises.readFile(filePath, 'utf8');\n const flowObj = await FlowInstrumentationService.parseFlowContent(content);\n\n // Only instrument flows with supported process types\n if (!FlowInstrumentationService.isSupportedProcessType(flowObj)) {\n this.logger.debug(`Skipping unsupported flow type: ${flowName} (processType=${flowObj?.Flow?.processType || 'undefined'})`);\n return;\n }\n\n // Check if flow already has RFLIB logging and skip if needed\n if (skipInstrumented && FlowInstrumentationService.hasRFLIBLogger(flowObj)) {\n this.logger.info(`Skipping already instrumented flow: ${flowName}`);\n return;\n }\n\n const instrumentedFlow = FlowInstrumentationService.instrumentFlow(flowObj, flowName, skipInstrumented);\n const newContent = FlowInstrumentationService.buildFlowContent(instrumentedFlow);\n\n if (content !== newContent) {\n this.stats.modifiedFiles++;\n this.stats.modifiedFilePaths?.push(filePath);\n if (!isDryRun) {\n await fs.promises.writeFile(filePath, newContent);\n this.logger.info(`Modified: ${filePath}`);\n } else {\n this.logger.info(`Would modify: ${filePath}`);\n if (isVerbose) {\n this.log(`Would modify: ${filePath}`);\n }\n }\n }\n } catch (error) {\n this.logger.error(`Error processing flow ${flowName}`, error);\n throw error;\n }\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ export type RflibLoggingLwcInstrumentResult = {
|
|
|
3
3
|
processedFiles: number;
|
|
4
4
|
modifiedFiles: number;
|
|
5
5
|
formattedFiles: number;
|
|
6
|
+
modifiedFilePaths?: string[];
|
|
6
7
|
};
|
|
7
8
|
export default class RflibLoggingLwcInstrument extends SfCommand<RflibLoggingLwcInstrumentResult> {
|
|
8
9
|
static readonly summary: string;
|
|
@@ -14,6 +15,8 @@ export default class RflibLoggingLwcInstrument extends SfCommand<RflibLoggingLwc
|
|
|
14
15
|
prettier: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
16
|
'no-if': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
17
|
'skip-instrumented': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
exclude: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
20
|
};
|
|
18
21
|
private logger;
|
|
19
22
|
private readonly stats;
|
|
@@ -4,6 +4,7 @@ import * as path from 'node:path';
|
|
|
4
4
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
5
5
|
import { Messages, Logger } from '@salesforce/core';
|
|
6
6
|
import * as prettier from 'prettier';
|
|
7
|
+
import { minimatch } from 'minimatch';
|
|
7
8
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
8
9
|
const messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.lwc.instrument');
|
|
9
10
|
class LwcInstrumentationService {
|
|
@@ -192,12 +193,24 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
|
|
|
192
193
|
description: messages.getMessage('flags.skip-instrumented.description'),
|
|
193
194
|
default: false,
|
|
194
195
|
}),
|
|
196
|
+
verbose: Flags.boolean({
|
|
197
|
+
summary: messages.getMessage('flags.verbose.summary'),
|
|
198
|
+
description: messages.getMessage('flags.verbose.description'),
|
|
199
|
+
char: 'v',
|
|
200
|
+
default: false,
|
|
201
|
+
}),
|
|
202
|
+
exclude: Flags.string({
|
|
203
|
+
summary: messages.getMessage('flags.exclude.summary'),
|
|
204
|
+
description: messages.getMessage('flags.exclude.description'),
|
|
205
|
+
char: 'e',
|
|
206
|
+
}),
|
|
195
207
|
};
|
|
196
208
|
logger;
|
|
197
209
|
stats = {
|
|
198
210
|
processedFiles: 0,
|
|
199
211
|
modifiedFiles: 0,
|
|
200
212
|
formattedFiles: 0,
|
|
213
|
+
modifiedFilePaths: [],
|
|
201
214
|
};
|
|
202
215
|
async run() {
|
|
203
216
|
this.logger = await Logger.child(this.ctor.name);
|
|
@@ -206,10 +219,12 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
|
|
|
206
219
|
prettier: flags.prettier,
|
|
207
220
|
noIf: flags['no-if'],
|
|
208
221
|
skipInstrumented: flags['skip-instrumented'],
|
|
222
|
+
verbose: flags.verbose,
|
|
223
|
+
exclude: flags.exclude,
|
|
209
224
|
};
|
|
210
225
|
this.log(`Scanning LWC components in ${flags.sourcepath}...`);
|
|
211
226
|
this.spinner.start('Running...');
|
|
212
|
-
const files = await this.findAllLwcFiles(flags.sourcepath);
|
|
227
|
+
const files = await this.findAllLwcFiles(flags.sourcepath, instrumentationOpts.exclude);
|
|
213
228
|
await Promise.all(files.map(async (filePath) => {
|
|
214
229
|
await this.instrumentLwcFile(filePath, flags.dryrun, instrumentationOpts);
|
|
215
230
|
}));
|
|
@@ -220,13 +235,17 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
|
|
|
220
235
|
this.log(`Formatted files: ${this.stats.formattedFiles}`);
|
|
221
236
|
return { ...this.stats };
|
|
222
237
|
}
|
|
223
|
-
async findAllLwcFiles(dirPath) {
|
|
238
|
+
async findAllLwcFiles(dirPath, excludePattern) {
|
|
224
239
|
this.logger.debug(`Scanning directory: ${dirPath}`);
|
|
225
240
|
const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
|
|
226
241
|
const results = await Promise.all(entries.map(async (entry) => {
|
|
227
242
|
const filePath = path.join(dirPath, entry.name);
|
|
243
|
+
if (excludePattern && minimatch(filePath, excludePattern, { matchBase: true })) {
|
|
244
|
+
this.logger.debug(`Skipping excluded path: ${filePath}`);
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
228
247
|
if (entry.isDirectory()) {
|
|
229
|
-
return this.findAllLwcFiles(filePath);
|
|
248
|
+
return this.findAllLwcFiles(filePath, excludePattern);
|
|
230
249
|
}
|
|
231
250
|
const parentDir = path.dirname(filePath);
|
|
232
251
|
if (entry.name.endsWith('.js') &&
|
|
@@ -257,6 +276,7 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
|
|
|
257
276
|
content = LwcInstrumentationService.processConsoleStatements(content, variableName);
|
|
258
277
|
if (content !== originalContent) {
|
|
259
278
|
this.stats.modifiedFiles++;
|
|
279
|
+
this.stats.modifiedFilePaths?.push(filePath);
|
|
260
280
|
if (!isDryRun) {
|
|
261
281
|
try {
|
|
262
282
|
const finalContent = instrumentationOpts.prettier
|
|
@@ -279,6 +299,9 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
|
|
|
279
299
|
}
|
|
280
300
|
else {
|
|
281
301
|
this.logger.info(`Would modify: ${filePath}`);
|
|
302
|
+
if (instrumentationOpts.verbose) {
|
|
303
|
+
this.log(`Would modify: ${filePath}`);
|
|
304
|
+
}
|
|
282
305
|
}
|
|
283
306
|
}
|
|
284
307
|
}
|