rflib-plugin 0.17.1 → 0.17.2

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.
@@ -9,7 +9,8 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
9
9
  const messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.aura.instrument');
10
10
  class AuraInstrumentationService {
11
11
  static ATTRIBUTE_REGEX = /<aura:attribute[^>]*>/g;
12
- static LOGGER_COMPONENT_REGEX = /<c:rflibLoggerCmp\s+aura:id="([^"]+)"\s+name="([^"]+)"\s+appendComponentId="([^"]+)"\s*\/>/;
12
+ static LOGGER_COMPONENT_REGEX = /<c:rflibLoggerCmp\b[^>]*\/?>/i;
13
+ static LOGGER_AURA_ID_REGEX = /aura:id=["']([^"']+)["']/;
13
14
  static PRETTIER_CONFIG = {
14
15
  parser: 'babel',
15
16
  printWidth: 120,
@@ -53,6 +54,7 @@ class AuraInstrumentationService {
53
54
  bodyContent = this.processIfStatements(bodyContent, loggerVar);
54
55
  }
55
56
  bodyContent = AuraInstrumentationService.processPromiseChains(bodyContent, loggerVar);
57
+ bodyContent = AuraInstrumentationService.processTryCatchBlocks(bodyContent, loggerVar, methodName);
56
58
  bodyContent = AuraInstrumentationService.processConsoleStatements(bodyContent, loggerVar);
57
59
  return `${methodName}: function(${params}) {${bodyContent}}`;
58
60
  });
@@ -63,11 +65,11 @@ class AuraInstrumentationService {
63
65
  return match.replace(blockBody, `\n ${logStatement}\n ${blockBody}`);
64
66
  });
65
67
  }
