rflib-plugin 0.9.1 → 0.10.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.
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-await-in-loop */
2
1
  import * as fs from 'node:fs';
3
2
  import * as path from 'node:path';
4
3
  import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
@@ -220,20 +219,21 @@ export default class RflibLoggingApexInstrument extends SfCommand {
220
219
  }
221
220
  async processDirectory(dirPath, isDryRun, instrumentationOpts) {
222
221
  this.logger.debug(`Processing directory: ${dirPath}`);
223
- const files = await fs.promises.readdir(dirPath);
224
- for (const file of files) {
225
- const filePath = path.join(dirPath, file);
226
- const stat = await fs.promises.stat(filePath);
227
- if (stat.isDirectory()) {
222
+ const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
223
+ await Promise.all(entries.map(async (entry) => {
224
+ const filePath = path.join(dirPath, entry.name);
225
+ if (entry.isDirectory()) {
228
226
  await this.processDirectory(filePath, isDryRun, instrumentationOpts);
227
+ return;
229
228
  }
230
- else if (file.includes('Test') && file.endsWith('.cls')) {
229
+ if (entry.name.includes('Test') && entry.name.endsWith('.cls')) {
231
230
  await this.processTestFile(filePath, isDryRun, instrumentationOpts);
231
+ return;
232
232
  }
233
- else if (file.endsWith('.cls')) {
233
+ if (entry.name.endsWith('.cls')) {
234
234
  await this.instrumentApexClass(filePath, isDryRun, instrumentationOpts);
235
235
  }
236
- }
236
+ }));
237
237
  }
238
238
  async processTestFile(filePath, isDryRun, instrumentationOpts) {
239
239
  this.logger.debug(`Processing test file: ${filePath}`);
@@ -1 +1 @@
1
- {"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/apex/instrument.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE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SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;wBAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,QAAQ,EAAE,CAAC,CAAC;oBAC/D,CAAC;gBACH,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,0BAA0B,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;YAChE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC","sourcesContent":["/* eslint-disable no-await-in-loop */\nimport * 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 ApexMethodMatch = {\n auraEnabled?: string;\n access: string;\n isStatic?: string;\n returnType: string;\n methodName: string;\n args: string;\n}\n\ntype IfCondition = {\n condition: string;\n position: number;\n}\n\ntype InstrumentationOptions = {\n readonly prettier: boolean;\n readonly noIf: boolean;\n readonly skipInstrumented: boolean;\n}\n\ntype LoggerInfo = {\n readonly exists: boolean;\n readonly variableName: string;\n}\n\ntype ProcessedParameters = {\n readonly paramList: readonly string[];\n readonly logArgs: string;\n}\n\nexport type RflibLoggingApexInstrumentResult = {\n processedFiles: number;\n modifiedFiles: number;\n formattedFiles: number;\n}\n\nMessages.importMessagesDirectoryFromMetaUrl(import.meta.url);\nconst messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.apex.instrument');\n\nclass ApexInstrumentationService {\n public static readonly TEST_SETUP_REGEX =\n /@TestSetup\\s+((public|private|protected|global)s+)?(?:static\\s+)?void\\s+(\\w+)\\s*\\([^)]*\\)\\s*{/g;\n\n private static readonly METHOD_REGEX =\n /(@AuraEnabled\\s*[\\s\\S]*?)?\\b(public|private|protected|global)\\s+(static\\s+)?(?:(\\w+(?:\\s*<(?:[^<>]|<[^<>]*>)*>)?)|void)\\s+(\\w+)\\s*\\(([\\s\\S]*?)\\)\\s*{/g;\n private static readonly CLASS_REGEX = /\\bclass\\s+\\w+\\s*{/;\n private static readonly CLASS_LOGGER_REGEX = /\\bprivate\\s+(?:static\\s+)?(?:final\\s+)?rflib_Logger\\s+(\\w+)\\b/;\n private static readonly GENERIC_ARGS_REGEX = /<[^>]+>/g;\n private static readonly CATCH_REGEX = /catch\\s*\\(\\s*\\w+\\s+(\\w+)\\s*\\)\\s*{/g;\n private static readonly IF_STATEMENT_REGEX =\n /if\\s*\\((.*?)\\)\\s*(?:{([^]*?(?:(?<!{){(?:[^]*?)}(?!})[^]*?)*)}|([^{].*?)(?=\\s*(?:;|$));)/g;\n private static readonly ELSE_REGEX = /\\s*else(?!\\s*if\\b)\\s*(?:{((?:[^{}]|{(?:[^{}]|{[^{}]*})*})*)}|([^{;]*(?:;|$)))/g;\n private static readonly IS_INSTRUMENTED_REGEX = /(\\brflib_Logger\\b|\\brflib_TestUtil\\b)/;\n private static readonly SYSTEM_DEBUG_REGEX = /System\\.debug\\s*\\(\\s*['\"]([^'\"]*)['\"]\\s*\\)\\s*;/g;\n\n private static readonly PRIMITIVE_TYPES = new Set([\n 'STRING',\n 'INTEGER',\n 'LONG',\n 'DECIMAL',\n 'DOUBLE',\n 'BOOLEAN',\n 'DATE',\n 'DATETIME',\n 'TIME',\n 'ID',\n ]);\n\n private static readonly PRETTIER_CONFIG: prettier.Options = {\n parser: 'apex',\n plugins: ['prettier-plugin-apex'],\n printWidth: 120,\n tabWidth: 4,\n useTabs: false,\n singleQuote: true,\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 isInstrumented(content: string): boolean {\n return this.IS_INSTRUMENTED_REGEX.test(content);\n }\n\n public static detectLogger(content: string): LoggerInfo {\n const match = content.match(this.CLASS_LOGGER_REGEX);\n return {\n exists: this.CLASS_LOGGER_REGEX.test(content),\n variableName: match ? match[1] : 'LOGGER',\n };\n }\n\n public static addLoggerDeclaration(content: string, className: string): string {\n const { exists, variableName } = this.detectLogger(content);\n if (!exists) {\n const loggerDecl = `private static final rflib_Logger ${variableName} = rflib_LoggerUtil.getFactory().createLogger('${className}');`;\n return content.replace(this.CLASS_REGEX, `$&\\n ${loggerDecl}`);\n }\n return content;\n }\n\n public static processMethodDeclarations(content: string, loggerName: string): string {\n return content.replace(this.METHOD_REGEX, (match: string, ...args: unknown[]) => {\n const methodInfo: ApexMethodMatch = {\n auraEnabled: args[0] as string,\n access: args[1] as string,\n isStatic: args[2] as string,\n returnType: args[3] as string,\n methodName: args[4] as string,\n args: args[5] as string,\n };\n\n const { paramList, logArgs } = this.processParameters(methodInfo.args);\n\n return `${match}\\n ${loggerName}.info('${methodInfo.methodName}(${paramList\n .map((_, i) => `{${i}}`)\n .join(', ')})'${logArgs});\\n`;\n });\n }\n\n public static processCatchBlocks(content: string, loggerName: string): string {\n return content.replace(this.CATCH_REGEX, (match: string, exceptionVar: string, offset: number) => {\n const contentBeforeCatch = content.substring(0, offset);\n const methodMatches = [...contentBeforeCatch.matchAll(this.METHOD_REGEX)];\n const lastMethodMatch = methodMatches[methodMatches.length - 1];\n const methodName = lastMethodMatch ? lastMethodMatch[5] : 'unknown';\n\n return `${match}\\n ${loggerName}.error('An error occurred in ${methodName}()', ${exceptionVar.trim()});`;\n });\n }\n\n public 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({\n condition: cleanedUpCondition,\n position: offset,\n });\n\n const logStatement = `${loggerName}.debug('if (${cleanedUpCondition})');\\n `;\n\n if (blockBody) {\n return `if (${condition}) {\\n ${logStatement}${blockBody}}\\n`;\n } else if (singleLineBody) {\n const cleanBody = singleLineBody.replace(/;$/, '').trim();\n return `if (${condition}) {\\n ${logStatement}${cleanBody};\\n }\\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 ?? 0))\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 public static processSystemDebugStatements(content: string, loggerName: string): string {\n return content.replace(this.SYSTEM_DEBUG_REGEX, (match, debugMessage) => `${loggerName}.debug('${debugMessage}');`);\n }\n\n private static isComplexType(paramType: string): boolean {\n return (\n paramType.includes('<') ||\n paramType.includes('[') ||\n paramType === 'Object' ||\n !this.PRIMITIVE_TYPES.has(paramType.toUpperCase())\n );\n }\n\n private static processParameters(args: string): ProcessedParameters {\n const parameters = args\n ? args\n .replaceAll(this.GENERIC_ARGS_REGEX, '')\n .split(',')\n .map((param) => param.trim())\n : [];\n\n const logArgs =\n parameters.length > 0 && parameters[0] !== ''\n ? `, new Object[] { ${parameters\n .map((p) => {\n const [paramType, ...rest] = p.split(' ');\n const paramName = rest.length > 0 ? rest.join(' ') : paramType;\n return this.isComplexType(paramType) ? `JSON.serialize(${paramName})` : paramName;\n })\n .join(', ')} }`\n : '';\n\n return { paramList: parameters, logArgs };\n }\n}\n\nexport default class RflibLoggingApexInstrument extends SfCommand<RflibLoggingApexInstrumentResult> {\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 prettier: Flags.boolean({\n summary: messages.getMessage('flags.prettier.summary'),\n description: messages.getMessage('flags.prettier.description'),\n char: 'p',\n default: false,\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: RflibLoggingApexInstrumentResult = {\n processedFiles: 0,\n modifiedFiles: 0,\n formattedFiles: 0,\n };\n\n public async run(): Promise<RflibLoggingApexInstrumentResult> {\n this.logger = await Logger.child(this.ctor.name);\n const startTime = Date.now();\n\n const { flags } = await this.parse(RflibLoggingApexInstrument);\n const sourcePath = flags.sourcepath;\n const isDryRun = flags.dryrun;\n\n const instrumentationOpts: InstrumentationOptions = {\n prettier: flags.prettier,\n noIf: flags['no-if'],\n skipInstrumented: flags['skip-instrumented'],\n };\n\n this.log(`Scanning Apex classes in ${sourcePath} and sub directories`);\n this.logger.debug(`Dry run mode: ${isDryRun}`);\n\n this.spinner.start('Running...');\n await this.processDirectory(sourcePath, isDryRun, instrumentationOpts);\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 this.log(`Formatted files: ${this.stats.formattedFiles}`);\n\n return { ...this.stats };\n }\n\n private async processDirectory(\n dirPath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n this.logger.debug(`Processing directory: ${dirPath}`);\n const files = await fs.promises.readdir(dirPath);\n\n for (const file of files) {\n const filePath = path.join(dirPath, file);\n const stat = await fs.promises.stat(filePath);\n\n if (stat.isDirectory()) {\n await this.processDirectory(filePath, isDryRun, instrumentationOpts);\n } else if (file.includes('Test') && file.endsWith('.cls')) {\n await this.processTestFile(filePath, isDryRun, instrumentationOpts);\n } else if (file.endsWith('.cls')) {\n await this.instrumentApexClass(filePath, isDryRun, instrumentationOpts);\n }\n }\n }\n\n private async processTestFile(\n filePath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n this.logger.debug(`Processing test file: ${filePath}`);\n let content = await fs.promises.readFile(filePath, 'utf8');\n const originalContent = content;\n\n if (instrumentationOpts.skipInstrumented && ApexInstrumentationService.isInstrumented(content)) {\n this.logger.info(`Skipping instrumented test class: ${filePath}`);\n return;\n }\n\n content = content.replace(\n ApexInstrumentationService.TEST_SETUP_REGEX,\n (match) => `${match}\\n rflib_TestUtil.prepareLoggerForUnitTests();`,\n );\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n if (!isDryRun) {\n try {\n const finalContent = instrumentationOpts.prettier\n ? await ApexInstrumentationService.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 test file: ${filePath}`);\n } else {\n this.logger.info(`Modified test file: ${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 test file without formatting: ${filePath}`);\n }\n } else {\n this.logger.info(`Would modify test file: ${filePath}`);\n }\n }\n }\n\n private async instrumentApexClass(\n filePath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n const className = path.basename(filePath, '.cls');\n this.logger.debug(`Processing class: ${className}`);\n\n try {\n this.stats.processedFiles++;\n let content = await fs.promises.readFile(filePath, 'utf8');\n const originalContent = content;\n\n if (instrumentationOpts.skipInstrumented && ApexInstrumentationService.isInstrumented(content)) {\n this.logger.info(`Skipping instrumented class: ${className}`);\n return;\n }\n\n const { variableName } = ApexInstrumentationService.detectLogger(content);\n content = ApexInstrumentationService.addLoggerDeclaration(content, className);\n content = ApexInstrumentationService.processMethodDeclarations(content, variableName);\n content = ApexInstrumentationService.processSystemDebugStatements(content, variableName);\n content = ApexInstrumentationService.processCatchBlocks(content, variableName);\n\n if (!instrumentationOpts.noIf) {\n content = ApexInstrumentationService.processIfStatements(content, variableName);\n }\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n if (!isDryRun) {\n try {\n const finalContent = instrumentationOpts.prettier\n ? await ApexInstrumentationService.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 } catch (error) {\n this.logger.error(`Error processing class ${className}`, error);\n throw error;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/apex/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,QAA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CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;wBAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,QAAQ,EAAE,CAAC,CAAC;oBAC/D,CAAC;gBACH,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,0BAA0B,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;YAChE,MAAM,KAAK,CAAC;QACd,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 ApexMethodMatch = {\n auraEnabled?: string;\n access: string;\n isStatic?: string;\n returnType: string;\n methodName: string;\n args: string;\n}\n\ntype IfCondition = {\n condition: string;\n position: number;\n}\n\ntype InstrumentationOptions = {\n readonly prettier: boolean;\n readonly noIf: boolean;\n readonly skipInstrumented: boolean;\n}\n\ntype LoggerInfo = {\n readonly exists: boolean;\n readonly variableName: string;\n}\n\ntype ProcessedParameters = {\n readonly paramList: readonly string[];\n readonly logArgs: string;\n}\n\nexport type RflibLoggingApexInstrumentResult = {\n processedFiles: number;\n modifiedFiles: number;\n formattedFiles: number;\n}\n\nMessages.importMessagesDirectoryFromMetaUrl(import.meta.url);\nconst messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.apex.instrument');\n\nclass ApexInstrumentationService {\n public static readonly TEST_SETUP_REGEX =\n /@TestSetup\\s+((public|private|protected|global)s+)?(?:static\\s+)?void\\s+(\\w+)\\s*\\([^)]*\\)\\s*{/g;\n\n private static readonly METHOD_REGEX =\n /(@AuraEnabled\\s*[\\s\\S]*?)?\\b(public|private|protected|global)\\s+(static\\s+)?(?:(\\w+(?:\\s*<(?:[^<>]|<[^<>]*>)*>)?)|void)\\s+(\\w+)\\s*\\(([\\s\\S]*?)\\)\\s*{/g;\n private static readonly CLASS_REGEX = /\\bclass\\s+\\w+\\s*{/;\n private static readonly CLASS_LOGGER_REGEX = /\\bprivate\\s+(?:static\\s+)?(?:final\\s+)?rflib_Logger\\s+(\\w+)\\b/;\n private static readonly GENERIC_ARGS_REGEX = /<[^>]+>/g;\n private static readonly CATCH_REGEX = /catch\\s*\\(\\s*\\w+\\s+(\\w+)\\s*\\)\\s*{/g;\n private static readonly IF_STATEMENT_REGEX =\n /if\\s*\\((.*?)\\)\\s*(?:{([^]*?(?:(?<!{){(?:[^]*?)}(?!})[^]*?)*)}|([^{].*?)(?=\\s*(?:;|$));)/g;\n private static readonly ELSE_REGEX = /\\s*else(?!\\s*if\\b)\\s*(?:{((?:[^{}]|{(?:[^{}]|{[^{}]*})*})*)}|([^{;]*(?:;|$)))/g;\n private static readonly IS_INSTRUMENTED_REGEX = /(\\brflib_Logger\\b|\\brflib_TestUtil\\b)/;\n private static readonly SYSTEM_DEBUG_REGEX = /System\\.debug\\s*\\(\\s*['\"]([^'\"]*)['\"]\\s*\\)\\s*;/g;\n\n private static readonly PRIMITIVE_TYPES = new Set([\n 'STRING',\n 'INTEGER',\n 'LONG',\n 'DECIMAL',\n 'DOUBLE',\n 'BOOLEAN',\n 'DATE',\n 'DATETIME',\n 'TIME',\n 'ID',\n ]);\n\n private static readonly PRETTIER_CONFIG: prettier.Options = {\n parser: 'apex',\n plugins: ['prettier-plugin-apex'],\n printWidth: 120,\n tabWidth: 4,\n useTabs: false,\n singleQuote: true,\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 isInstrumented(content: string): boolean {\n return this.IS_INSTRUMENTED_REGEX.test(content);\n }\n\n public static detectLogger(content: string): LoggerInfo {\n const match = content.match(this.CLASS_LOGGER_REGEX);\n return {\n exists: this.CLASS_LOGGER_REGEX.test(content),\n variableName: match ? match[1] : 'LOGGER',\n };\n }\n\n public static addLoggerDeclaration(content: string, className: string): string {\n const { exists, variableName } = this.detectLogger(content);\n if (!exists) {\n const loggerDecl = `private static final rflib_Logger ${variableName} = rflib_LoggerUtil.getFactory().createLogger('${className}');`;\n return content.replace(this.CLASS_REGEX, `$&\\n ${loggerDecl}`);\n }\n return content;\n }\n\n public static processMethodDeclarations(content: string, loggerName: string): string {\n return content.replace(this.METHOD_REGEX, (match: string, ...args: unknown[]) => {\n const methodInfo: ApexMethodMatch = {\n auraEnabled: args[0] as string,\n access: args[1] as string,\n isStatic: args[2] as string,\n returnType: args[3] as string,\n methodName: args[4] as string,\n args: args[5] as string,\n };\n\n const { paramList, logArgs } = this.processParameters(methodInfo.args);\n\n return `${match}\\n ${loggerName}.info('${methodInfo.methodName}(${paramList\n .map((_, i) => `{${i}}`)\n .join(', ')})'${logArgs});\\n`;\n });\n }\n\n public static processCatchBlocks(content: string, loggerName: string): string {\n return content.replace(this.CATCH_REGEX, (match: string, exceptionVar: string, offset: number) => {\n const contentBeforeCatch = content.substring(0, offset);\n const methodMatches = [...contentBeforeCatch.matchAll(this.METHOD_REGEX)];\n const lastMethodMatch = methodMatches[methodMatches.length - 1];\n const methodName = lastMethodMatch ? lastMethodMatch[5] : 'unknown';\n\n return `${match}\\n ${loggerName}.error('An error occurred in ${methodName}()', ${exceptionVar.trim()});`;\n });\n }\n\n public 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({\n condition: cleanedUpCondition,\n position: offset,\n });\n\n const logStatement = `${loggerName}.debug('if (${cleanedUpCondition})');\\n `;\n\n if (blockBody) {\n return `if (${condition}) {\\n ${logStatement}${blockBody}}\\n`;\n } else if (singleLineBody) {\n const cleanBody = singleLineBody.replace(/;$/, '').trim();\n return `if (${condition}) {\\n ${logStatement}${cleanBody};\\n }\\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 ?? 0))\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 public static processSystemDebugStatements(content: string, loggerName: string): string {\n return content.replace(this.SYSTEM_DEBUG_REGEX, (match, debugMessage) => `${loggerName}.debug('${debugMessage}');`);\n }\n\n private static isComplexType(paramType: string): boolean {\n return (\n paramType.includes('<') ||\n paramType.includes('[') ||\n paramType === 'Object' ||\n !this.PRIMITIVE_TYPES.has(paramType.toUpperCase())\n );\n }\n\n private static processParameters(args: string): ProcessedParameters {\n const parameters = args\n ? args\n .replaceAll(this.GENERIC_ARGS_REGEX, '')\n .split(',')\n .map((param) => param.trim())\n : [];\n\n const logArgs =\n parameters.length > 0 && parameters[0] !== ''\n ? `, new Object[] { ${parameters\n .map((p) => {\n const [paramType, ...rest] = p.split(' ');\n const paramName = rest.length > 0 ? rest.join(' ') : paramType;\n return this.isComplexType(paramType) ? `JSON.serialize(${paramName})` : paramName;\n })\n .join(', ')} }`\n : '';\n\n return { paramList: parameters, logArgs };\n }\n}\n\nexport default class RflibLoggingApexInstrument extends SfCommand<RflibLoggingApexInstrumentResult> {\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 prettier: Flags.boolean({\n summary: messages.getMessage('flags.prettier.summary'),\n description: messages.getMessage('flags.prettier.description'),\n char: 'p',\n default: false,\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: RflibLoggingApexInstrumentResult = {\n processedFiles: 0,\n modifiedFiles: 0,\n formattedFiles: 0,\n };\n\n public async run(): Promise<RflibLoggingApexInstrumentResult> {\n this.logger = await Logger.child(this.ctor.name);\n const startTime = Date.now();\n\n const { flags } = await this.parse(RflibLoggingApexInstrument);\n const sourcePath = flags.sourcepath;\n const isDryRun = flags.dryrun;\n\n const instrumentationOpts: InstrumentationOptions = {\n prettier: flags.prettier,\n noIf: flags['no-if'],\n skipInstrumented: flags['skip-instrumented'],\n };\n\n this.log(`Scanning Apex classes in ${sourcePath} and sub directories`);\n this.logger.debug(`Dry run mode: ${isDryRun}`);\n\n this.spinner.start('Running...');\n await this.processDirectory(sourcePath, isDryRun, instrumentationOpts);\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 this.log(`Formatted files: ${this.stats.formattedFiles}`);\n\n return { ...this.stats };\n }\n\n private async processDirectory(\n dirPath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n this.logger.debug(`Processing directory: ${dirPath}`);\n const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });\n\n await Promise.all(\n entries.map(async (entry) => {\n const filePath = path.join(dirPath, entry.name);\n\n if (entry.isDirectory()) {\n await this.processDirectory(filePath, isDryRun, instrumentationOpts);\n return;\n }\n\n if (entry.name.includes('Test') && entry.name.endsWith('.cls')) {\n await this.processTestFile(filePath, isDryRun, instrumentationOpts);\n return;\n }\n\n if (entry.name.endsWith('.cls')) {\n await this.instrumentApexClass(filePath, isDryRun, instrumentationOpts);\n }\n }),\n );\n }\n\n private async processTestFile(\n filePath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n this.logger.debug(`Processing test file: ${filePath}`);\n let content = await fs.promises.readFile(filePath, 'utf8');\n const originalContent = content;\n\n if (instrumentationOpts.skipInstrumented && ApexInstrumentationService.isInstrumented(content)) {\n this.logger.info(`Skipping instrumented test class: ${filePath}`);\n return;\n }\n\n content = content.replace(\n ApexInstrumentationService.TEST_SETUP_REGEX,\n (match) => `${match}\\n rflib_TestUtil.prepareLoggerForUnitTests();`,\n );\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n if (!isDryRun) {\n try {\n const finalContent = instrumentationOpts.prettier\n ? await ApexInstrumentationService.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 test file: ${filePath}`);\n } else {\n this.logger.info(`Modified test file: ${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 test file without formatting: ${filePath}`);\n }\n } else {\n this.logger.info(`Would modify test file: ${filePath}`);\n }\n }\n }\n\n private async instrumentApexClass(\n filePath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n const className = path.basename(filePath, '.cls');\n this.logger.debug(`Processing class: ${className}`);\n\n try {\n this.stats.processedFiles++;\n let content = await fs.promises.readFile(filePath, 'utf8');\n const originalContent = content;\n\n if (instrumentationOpts.skipInstrumented && ApexInstrumentationService.isInstrumented(content)) {\n this.logger.info(`Skipping instrumented class: ${className}`);\n return;\n }\n\n const { variableName } = ApexInstrumentationService.detectLogger(content);\n content = ApexInstrumentationService.addLoggerDeclaration(content, className);\n content = ApexInstrumentationService.processMethodDeclarations(content, variableName);\n content = ApexInstrumentationService.processSystemDebugStatements(content, variableName);\n content = ApexInstrumentationService.processCatchBlocks(content, variableName);\n\n if (!instrumentationOpts.noIf) {\n content = ApexInstrumentationService.processIfStatements(content, variableName);\n }\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n if (!isDryRun) {\n try {\n const finalContent = instrumentationOpts.prettier\n ? await ApexInstrumentationService.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 } catch (error) {\n this.logger.error(`Error processing class ${className}`, error);\n throw error;\n }\n }\n}\n"]}
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-await-in-loop */
2
1
  import * as fs from 'node:fs';
3
2
  import * as path from 'node:path';
4
3
  import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
@@ -200,17 +199,17 @@ export default class RflibLoggingAuraInstrument extends SfCommand {
200
199
  return;
201
200
  }
202
201
  const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
203
- for (const entry of entries) {
202
+ await Promise.all(entries
203
+ .filter((entry) => entry.isDirectory())
204
+ .map(async (entry) => {
204
205
  const fullPath = path.join(dirPath, entry.name);
205
- if (entry.isDirectory()) {
206
- if (entry.name === 'aura') {
207
- await this.processAuraComponents(fullPath, isDryRun, instrumentationOpts);
208
- }
209
- else {
210
- await this.processDirectory(fullPath, isDryRun, instrumentationOpts);
211
- }
206
+ if (entry.name === 'aura') {
207
+ await this.processAuraComponents(fullPath, isDryRun, instrumentationOpts);
212
208
  }
213
- }
209
+ else {
210
+ await this.processDirectory(fullPath, isDryRun, instrumentationOpts);
211
+ }
212
+ }));
214
213
  }
215
214
  async processAuraComponents(auraPath, isDryRun, instrumentationOpts) {
216
215
  if (path.basename(auraPath) !== 'aura') {
@@ -218,12 +217,9 @@ export default class RflibLoggingAuraInstrument extends SfCommand {
218
217
  return;
219
218
  }
220
219
  const entries = await fs.promises.readdir(auraPath, { withFileTypes: true });
221
- for (const entry of entries) {
222
- if (entry.isDirectory()) {
223
- const componentPath = path.join(auraPath, entry.name);
224
- await this.processAuraComponent(componentPath, entry.name, isDryRun, instrumentationOpts);
225
- }
226
- }
220
+ await Promise.all(entries
221
+ .filter((entry) => entry.isDirectory())
222
+ .map((entry) => this.processAuraComponent(path.join(auraPath, entry.name), entry.name, isDryRun, instrumentationOpts)));
227
223
  }
228
224
  async processAuraComponent(componentPath, componentName, isDryRun, instrumentationOpts) {
229
225
  this.logger.info(`Processing Aura component: ${componentName}`);
@@ -234,9 +230,11 @@ export default class RflibLoggingAuraInstrument extends SfCommand {
234
230
  try {
235
231
  const loggerId = await this.instrumentCmpFile(cmpPath, componentName, isDryRun);
236
232
  this.logger.debug(`Using logger ID: ${loggerId}`);
237
- await this.instrumentJsFile(controllerPath, loggerId, isDryRun, instrumentationOpts);
238
- await this.instrumentJsFile(helperPath, loggerId, isDryRun, instrumentationOpts);
239
- await this.instrumentJsFile(rendererPath, loggerId, isDryRun, instrumentationOpts);
233
+ await Promise.all([
234
+ this.instrumentJsFile(controllerPath, loggerId, isDryRun, instrumentationOpts),
235
+ this.instrumentJsFile(helperPath, loggerId, isDryRun, instrumentationOpts),
236
+ this.instrumentJsFile(rendererPath, loggerId, isDryRun, instrumentationOpts),
237
+ ]);
240
238
  }
241
239
  catch (error) {
242
240
  this.logger.error(`Error processing Aura component ${componentName}`, error);
@@ -1 +1 @@
1
- {"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/aura/instrument.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,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,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,+BAA+B,CAAC,CAAC;AAExF,MAAM,0BAA0B;IACvB,MAAM,CAAU,eAAe,GAAG,wBAAwB,CAAC;IAC3D,MAAM,CAAU,sBAAsB,GAC3C,4FAA4F,CAAC;IAEvF,MAAM,CAAU,gBAAgB,GAAG,+CAA+C,CAAC;IACnF,MAAM,CAAU,YAAY,GAClC,oHAAoH,CAAC;IAC/G,MAAM,CAAU,mBAAmB,GAAG,sEAAsE,CAAC;IAC7G,MAAM,CAAU,qBAAqB,GAAG,6CAA6C,CAAC;IACtF,MAAM,CAAU,kBAAkB,GACxC,0FAA0F,CAAC;IACrF,MAAM,CAAU,UAAU,GAChC,qFAAqF,CAAC;IAChF,MAAM,CAAU,iBAAiB,GAAG,gEAAgE,CAAC;IAErG,MAAM,CA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C,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":["/* eslint-disable no-await-in-loop */\nimport * 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 await this.processDirectory(flags.sourcepath, flags.dryrun, instrumentationOpts);\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 processDirectory(\n dirPath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n this.logger.debug(`Processing directory: ${dirPath}`);\n\n const dirName = path.basename(dirPath);\n const parentDir = path.basename(path.dirname(dirPath));\n\n if (parentDir === 'aura') {\n this.logger.info(`Processing single component: ${dirName}`);\n await this.processAuraComponent(dirPath, dirName, isDryRun, instrumentationOpts);\n return;\n }\n\n const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dirPath, entry.name);\n\n if (entry.isDirectory()) {\n if (entry.name === 'aura') {\n await this.processAuraComponents(fullPath, isDryRun, instrumentationOpts);\n } else {\n await this.processDirectory(fullPath, isDryRun, instrumentationOpts);\n }\n }\n }\n }\n\n private async processAuraComponents(\n auraPath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n if (path.basename(auraPath) !== 'aura') {\n this.logger.warn(`Not an aura directory: ${auraPath}`);\n return;\n }\n\n const entries = await fs.promises.readdir(auraPath, { withFileTypes: true });\n\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const componentPath = path.join(auraPath, entry.name);\n await this.processAuraComponent(componentPath, entry.name, isDryRun, instrumentationOpts);\n }\n }\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 this.instrumentJsFile(controllerPath, loggerId, isDryRun, instrumentationOpts);\n await this.instrumentJsFile(helperPath, loggerId, isDryRun, instrumentationOpts);\n await this.instrumentJsFile(rendererPath, loggerId, isDryRun, instrumentationOpts);\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;AAmBrC,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,0BAA0B;IACvB,MAAM,CAAU,eAAe,GAAG,wBAAwB,CAAC;IAC3D,MAAM,CAAU,sBAAsB,GAC3C,4FAA4F,CAAC;IAEvF,MAAM,CAAU,gBAAgB,GAAG,+CAA+C,CAAC;IACnF,MAAM,CAA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AE,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 await this.processDirectory(flags.sourcepath, flags.dryrun, instrumentationOpts);\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 processDirectory(\n dirPath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n this.logger.debug(`Processing directory: ${dirPath}`);\n\n const dirName = path.basename(dirPath);\n const parentDir = path.basename(path.dirname(dirPath));\n\n if (parentDir === 'aura') {\n this.logger.info(`Processing single component: ${dirName}`);\n await this.processAuraComponent(dirPath, dirName, isDryRun, instrumentationOpts);\n return;\n }\n\n const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });\n\n await Promise.all(\n entries\n .filter((entry) => entry.isDirectory())\n .map(async (entry) => {\n const fullPath = path.join(dirPath, entry.name);\n\n if (entry.name === 'aura') {\n await this.processAuraComponents(fullPath, isDryRun, instrumentationOpts);\n } else {\n await this.processDirectory(fullPath, isDryRun, instrumentationOpts);\n }\n }),\n );\n }\n\n private async processAuraComponents(\n auraPath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n if (path.basename(auraPath) !== 'aura') {\n this.logger.warn(`Not an aura directory: ${auraPath}`);\n return;\n }\n\n const entries = await fs.promises.readdir(auraPath, { withFileTypes: true });\n\n await Promise.all(\n entries\n .filter((entry) => entry.isDirectory())\n .map((entry) =>\n this.processAuraComponent(\n path.join(auraPath, entry.name),\n entry.name,\n isDryRun,\n instrumentationOpts,\n ),\n ),\n );\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,4 +1,4 @@
1
- /* eslint-disable no-await-in-loop, sf-plugin/only-extend-SfCommand */
1
+ /* eslint-disable sf-plugin/only-extend-SfCommand */
2
2
  /* eslint-disable @typescript-eslint/return-await */
3
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
4
  /* eslint-disable @typescript-eslint/no-unsafe-call */
@@ -559,17 +559,17 @@ export default class RflibLoggingFlowInstrument extends SfCommand {
559
559
  }
560
560
  async processDirectory(dirPath, isDryRun, skipInstrumented) {
561
561
  this.logger.debug(`Processing directory: ${dirPath}`);
562
- const files = await fs.promises.readdir(dirPath);
563
- for (const file of files) {
564
- const filePath = path.join(dirPath, file);
565
- const stat = await fs.promises.stat(filePath);
566
- if (stat.isDirectory()) {
562
+ const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
563
+ await Promise.all(entries.map(async (entry) => {
564
+ const filePath = path.join(dirPath, entry.name);
565
+ if (entry.isDirectory()) {
567
566
  await this.processDirectory(filePath, isDryRun, skipInstrumented);
567
+ return;
568
568
  }
569
- else if (file.endsWith('.flow-meta.xml')) {
569
+ if (entry.name.endsWith('.flow-meta.xml')) {
570
570
  await this.instrumentFlowFile(filePath, isDryRun, skipInstrumented);
571
571
  }
572
- }
572
+ }));
573
573
  }
574
574
  async instrumentFlowFile(filePath, isDryRun, skipInstrumented) {
575
575
  const flowName = path.basename(filePath, '.flow-meta.xml');