66
- static processTryCatchBlocks(content) {
68
+ static processTryCatchBlocks(content, loggerVar, methodName) {
67
69
  return content.replace(this.TRY_CATCH_BLOCK_REGEX, (match, exceptionVar) => {
68
70
  const errorVar = exceptionVar.trim().split(' ')[0] || 'error';
69
71
  return match.replace(/catch\s*\(([^)]*)\)\s*{/, `catch(${exceptionVar}) {
70
- logger.error('An error occurred', ${errorVar});`);
72
+ ${loggerVar}.error('An error occurred in ${methodName}', ${errorVar});`);
71
73
  });
72
74
  }
73
75
  static processPromiseType(type, paramName, loggerVar) {
@@ -278,7 +280,8 @@ export default class RflibLoggingAuraInstrument extends SfCommand {
278
280
  const originalContent = content;
279
281
  const loggerMatch = content.match(AuraInstrumentationService.LOGGER_COMPONENT_REGEX);
280
282
  if (loggerMatch) {
281
- return loggerMatch[1];
283
+ const idMatch = loggerMatch[0].match(AuraInstrumentationService.LOGGER_AURA_ID_REGEX);
284
+ return idMatch ? idMatch[1] : 'logger';
282
285
  }
283
286
  const lastAttributeMatch = [...content.matchAll(AuraInstrumentationService.ATTRIBUTE_REGEX)].pop();
284
287
  if (lastAttributeMatch) {
@@ -286,6 +289,14 @@ export default class RflibLoggingAuraInstrument extends SfCommand {
286
289
  const loggerComponent = `\n <c:rflibLoggerCmp aura:id="logger" name="${componentName}" appendComponentId="false" />`;
287
290
  content = content.slice(0, insertPosition) + loggerComponent + content.slice(insertPosition);
288
291
  }
292
+ else {
293
+ const componentMatch = content.match(/<aura:component[^>]*>/);
294
+ if (componentMatch) {
295
+ const insertPosition = componentMatch.index + componentMatch[0].length;
296
+ const loggerComponent = `\n <c:rflibLoggerCmp aura:id="logger" name="${componentName}" appendComponentId="false" />`;
297
+ content = content.slice(0, insertPosition) + loggerComponent + content.slice(insertPosition);
298
+ }
299
+ }
289
300
  if (content !== originalContent) {
290
301
  this.stats.modifiedFiles++;
291
302
  this.stats.modifiedFilePaths?.push(filePath);
@@ -318,7 +329,6 @@ export default class RflibLoggingAuraInstrument extends SfCommand {
318
329
  const isHelper = filePath.endsWith('Helper.js');
319
330
  // Process methods and other patterns
320
331
  content = AuraInstrumentationService.processMethodLogging(content, loggerId, isHelper, instrumentationOpts.noIf);
321
- content = AuraInstrumentationService.processTryCatchBlocks(content);
322
332
  if (content !== originalContent) {
323
333
  await writeInstrumentedFile(filePath, content, originalContent, instrumentationOpts, isDryRun, this.stats, this.logger, (msg) => this.log(msg), AuraInstrumentationService.PRETTIER_CONFIG);
324
334
  }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O,EAAE,QAAQ,CAAC,EAAE,CAAC;YACzG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;YAC5D,OAAO;QACT,CAAC;QAED,MAAM,eAAe,GAAG,OAAO,CAAC;QAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAEhD,qCAAqC;QACrC,OAAO,GAAG,0BAA0B,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACjH,OAAO,GAAG,0BAA0B,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAEpE,IAAI,OAAO,KAAK,eAAe,EAAE,CAAC;YAChC,MAAM,qBAAqB,CACzB,QAAQ,EACR,OAAO,EACP,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EACtB,0BAA0B,CAAC,eAAe,CAC3C,CAAC;QACJ,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';\nimport { processWithConcurrency } from '../../../../shared/concurrency.js';\n\nimport { IfCondition, InstrumentationOptions } from '../../../../shared/types.js';\nimport { writeInstrumentedFile } from '../../../../shared/formatting.js';\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 public 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 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\n\n public static isInstrumented(content: string, loggerId: string): boolean {\n return new RegExp(`\\\\.find\\\\(['\"]${loggerId}['\"]\\\\)`, 'g').test(content);\n }\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 concurrency: Flags.integer({\n summary: messages.getMessage('flags.concurrency.summary'),\n description: messages.getMessage('flags.concurrency.description'),\n char: 'c',\n default: 10,\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 noCatch: false,\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 processWithConcurrency(\n components,\n flags.concurrency,\n 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 await writeInstrumentedFile(\n filePath,\n content,\n originalContent,\n instrumentationOpts,\n isDryRun,\n this.stats,\n this.logger,\n (msg) => this.log(msg),\n AuraInstrumentationService.PRETTIER_CONFIG,\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;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,EAAE,qBAAqB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CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;QAE5B,IAAI,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3D,IAAI,mBAAmB,CAAC,gBAAgB,IAAI,0BAA0B,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;YACzG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;YAC5D,OAAO;QACT,CAAC;QAED,MAAM,eAAe,GAAG,OAAO,CAAC;QAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAEhD,qCAAqC;QACrC,OAAO,GAAG,0BAA0B,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAEjH,IAAI,OAAO,KAAK,eAAe,EAAE,CAAC;YAChC,MAAM,qBAAqB,CACzB,QAAQ,EACR,OAAO,EACP,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EACtB,0BAA0B,CAAC,eAAe,CAC3C,CAAC;QACJ,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';\nimport { processWithConcurrency } from '../../../../shared/concurrency.js';\n\nimport { IfCondition, InstrumentationOptions } from '../../../../shared/types.js';\nimport { writeInstrumentedFile } from '../../../../shared/formatting.js';\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 = /<c:rflibLoggerCmp\\b[^>]*\\/?>/i;\n public static readonly LOGGER_AURA_ID_REGEX = /aura:id=[\"']([^\"']+)[\"']/;\n\n public 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 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\n\n public static isInstrumented(content: string, loggerId: string): boolean {\n return new RegExp(`\\\\.find\\\\(['\"]${loggerId}['\"]\\\\)`, 'g').test(content);\n }\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.processTryCatchBlocks(bodyContent, loggerVar, methodName);\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, loggerVar: string, methodName: 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 ${loggerVar}.error('An error occurred in ${methodName}', ${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 concurrency: Flags.integer({\n summary: messages.getMessage('flags.concurrency.summary'),\n description: messages.getMessage('flags.concurrency.description'),\n char: 'c',\n default: 10,\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 noCatch: false,\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 processWithConcurrency(\n components,\n flags.concurrency,\n 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 const idMatch = loggerMatch[0].match(AuraInstrumentationService.LOGGER_AURA_ID_REGEX);\n return idMatch ? idMatch[1] : 'logger';\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 } else {\n const componentMatch = content.match(/<aura:component[^>]*>/);\n if (componentMatch) {\n const insertPosition = componentMatch.index! + componentMatch[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\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\n if (content !== originalContent) {\n await writeInstrumentedFile(\n filePath,\n content,\n originalContent,\n instrumentationOpts,\n isDryRun,\n this.stats,\n this.logger,\n (msg) => this.log(msg),\n AuraInstrumentationService.PRETTIER_CONFIG,\n );\n }\n }\n}\n"]}
package/oclif.lock CHANGED
@@ -774,16 +774,16 @@
774
774
  resolve-global "1.0.0"
775
775
  yargs "^17.0.0"
776
776
 
777
- "@commitlint/cli@^20.4.1":
778
- version "20.4.2"
779
- resolved "https://registry.npmjs.org/@commitlint/cli/-/cli-20.4.2.tgz"
780
- integrity sha512-YjYSX2yj/WsVoxh9mNiymfFS2ADbg2EK4+1WAsMuckwKMCqJ5PDG0CJU/8GvmHWcv4VRB2V02KqSiecRksWqZQ==
781
- dependencies:
782
- "@commitlint/format" "^20.4.0"
783
- "@commitlint/lint" "^20.4.2"
784
- "@commitlint/load" "^20.4.0"
785
- "@commitlint/read" "^20.4.0"
786
- "@commitlint/types" "^20.4.0"
777
+ "@commitlint/cli@^20.4.3":
778
+ version "20.4.3"
779
+ resolved "https://registry.yarnpkg.com/@commitlint/cli/-/cli-20.4.3.tgz#250e3a46f2e337ae96c288317e9e3026a68d0700"
780
+ integrity sha512-Z37EMoDT7+Upg500vlr/vZrgRsb6Xc5JAA3Tv7BYbobnN/ZpqUeZnSLggBg2+1O+NptRDtyujr2DD1CPV2qwhA==
781
+ dependencies:
782
+ "@commitlint/format" "^20.4.3"
783
+ "@commitlint/lint" "^20.4.3"
784
+ "@commitlint/load" "^20.4.3"
785
+ "@commitlint/read" "^20.4.3"
786
+ "@commitlint/types" "^20.4.3"
787
787
  tinyexec "^1.0.0"
788
788
  yargs "^17.0.0"
789
789
 
@@ -802,12 +802,12 @@
802
802
  "@commitlint/types" "^17.8.1"
803
803
  ajv "^8.11.0"
804
804
 
805
- "@commitlint/config-validator@^20.4.0":
806
- version "20.4.0"
807
- resolved "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-20.4.0.tgz"
808
- integrity sha512-zShmKTF+sqyNOfAE0vKcqnpvVpG0YX8F9G/ZIQHI2CoKyK+PSdladXMSns400aZ5/QZs+0fN75B//3Q5CHw++w==
805
+ "@commitlint/config-validator@^20.4.3":
806
+ version "20.4.3"
807
+ resolved "https://registry.yarnpkg.com/@commitlint/config-validator/-/config-validator-20.4.3.tgz#45e89b4038ee97ab04d1eb95aaafc78033148bcc"
808
+ integrity sha512-jCZpZFkcSL3ZEdL5zgUzFRdytv3xPo8iukTe9VA+QGus/BGhpp1xXSVu2B006GLLb2gYUAEGEqv64kTlpZNgmA==
809
809
  dependencies:
810
- "@commitlint/types" "^20.4.0"
810
+ "@commitlint/types" "^20.4.3"
811
811
  ajv "^8.11.0"
812
812
 
813
813
  "@commitlint/ensure@^17.8.1":
@@ -822,12 +822,12 @@
822
822
  lodash.startcase "^4.4.0"
823
823
  lodash.upperfirst "^4.3.1"
824
824
 
825
- "@commitlint/ensure@^20.4.1":
826
- version "20.4.1"
827
- resolved "https://registry.npmjs.org/@commitlint/ensure/-/ensure-20.4.1.tgz"
828
- integrity sha512-WLQqaFx1pBooiVvBrA1YfJNFqZF8wS/YGOtr5RzApDbV9tQ52qT5VkTsY65hFTnXhW8PcDfZLaknfJTmPejmlw==
825
+ "@commitlint/ensure@^20.4.3":
826
+ version "20.4.3"
827
+ resolved "https://registry.yarnpkg.com/@commitlint/ensure/-/ensure-20.4.3.tgz#dc5406126da7bd0c7a30896b50f9962fe5488e8c"
828
+ integrity sha512-WcXGKBNn0wBKpX8VlXgxqedyrLxedIlLBCMvdamLnJFEbUGJ9JZmBVx4vhLV3ZyA8uONGOb+CzW0Y9HDbQ+ONQ==
829
829
  dependencies:
830
- "@commitlint/types" "^20.4.0"
830
+ "@commitlint/types" "^20.4.3"
831
831
  lodash.camelcase "^4.3.0"
832
832
  lodash.kebabcase "^4.1.1"
833
833
  lodash.snakecase "^4.1.1"
@@ -852,12 +852,12 @@
852
852
  "@commitlint/types" "^17.8.1"
853
853
  chalk "^4.1.0"
854
854
 
855
- "@commitlint/format@^20.4.0":
856
- version "20.4.0"
857
- resolved "https://registry.npmjs.org/@commitlint/format/-/format-20.4.0.tgz"
858
- integrity sha512-i3ki3WR0rgolFVX6r64poBHXM1t8qlFel1G1eCBvVgntE3fCJitmzSvH5JD/KVJN/snz6TfaX2CLdON7+s4WVQ==
855
+ "@commitlint/format@^20.4.3":
856
+ version "20.4.3"
857
+ resolved "https://registry.yarnpkg.com/@commitlint/format/-/format-20.4.3.tgz#bc36da1d648b4083108138e7807ae85e5b7bb67d"
858
+ integrity sha512-UDJVErjLbNghop6j111rsHJYGw6MjCKAi95K0GT2yf4eeiDHy3JDRLWYWEjIaFgO+r+dQSkuqgJ1CdMTtrvHsA==
859
859
  dependencies:
860
- "@commitlint/types" "^20.4.0"
860
+ "@commitlint/types" "^20.4.3"
861
861
  picocolors "^1.1.1"
862
862
 
863
863
  "@commitlint/is-ignored@^17.8.1":
@@ -868,12 +868,12 @@
868
868
  "@commitlint/types" "^17.8.1"
869
869
  semver "7.5.4"
870
870
 
871
- "@commitlint/is-ignored@^20.4.1":
872
- version "20.4.1"
873
- resolved "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-20.4.1.tgz"
874
- integrity sha512-In5EO4JR1lNsAv1oOBBO24V9ND1IqdAJDKZiEpdfjDl2HMasAcT7oA+5BKONv1pRoLG380DGPE2W2RIcUwdgLA==
871
+ "@commitlint/is-ignored@^20.4.3":
872
+ version "20.4.3"
873
+ resolved "https://registry.yarnpkg.com/@commitlint/is-ignored/-/is-ignored-20.4.3.tgz#21302df68e2652c8ee566ece2bcaa9a19c463ae1"
874
+ integrity sha512-W5VQKZ7fdJ1X3Tko+h87YZaqRMGN1KvQKXyCM8xFdxzMIf1KCZgN4uLz3osLB1zsFcVS4ZswHY64LI26/9ACag==
875
875
  dependencies:
876
- "@commitlint/types" "^20.4.0"
876
+ "@commitlint/types" "^20.4.3"
877
877
  semver "^7.6.0"
878
878
 
879
879
  "@commitlint/lint@^17.8.1":
@@ -886,15 +886,15 @@
886
886
  "@commitlint/rules" "^17.8.1"
887
887
  "@commitlint/types" "^17.8.1"
888
888
 
889
- "@commitlint/lint@^20.4.2":
890
- version "20.4.2"
891
- resolved "https://registry.npmjs.org/@commitlint/lint/-/lint-20.4.2.tgz"
892
- integrity sha512-buquzNRtFng6xjXvBU1abY/WPEEjCgUipNQrNmIWe8QuJ6LWLtei/LDBAzEe5ASm45+Q9L2Xi3/GVvlj50GAug==
889
+ "@commitlint/lint@^20.4.3":
890
+ version "20.4.3"
891
+ resolved "https://registry.yarnpkg.com/@commitlint/lint/-/lint-20.4.3.tgz#188efbdf9c10d9ff078ffdaf97cd14bc2171eea8"
892
+ integrity sha512-CYOXL23e+nRKij81+d0+dymtIi7Owl9QzvblJYbEfInON/4MaETNSLFDI74LDu+YJ0ML5HZyw9Vhp9QpckwQ0A==
893
893
  dependencies:
894
- "@commitlint/is-ignored" "^20.4.1"
895
- "@commitlint/parse" "^20.4.1"
896
- "@commitlint/rules" "^20.4.2"
897
- "@commitlint/types" "^20.4.0"
894
+ "@commitlint/is-ignored" "^20.4.3"
895
+ "@commitlint/parse" "^20.4.3"
896
+ "@commitlint/rules" "^20.4.3"
897
+ "@commitlint/types" "^20.4.3"
898
898
 
899
899
  "@commitlint/load@^17.8.1":
900
900
  version "17.8.1"
@@ -916,16 +916,16 @@
916
916
  ts-node "^10.8.1"
917
917
  typescript "^4.6.4 || ^5.2.2"
918
918
 
919
- "@commitlint/load@^20.4.0":
920
- version "20.4.0"
921
- resolved "https://registry.npmjs.org/@commitlint/load/-/load-20.4.0.tgz"
922
- integrity sha512-Dauup/GfjwffBXRJUdlX/YRKfSVXsXZLnINXKz0VZkXdKDcaEILAi9oflHGbfydonJnJAbXEbF3nXPm9rm3G6A==
919
+ "@commitlint/load@^20.4.3":
920
+ version "20.4.3"
921
+ resolved "https://registry.yarnpkg.com/@commitlint/load/-/load-20.4.3.tgz#372092f6c77251c11111f69ce01d66f834d79adf"
922
+ integrity sha512-3cdJOUVP+VcgHa7bhJoWS+Z8mBNXB5aLWMBu7Q7uX8PSeWDzdbrBlR33J1MGGf7r1PZDp+mPPiFktk031PgdRw==
923
923
  dependencies:
924
- "@commitlint/config-validator" "^20.4.0"
924
+ "@commitlint/config-validator" "^20.4.3"
925
925
  "@commitlint/execute-rule" "^20.0.0"
926
- "@commitlint/resolve-extends" "^20.4.0"
927
- "@commitlint/types" "^20.4.0"
928
- cosmiconfig "^9.0.0"
926
+ "@commitlint/resolve-extends" "^20.4.3"
927
+ "@commitlint/types" "^20.4.3"
928
+ cosmiconfig "^9.0.1"
929
929
  cosmiconfig-typescript-loader "^6.1.0"
930
930
  is-plain-obj "^4.1.0"
931
931
  lodash.mergewith "^4.6.2"
@@ -936,10 +936,10 @@
936
936
  resolved "https://registry.npmjs.org/@commitlint/message/-/message-17.8.1.tgz"
937
937
  integrity sha512-6bYL1GUQsD6bLhTH3QQty8pVFoETfFQlMn2Nzmz3AOLqRVfNNtXBaSY0dhZ0dM6A2MEq4+2d7L/2LP8TjqGRkA==
938
938
 
939
- "@commitlint/message@^20.4.0":
940
- version "20.4.0"
941
- resolved "https://registry.npmjs.org/@commitlint/message/-/message-20.4.0.tgz"
942
- integrity sha512-B5lGtvHgiLAIsK5nLINzVW0bN5hXv+EW35sKhYHE8F7V9Uz1fR4tx3wt7mobA5UNhZKUNgB/+ldVMQE6IHZRyA==
939
+ "@commitlint/message@^20.4.3":
940
+ version "20.4.3"
941
+ resolved "https://registry.yarnpkg.com/@commitlint/message/-/message-20.4.3.tgz#0c377fbbe1c72487612330a01d1e7dea991fa467"
942
+ integrity sha512-6akwCYrzcrFcTYz9GyUaWlhisY4lmQ3KvrnabmhoeAV8nRH4dXJAh4+EUQ3uArtxxKQkvxJS78hNX2EU3USgxQ==
943
943
 
944
944
  "@commitlint/parse@^17.8.1":
945
945
  version "17.8.1"
@@ -950,14 +950,14 @@
950
950
  conventional-changelog-angular "^6.0.0"
951
951
  conventional-commits-parser "^4.0.0"
952
952
 
953
- "@commitlint/parse@^20.4.1":
954
- version "20.4.1"
955
- resolved "https://registry.npmjs.org/@commitlint/parse/-/parse-20.4.1.tgz"
956
- integrity sha512-XNtZjeRcFuAfUnhYrCY02+mpxwY4OmnvD3ETbVPs25xJFFz1nRo/25nHj+5eM+zTeRFvWFwD4GXWU2JEtoK1/w==
953
+ "@commitlint/parse@^20.4.3":
954
+ version "20.4.3"
955
+ resolved "https://registry.yarnpkg.com/@commitlint/parse/-/parse-20.4.3.tgz#47ae05ba815101d59b9c64089d4a7f01742a1cf9"
956
+ integrity sha512-hzC3JCo3zs3VkQ833KnGVuWjWIzR72BWZWjQM7tY/7dfKreKAm7fEsy71tIFCRtxf2RtMP2d3RLF1U9yhFSccA==
957
957
  dependencies:
958
- "@commitlint/types" "^20.4.0"
959
- conventional-changelog-angular "^8.1.0"
960
- conventional-commits-parser "^6.2.1"
958
+ "@commitlint/types" "^20.4.3"
959
+ conventional-changelog-angular "^8.2.0"
960
+ conventional-commits-parser "^6.3.0"
961
961
 
962
962
  "@commitlint/read@^17.8.1":
963
963
  version "17.8.1"
@@ -970,13 +970,13 @@
970
970
  git-raw-commits "^2.0.11"
971
971
  minimist "^1.2.6"
972
972
 
973
- "@commitlint/read@^20.4.0":
974
- version "20.4.0"
975
- resolved "https://registry.npmjs.org/@commitlint/read/-/read-20.4.0.tgz"
976
- integrity sha512-QfpFn6/I240ySEGv7YWqho4vxqtPpx40FS7kZZDjUJ+eHxu3azfhy7fFb5XzfTqVNp1hNoI3tEmiEPbDB44+cg==
973
+ "@commitlint/read@^20.4.3":
974
+ version "20.4.3"
975
+ resolved "https://registry.yarnpkg.com/@commitlint/read/-/read-20.4.3.tgz#235f685234ebc33ee22b748759ca69433f955026"
976
+ integrity sha512-j42OWv3L31WfnP8WquVjHZRt03w50Y/gEE8FAyih7GQTrIv2+pZ6VZ6pWLD/ml/3PO+RV2SPtRtTp/MvlTb8rQ==
977
977
  dependencies:
978
- "@commitlint/top-level" "^20.4.0"
979
- "@commitlint/types" "^20.4.0"
978
+ "@commitlint/top-level" "^20.4.3"
979
+ "@commitlint/types" "^20.4.3"
980
980
  git-raw-commits "^4.0.0"
981
981
  minimist "^1.2.8"
982
982
  tinyexec "^1.0.0"
@@ -993,13 +993,13 @@
993
993
  resolve-from "^5.0.0"
994
994
  resolve-global "^1.0.0"
995
995
 
996
- "@commitlint/resolve-extends@^20.4.0":
997
- version "20.4.0"
998
- resolved "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-20.4.0.tgz"
999
- integrity sha512-ay1KM8q0t+/OnlpqXJ+7gEFQNlUtSU5Gxr8GEwnVf2TPN3+ywc5DzL3JCxmpucqxfHBTFwfRMXxPRRnR5Ki20g==
996
+ "@commitlint/resolve-extends@^20.4.3":
997
+ version "20.4.3"
998
+ resolved "https://registry.yarnpkg.com/@commitlint/resolve-extends/-/resolve-extends-20.4.3.tgz#b644c4f4812b298191a28f4040cd24d724b8a74c"
999
+ integrity sha512-QucxcOy+00FhS9s4Uy0OyS5HeUV+hbC6OLqkTSIm6fwMdKva+OEavaCDuLtgd9akZZlsUo//XzSmPP3sLKBPog==
1000
1000
  dependencies:
1001
- "@commitlint/config-validator" "^20.4.0"
1002
- "@commitlint/types" "^20.4.0"
1001
+ "@commitlint/config-validator" "^20.4.3"
1002
+ "@commitlint/types" "^20.4.3"
1003
1003
  global-directory "^4.0.1"
1004
1004
  import-meta-resolve "^4.0.0"
1005
1005
  lodash.mergewith "^4.6.2"
@@ -1016,15 +1016,15 @@
1016
1016
  "@commitlint/types" "^17.8.1"
1017
1017
  execa "^5.0.0"
1018
1018
 
1019
- "@commitlint/rules@^20.4.2":
1020
- version "20.4.2"
1021
- resolved "https://registry.npmjs.org/@commitlint/rules/-/rules-20.4.2.tgz"
1022
- integrity sha512-oz83pnp5Yq6uwwTAabuVQPNlPfeD2Y5ZjMb7Wx8FSUlu4sLYJjbBWt8031Z0osCFPfHzAwSYrjnfDFKtuSMdKg==
1019
+ "@commitlint/rules@^20.4.3":
1020
+ version "20.4.3"
1021
+ resolved "https://registry.yarnpkg.com/@commitlint/rules/-/rules-20.4.3.tgz#3f5045abd091125799c17b7e79f0b6b2b7a6bc94"
1022
+ integrity sha512-Yuosd7Grn5qiT7FovngXLyRXTMUbj9PYiSkvUgWK1B5a7+ZvrbWDS7epeUapYNYatCy/KTpPFPbgLUdE+MUrBg==
1023
1023
  dependencies:
1024
- "@commitlint/ensure" "^20.4.1"
1025
- "@commitlint/message" "^20.4.0"
1024
+ "@commitlint/ensure" "^20.4.3"
1025
+ "@commitlint/message" "^20.4.3"
1026
1026
  "@commitlint/to-lines" "^20.0.0"
1027
- "@commitlint/types" "^20.4.0"
1027
+ "@commitlint/types" "^20.4.3"
1028
1028
 
1029
1029
  "@commitlint/to-lines@^17.8.1":
1030
1030
  version "17.8.1"
@@ -1043,10 +1043,10 @@
1043
1043
  dependencies:
1044
1044
  find-up "^5.0.0"
1045
1045
 
1046
- "@commitlint/top-level@^20.4.0":
1047
- version "20.4.0"
1048
- resolved "https://registry.npmjs.org/@commitlint/top-level/-/top-level-20.4.0.tgz"
1049
- integrity sha512-NDzq8Q6jmFaIIBC/GG6n1OQEaHdmaAAYdrZRlMgW6glYWGZ+IeuXmiymDvQNXPc82mVxq2KiE3RVpcs+1OeDeA==
1046
+ "@commitlint/top-level@^20.4.3":
1047
+ version "20.4.3"
1048
+ resolved "https://registry.yarnpkg.com/@commitlint/top-level/-/top-level-20.4.3.tgz#6f94e558c1aa6ba3a1d6962e9adaa34f657efe81"
1049
+ integrity sha512-qD9xfP6dFg5jQ3NMrOhG0/w5y3bBUsVGyJvXxdWEwBm8hyx4WOk3kKXw28T5czBYvyeCVJgJJ6aoJZUWDpaacQ==
1050
1050
  dependencies:
1051
1051
  escalade "^3.2.0"
1052
1052
 
@@ -1057,12 +1057,12 @@
1057
1057
  dependencies:
1058
1058
  chalk "^4.1.0"
1059
1059
 
1060
- "@commitlint/types@^20.4.0":
1061
- version "20.4.0"
1062
- resolved "https://registry.npmjs.org/@commitlint/types/-/types-20.4.0.tgz"
1063
- integrity sha512-aO5l99BQJ0X34ft8b0h7QFkQlqxC6e7ZPVmBKz13xM9O8obDaM1Cld4sQlJDXXU/VFuUzQ30mVtHjVz74TuStw==
1060
+ "@commitlint/types@^20.4.3":
1061
+ version "20.4.3"
1062
+ resolved "https://registry.yarnpkg.com/@commitlint/types/-/types-20.4.3.tgz#aa3fb9732dd42dea590d165214631ebc7b07eb59"
1063
+ integrity sha512-51OWa1Gi6ODOasPmfJPq6js4pZoomima4XLZZCrkldaH2V5Nb3bVhNXPeT6XV0gubbainSpTw4zi68NqAeCNCg==
1064
1064
  dependencies:
1065
- conventional-commits-parser "^6.2.1"
1065
+ conventional-commits-parser "^6.3.0"
1066
1066
  picocolors "^1.1.1"
1067
1067
 
1068
1068
  "@cspotcode/source-map-support@^0.8.0":
@@ -1538,10 +1538,10 @@
1538
1538
  wordwrap "^1.0.0"
1539
1539
  wrap-ansi "^7.0.0"
1540
1540
 
1541
- "@oclif/plugin-command-snapshot@^5.3.10":
1542
- version "5.3.10"
1543
- resolved "https://registry.yarnpkg.com/@oclif/plugin-command-snapshot/-/plugin-command-snapshot-5.3.10.tgz#7146eccb3ec4f66fb27bf5a362add7d0697ba2b1"
1544
- integrity sha512-pGKxLQzE3NYsl63WmwiCndrskKFsQXZ8P5trvycqGHJ1YmffL4xPpfiDcMtiKuK0MX2vSnTkQ0k7n5kchmx+vA==
1541
+ "@oclif/plugin-command-snapshot@^5.3.11":
1542
+ version "5.3.11"
1543
+ resolved "https://registry.yarnpkg.com/@oclif/plugin-command-snapshot/-/plugin-command-snapshot-5.3.11.tgz#d844efb206856cd7475b763e5c815301ced421a8"
1544
+ integrity sha512-GlSVuVs7wwx0Yoa4U6MXTTJIjWhXmXx5Mzh8zPebjzHARNKTeozQMxMnWCW7p0b6QAYl6XUnTng/usQ8GAxtVA==
1545
1545
  dependencies:
1546
1546
  "@oclif/core" "^4"
1547
1547
  ansis "^3.17.0"
@@ -1823,6 +1823,11 @@
1823
1823
  resolved "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz"
1824
1824
  integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==
1825
1825
 
1826
+ "@simple-libs/stream-utils@^1.2.0":
1827
+ version "1.2.0"
1828
+ resolved "https://registry.yarnpkg.com/@simple-libs/stream-utils/-/stream-utils-1.2.0.tgz#5af724b826f1ab4d7f2826d31d3efccec124102b"
1829
+ integrity sha512-KxXvfapcixpz6rVEB6HPjOUZT22yN6v0vI0urQSk1L8MlEWPDFCZkhw2xmkyoTGYeFw7tWTZd7e3lVzRZRN/EA==
1830
+
1826
1831
  "@sindresorhus/is@^4":
1827
1832
  version "4.6.0"
1828
1833
  resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz"
@@ -3505,10 +3510,10 @@ conventional-changelog-angular@^6.0.0:
3505
3510
  dependencies:
3506
3511
  compare-func "^2.0.0"
3507
3512
 
3508
- conventional-changelog-angular@^8.1.0:
3509
- version "8.1.0"
3510
- resolved "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-8.1.0.tgz"
3511
- integrity sha512-GGf2Nipn1RUCAktxuVauVr1e3r8QrLP/B0lEUsFktmGqc3ddbQkhoJZHJctVU829U1c6mTSWftrVOCHaL85Q3w==
3513
+ conventional-changelog-angular@^8.2.0:
3514
+ version "8.3.0"
3515
+ resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-8.3.0.tgz#e344def5f3d3c4f3242dea3c4e12c402e0d6832c"
3516
+ integrity sha512-DOuBwYSqWzfwuRByY9O4oOIvDlkUCTDzfbOgcSbkY+imXXj+4tmrEFao3K+FxemClYfYnZzsvudbwrhje9VHDA==
3512
3517
  dependencies:
3513
3518
  compare-func "^2.0.0"
3514
3519
 
@@ -3529,11 +3534,12 @@ conventional-commits-parser@^4.0.0:
3529
3534
  meow "^8.1.2"
3530
3535
  split2 "^3.2.2"
3531
3536
 
3532
- conventional-commits-parser@^6.2.1:
3533
- version "6.2.1"
3534
- resolved "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.2.1.tgz"
3535
- integrity sha512-20pyHgnO40rvfI0NGF/xiEoFMkXDtkF8FwHvk5BokoFoCuTQRI8vrNCNFWUOfuolKJMm1tPCHc8GgYEtr1XRNA==
3537
+ conventional-commits-parser@^6.3.0:
3538
+ version "6.3.0"
3539
+ resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-6.3.0.tgz#fc170753ca66f31940a438539bf48e4406ac54b5"
3540
+ integrity sha512-RfOq/Cqy9xV9bOA8N+ZH6DlrDR+5S3Mi0B5kACEjESpE+AviIpAptx9a9cFpWCCvgRtWT+0BbUw+e1BZfts9jg==
3536
3541
  dependencies:
3542
+ "@simple-libs/stream-utils" "^1.2.0"
3537
3543
  meow "^13.0.0"
3538
3544
 
3539
3545
  convert-source-map@^1.7.0:
@@ -3585,10 +3591,10 @@ cosmiconfig@^8.0.0, cosmiconfig@^8.3.6:
3585
3591
  parse-json "^5.2.0"
3586
3592
  path-type "^4.0.0"
3587
3593
 
3588
- cosmiconfig@^9.0.0:
3589
- version "9.0.0"
3590
- resolved "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.0.tgz"
3591
- integrity sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==
3594
+ cosmiconfig@^9.0.1:
3595
+ version "9.0.1"
3596
+ resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-9.0.1.tgz#df110631a8547b5d1a98915271986f06e3011379"
3597
+ integrity sha512-hr4ihw+DBqcvrsEDioRO31Z17x71pUYoNe/4h6Z0wB72p7MU7/9gH8Q3s12NFhHPfYBBOV3qyfUxmr/Yn3shnQ==
3592
3598
  dependencies:
3593
3599
  env-paths "^2.2.1"
3594
3600
  import-fresh "^3.3.0"
@@ -6227,13 +6233,6 @@ minimatch@^10.2.4:
6227
6233
  dependencies:
6228
6234
  brace-expansion "^5.0.2"
6229
6235
 
6230
- minimatch@^10.2.4:
6231
- version "10.2.4"
6232
- resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.2.4.tgz#465b3accbd0218b8281f5301e27cedc697f96fde"
6233
- integrity sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==
6234
- dependencies:
6235
- brace-expansion "^5.0.2"
6236
-
6237
6236
  minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
6238
6237
  version "3.1.2"
6239
6238
  resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz"
@@ -281,14 +281,12 @@
281
281
  "instrument:aura:logging:rflib"
282
282
  ]
283
283
  },
284
- "rflib:logging:flow:instrument": {
284
+ "rflib:logging:lwc:instrument": {
285
285
  "aliases": [],
286
286
  "args": {},
287
- "description": "Automatically adds RFLIB logging statements to Salesforce Flows to provide enhanced tracking and debugging capabilities. Works with both standard Flows and Auto-Launched Flows. Instruments flow invocations and decision paths with logging actions. Also sets the CanvasMode to AUTO_LAYOUT_CANVAS for better flow visualization while preserving the original processType.",
287
+ "description": "Analyzes Lightning Web Component JavaScript files and adds RFLIB logging statements for:\n- Method entry logging with parameter values\n- Error logging in try-catch blocks\n- Error logging in Promise catch handlers\n- Condition logging in if/else blocks\n- Adds logger import if not present\n- Adds logger initialization if not present\n- Replaces console.log and similar method invocations\n- Formats modified files using Prettier (optional)",
288
288
  "examples": [
289
- "<%= config.bin %> <%= command.id %> --sourcepath force-app",
290
- "<%= config.bin %> <%= command.id %> --sourcepath force-app --dryrun",
291
- "<%= config.bin %> <%= command.id %> --sourcepath force-app --skip-instrumented"
289
+ "- Add logging to all LWC files:\n$ sf rflib logging lwc instrument --sourcepath force-app/main/default/lwc\n\n- Preview changes:\n$ sf rflib logging lwc instrument --sourcepath force-app/main/default/lwc --dryrun\n\n- Add logging and format code:\n$ sf rflib logging lwc instrument --sourcepath force-app/main/default/lwc --prettier\n\n- Process specific component:\n$ sf rflib logging lwc instrument --sourcepath force-app/main/default/lwc/myComponent"
292
290
  ],
293
291
  "flags": {
294
292
  "json": {
@@ -308,24 +306,39 @@
308
306
  },
309
307
  "sourcepath": {
310
308
  "char": "s",
311
- "description": "Path to the source directory containing Flow files that should be instrumented with RFLIB logging statements. Processes .flow-meta.xml files with processType=\"Flow\" or \"AutoLaunchedFlow\".",
309
+ "description": "Path to the source directory containing Lightning Web Component JavaScript files that should be instrumented with RFLIB logging statements. Aura component files are automatically excluded. The command will:\n- Process all .js files in the directory and subdirectories\n- Skip files in 'aura' directories\n- Add import statement: import { createLogger } from 'c/rflibLogger'\n- Add logger initialization: const logger = createLogger('ComponentName')",
312
310
  "name": "sourcepath",
313
311
  "required": true,
314
- "summary": "Directory containing Flow files to instrument with logging.",
312
+ "summary": "Directory containing LWC JavaScript files to instrument with logging.",
315
313
  "hasDynamicHelp": false,
316
314
  "multiple": false,
317
315
  "type": "option"
318
316
  },
319
317
  "dryrun": {
320
318
  "char": "d",
321
- "description": "When enabled, shows which files would be modified without making actual changes. Useful for reviewing the impact before applying changes.",
319
+ "description": "When enabled, shows which files would be modified without making actual changes. Useful for reviewing the impact before applying changes. Shows:\n- Files that would be modified\n- Number of processed files\n- Number of modified files\n- Number of formatted files",
322
320
  "name": "dryrun",
323
321
  "summary": "Preview changes without modifying files.",
324
322
  "allowNo": false,
325
323
  "type": "boolean"
326
324
  },
325
+ "prettier": {
326
+ "char": "p",
327
+ "description": "When enabled, formats the modified JavaScript files using Prettier after adding logging statements. Maintains consistent code style with:\n- 120 character line width\n- 4 space indentation\n- Single quotes for strings\n- No tabs",
328
+ "name": "prettier",
329
+ "summary": "Format modified files using Prettier.",
330
+ "allowNo": false,
331
+ "type": "boolean"
332
+ },
333
+ "no-if": {
334
+ "description": "When provided, the command will not add log statements inside of `if` and `else` blocks.",
335
+ "name": "no-if",
336
+ "summary": "Exclude the instrumentation of if-else statements.",
337
+ "allowNo": false,
338
+ "type": "boolean"
339
+ },
327
340
  "skip-instrumented": {
328
- "description": "When provided, the command will not add log statements to any Flows that already contain RFLIB logging actions.",
341
+ "description": "When provided, the command will not add log statements to any Apex class that contains the `rflib` import statement.",
329
342
  "name": "skip-instrumented",
330
343
  "summary": "Skips any files where a logger is already present.",
331
344
  "allowNo": false,
@@ -341,7 +354,7 @@
341
354
  },
342
355
  "exclude": {
343
356
  "char": "e",
344
- "description": "Exclude specific files or directories that match the provided glob pattern. For example, use --exclude \"**/Test_*.flow-meta.xml\" to skip certain flows.",
357
+ "description": "Exclude specific files or directories that match the provided glob pattern. For example, use --exclude \"**/Generated_*.js\" to skip auto-generated components.",
345
358
  "name": "exclude",
346
359
  "summary": "Exclude files or directories from instrumentation based on a glob pattern.",
347
360
  "hasDynamicHelp": false,
@@ -361,12 +374,12 @@
361
374
  },
362
375
  "hasDynamicHelp": false,
363
376
  "hiddenAliases": [],
364
- "id": "rflib:logging:flow:instrument",
377
+ "id": "rflib:logging:lwc:instrument",
365
378
  "pluginAlias": "rflib-plugin",
366
379
  "pluginName": "rflib-plugin",
367
380
  "pluginType": "core",
368
381
  "strict": true,
369
- "summary": "Adds RFLIB logging statements to Salesforce Flows.",
382
+ "summary": "Instrument Lightning Web Components with RFLIB logging statements automatically.",
370
383
  "enableJsonFlag": true,
371
384
  "isESM": true,
372
385
  "relativePath": [
@@ -374,43 +387,45 @@
374
387
  "commands",
375
388
  "rflib",
376
389
  "logging",
377
- "flow",
390
+ "lwc",
378
391
  "instrument.js"
379
392
  ],
380
393
  "aliasPermutations": [],
381
394
  "permutations": [
382
- "rflib:logging:flow:instrument",
383
- "logging:rflib:flow:instrument",
384
- "logging:flow:rflib:instrument",
385
- "logging:flow:instrument:rflib",
386
- "rflib:flow:logging:instrument",
387
- "flow:rflib:logging:instrument",
388
- "flow:logging:rflib:instrument",
389
- "flow:logging:instrument:rflib",
390
- "rflib:flow:instrument:logging",
391
- "flow:rflib:instrument:logging",
392
- "flow:instrument:rflib:logging",
393
- "flow:instrument:logging:rflib",
394
- "rflib:logging:instrument:flow",
395
- "logging:rflib:instrument:flow",
396
- "logging:instrument:rflib:flow",
397
- "logging:instrument:flow:rflib",
398
- "rflib:instrument:logging:flow",
399
- "instrument:rflib:logging:flow",
400
- "instrument:logging:rflib:flow",
401
- "instrument:logging:flow:rflib",
402
- "rflib:instrument:flow:logging",
403
- "instrument:rflib:flow:logging",
404
- "instrument:flow:rflib:logging",
405
- "instrument:flow:logging:rflib"
395
+ "rflib:logging:lwc:instrument",
396
+ "logging:rflib:lwc:instrument",
397
+ "logging:lwc:rflib:instrument",
398
+ "logging:lwc:instrument:rflib",
399
+ "rflib:lwc:logging:instrument",
400
+ "lwc:rflib:logging:instrument",
401
+ "lwc:logging:rflib:instrument",
402
+ "lwc:logging:instrument:rflib",
403
+ "rflib:lwc:instrument:logging",
404
+ "lwc:rflib:instrument:logging",
405
+ "lwc:instrument:rflib:logging",
406
+ "lwc:instrument:logging:rflib",
407
+ "rflib:logging:instrument:lwc",
408
+ "logging:rflib:instrument:lwc",
409
+ "logging:instrument:rflib:lwc",
410
+ "logging:instrument:lwc:rflib",
411
+ "rflib:instrument:logging:lwc",
412
+ "instrument:rflib:logging:lwc",
413
+ "instrument:logging:rflib:lwc",
414
+ "instrument:logging:lwc:rflib",
415
+ "rflib:instrument:lwc:logging",
416
+ "instrument:rflib:lwc:logging",
417
+ "instrument:lwc:rflib:logging",
418
+ "instrument:lwc:logging:rflib"
406
419
  ]
407
420
  },
408
- "rflib:logging:lwc:instrument": {
421
+ "rflib:logging:flow:instrument": {
409
422
  "aliases": [],
410
423
  "args": {},
411
- "description": "Analyzes Lightning Web Component JavaScript files and adds RFLIB logging statements for:\n- Method entry logging with parameter values\n- Error logging in try-catch blocks\n- Error logging in Promise catch handlers\n- Condition logging in if/else blocks\n- Adds logger import if not present\n- Adds logger initialization if not present\n- Replaces console.log and similar method invocations\n- Formats modified files using Prettier (optional)",
424
+ "description": "Automatically adds RFLIB logging statements to Salesforce Flows to provide enhanced tracking and debugging capabilities. Works with both standard Flows and Auto-Launched Flows. Instruments flow invocations and decision paths with logging actions. Also sets the CanvasMode to AUTO_LAYOUT_CANVAS for better flow visualization while preserving the original processType.",
412
425
  "examples": [
413
- "- Add logging to all LWC files:\n$ sf rflib logging lwc instrument --sourcepath force-app/main/default/lwc\n\n- Preview changes:\n$ sf rflib logging lwc instrument --sourcepath force-app/main/default/lwc --dryrun\n\n- Add logging and format code:\n$ sf rflib logging lwc instrument --sourcepath force-app/main/default/lwc --prettier\n\n- Process specific component:\n$ sf rflib logging lwc instrument --sourcepath force-app/main/default/lwc/myComponent"
426
+ "<%= config.bin %> <%= command.id %> --sourcepath force-app",
427
+ "<%= config.bin %> <%= command.id %> --sourcepath force-app --dryrun",
428
+ "<%= config.bin %> <%= command.id %> --sourcepath force-app --skip-instrumented"
414
429
  ],
415
430
  "flags": {
416
431
  "json": {
@@ -430,39 +445,24 @@
430
445
  },
431
446
  "sourcepath": {
432
447
  "char": "s",
433
- "description": "Path to the source directory containing Lightning Web Component JavaScript files that should be instrumented with RFLIB logging statements. Aura component files are automatically excluded. The command will:\n- Process all .js files in the directory and subdirectories\n- Skip files in 'aura' directories\n- Add import statement: import { createLogger } from 'c/rflibLogger'\n- Add logger initialization: const logger = createLogger('ComponentName')",
448
+ "description": "Path to the source directory containing Flow files that should be instrumented with RFLIB logging statements. Processes .flow-meta.xml files with processType=\"Flow\" or \"AutoLaunchedFlow\".",
434
449
  "name": "sourcepath",
435
450
  "required": true,
436
- "summary": "Directory containing LWC JavaScript files to instrument with logging.",
451
+ "summary": "Directory containing Flow files to instrument with logging.",
437
452
  "hasDynamicHelp": false,
438
453
  "multiple": false,
439
454
  "type": "option"
440
455
  },
441
456
  "dryrun": {
442
457
  "char": "d",
443
- "description": "When enabled, shows which files would be modified without making actual changes. Useful for reviewing the impact before applying changes. Shows:\n- Files that would be modified\n- Number of processed files\n- Number of modified files\n- Number of formatted files",
458
+ "description": "When enabled, shows which files would be modified without making actual changes. Useful for reviewing the impact before applying changes.",
444
459
  "name": "dryrun",
445
460
  "summary": "Preview changes without modifying files.",
446
461
  "allowNo": false,
447
462
  "type": "boolean"
448
463
  },
449
- "prettier": {
450
- "char": "p",
451
- "description": "When enabled, formats the modified JavaScript files using Prettier after adding logging statements. Maintains consistent code style with:\n- 120 character line width\n- 4 space indentation\n- Single quotes for strings\n- No tabs",
452
- "name": "prettier",
453
- "summary": "Format modified files using Prettier.",
454
- "allowNo": false,
455
- "type": "boolean"
456
- },
457
- "no-if": {
458
- "description": "When provided, the command will not add log statements inside of `if` and `else` blocks.",
459
- "name": "no-if",
460
- "summary": "Exclude the instrumentation of if-else statements.",
461
- "allowNo": false,
462
- "type": "boolean"
463
- },
464
464
  "skip-instrumented": {
465
- "description": "When provided, the command will not add log statements to any Apex class that contains the `rflib` import statement.",
465
+ "description": "When provided, the command will not add log statements to any Flows that already contain RFLIB logging actions.",
466
466
  "name": "skip-instrumented",
467
467
  "summary": "Skips any files where a logger is already present.",
468
468
  "allowNo": false,
@@ -478,7 +478,7 @@
478
478
  },
479
479
  "exclude": {
480
480
  "char": "e",
481
- "description": "Exclude specific files or directories that match the provided glob pattern. For example, use --exclude \"**/Generated_*.js\" to skip auto-generated components.",
481
+ "description": "Exclude specific files or directories that match the provided glob pattern. For example, use --exclude \"**/Test_*.flow-meta.xml\" to skip certain flows.",
482
482
  "name": "exclude",
483
483
  "summary": "Exclude files or directories from instrumentation based on a glob pattern.",
484
484
  "hasDynamicHelp": false,
@@ -498,12 +498,12 @@
498
498
  },
499
499
  "hasDynamicHelp": false,
500
500
  "hiddenAliases": [],
501
- "id": "rflib:logging:lwc:instrument",
501
+ "id": "rflib:logging:flow:instrument",
502
502
  "pluginAlias": "rflib-plugin",
503
503
  "pluginName": "rflib-plugin",
504
504
  "pluginType": "core",
505
505
  "strict": true,
506
- "summary": "Instrument Lightning Web Components with RFLIB logging statements automatically.",
506
+ "summary": "Adds RFLIB logging statements to Salesforce Flows.",
507
507
  "enableJsonFlag": true,
508
508
  "isESM": true,
509
509
  "relativePath": [
@@ -511,37 +511,37 @@
511
511
  "commands",
512
512
  "rflib",
513
513
  "logging",
514
- "lwc",
514
+ "flow",
515
515
  "instrument.js"
516
516
  ],
517
517
  "aliasPermutations": [],
518
518
  "permutations": [
519
- "rflib:logging:lwc:instrument",
520
- "logging:rflib:lwc:instrument",
521
- "logging:lwc:rflib:instrument",
522
- "logging:lwc:instrument:rflib",
523
- "rflib:lwc:logging:instrument",
524
- "lwc:rflib:logging:instrument",
525
- "lwc:logging:rflib:instrument",
526
- "lwc:logging:instrument:rflib",
527
- "rflib:lwc:instrument:logging",
528
- "lwc:rflib:instrument:logging",
529
- "lwc:instrument:rflib:logging",
530
- "lwc:instrument:logging:rflib",
531
- "rflib:logging:instrument:lwc",
532
- "logging:rflib:instrument:lwc",
533
- "logging:instrument:rflib:lwc",
534
- "logging:instrument:lwc:rflib",
535
- "rflib:instrument:logging:lwc",
536
- "instrument:rflib:logging:lwc",
537
- "instrument:logging:rflib:lwc",
538
- "instrument:logging:lwc:rflib",
539
- "rflib:instrument:lwc:logging",
540
- "instrument:rflib:lwc:logging",
541
- "instrument:lwc:rflib:logging",
542
- "instrument:lwc:logging:rflib"
519
+ "rflib:logging:flow:instrument",
520
+ "logging:rflib:flow:instrument",
521
+ "logging:flow:rflib:instrument",
522
+ "logging:flow:instrument:rflib",
523
+ "rflib:flow:logging:instrument",
524
+ "flow:rflib:logging:instrument",
525
+ "flow:logging:rflib:instrument",
526
+ "flow:logging:instrument:rflib",
527
+ "rflib:flow:instrument:logging",
528
+ "flow:rflib:instrument:logging",
529
+ "flow:instrument:rflib:logging",
530
+ "flow:instrument:logging:rflib",
531
+ "rflib:logging:instrument:flow",
532
+ "logging:rflib:instrument:flow",
533
+ "logging:instrument:rflib:flow",
534
+ "logging:instrument:flow:rflib",
535
+ "rflib:instrument:logging:flow",
536
+ "instrument:rflib:logging:flow",
537
+ "instrument:logging:rflib:flow",
538
+ "instrument:logging:flow:rflib",
539
+ "rflib:instrument:flow:logging",
540
+ "instrument:rflib:flow:logging",
541
+ "instrument:flow:rflib:logging",
542
+ "instrument:flow:logging:rflib"
543
543
  ]
544
544
  }
545
545
  },
546
- "version": "0.17.1"
546
+ "version": "0.17.2"
547
547
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rflib-plugin",
3
3
  "description": "Utility commands to help with the adoption of the RFLIB open-source library for Salesforce.",
4
- "version": "0.17.1",
4
+ "version": "0.17.2",
5
5
  "dependencies": {
6
6
  "@oclif/core": "^4.8.0",
7
7
  "@salesforce/core": "^8.26.3",
@@ -14,11 +14,11 @@
14
14
  "xml2js": "^0.6.2"
15
15
  },
16
16
  "devDependencies": {
17
- "@commitlint/cli": "^20.4.1",
17
+ "@commitlint/cli": "^20.4.3",
18
18
  "@eslint/eslintrc": "^2.1.4",
19
19
  "@eslint/js": "^8.57.1",
20
20
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
21
- "@oclif/plugin-command-snapshot": "^5.3.10",
21
+ "@oclif/plugin-command-snapshot": "^5.3.11",
22
22
  "@salesforce/cli-plugins-testkit": "^5.3.41",
23
23
  "@salesforce/dev-scripts": "^11.0.4",
24
24
  "@types/minimatch": "^5.1.2",
@@ -97,6 +97,7 @@
97
97
  "postpack": "sf-clean --ignore-signing-artifacts",
98
98
  "prepack": "sf-prepack",
99
99
  "test": "wireit",
100
+ "test:e2e": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/e2e-test.ts",
100
101
  "test:nuts": "wireit",
101
102
  "test:only": "wireit",
102
103
  "version": "oclif readme",