rflib-plugin 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/rflib/logging/apex/instrument.d.ts +2 -2
- package/lib/commands/rflib/logging/apex/instrument.js +22 -11
- package/lib/commands/rflib/logging/apex/instrument.js.map +1 -1
- package/lib/commands/rflib/logging/aura/instrument.d.ts +2 -2
- package/lib/commands/rflib/logging/aura/instrument.js +21 -10
- package/lib/commands/rflib/logging/aura/instrument.js.map +1 -1
- package/lib/commands/rflib/logging/lwc/instrument.d.ts +2 -2
- package/lib/commands/rflib/logging/lwc/instrument.js +9 -3
- package/lib/commands/rflib/logging/lwc/instrument.js.map +1 -1
- package/messages/rflib.logging.aura.instrument.md +1 -0
- package/messages/rflib.logging.lwc.instrument.md +1 -0
- package/oclif.lock +570 -913
- package/oclif.manifest.json +3 -3
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/lwc/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;AAwBrC,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;AAEvF,MAAM,yBAAyB;IACrB,MAAM,CAAU,YAAY,GAAG,+DAA+D,CAAC;IAC/F,MAAM,CAAU,YAAY,GAAG,yDAAyD,CA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CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,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;wBAC5G,MAAM,EAAE,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,wBAAwB,aAAa,EAAE,EAAE,KAAK,CAAC,CAAC;YAClE,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\ninterface InstrumentationOptions {\n readonly prettier: boolean;\n readonly noIf: boolean;\n readonly skipInstrumented: boolean;\n}\n\ninterface LoggerInfo {\n readonly exists: boolean;\n readonly variableName: string;\n}\n\ninterface IfCondition {\n readonly condition: string;\n readonly position: number;\n}\n\nexport interface RflibLoggingLwcInstrumentResult {\n processedFiles: number;\n modifiedFiles: number;\n formattedFiles: number;\n}\n\nMessages.importMessagesDirectoryFromMetaUrl(import.meta.url);\nconst messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.lwc.instrument');\n\nclass LwcInstrumentationService {\n private static readonly IMPORT_REGEX = /import\\s*{\\s*createLogger\\s*}\\s*from\\s*['\"]c\\/rflibLogger['\"]/;\n private static readonly LOGGER_REGEX = /const\\s+(\\w+)\\s*=\\s*createLogger\\s*\\(['\"]([\\w-]+)['\"]\\)/;\n private static readonly METHOD_REGEX = /(?:async\\s+)?(?!(?:if|switch|case|while|for|catch)\\b)(\\b\\w+)\\s*\\((.*?)\\)\\s*{/g;\n private static readonly EXPORT_DEFAULT_REGEX = /export\\s+default\\s+class\\s+(\\w+)/;\n private static readonly IF_STATEMENT_REGEX = /if\\s*\\((.*?)\\)\\s*(?:{([^]*?(?:(?<!{){(?:[^]*?)}(?!})[^]*?)*)}|([^{].*?)(?=\\s*(?:;|$));)/g;\n private static readonly ELSE_REGEX = /}\\s*else(?!\\s+if\\b)\\s*(?:{((?:[^{}]|{(?:[^{}]|{[^{}]*})*})*)}|([^{].*?)(?=\\n|;|$))/g;\n private static readonly PROMISE_CHAIN_REGEX = /\\.(then|catch|finally)\\s*\\(\\s*(?:async\\s+)?(?:\\(?([^)]*)\\)?)?\\s*=>\\s*(?:\\{((?:[^{}]|`[^`]*`)*?)\\}|([^{;]*?(?:\\.[^{;]*?)*(?:\\([^)]*\\))?)(?=\\s*(?:\\)\\)|\\.|\\))))/g;\n private static readonly TRY_CATCH_BLOCK_REGEX = /try\\s*{[\\s\\S]*?}\\s*catch\\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 };\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.IMPORT_REGEX.test(content);\n }\n\n public static detectLogger(content: string): LoggerInfo {\n const match = content.match(this.LOGGER_REGEX);\n return {\n exists: match !== null,\n variableName: match ? match[1] : 'logger',\n };\n }\n\n public static addImportAndLogger(content: string, componentName: string): string {\n let modified = content;\n\n if (!this.IMPORT_REGEX.test(content)) {\n modified = `import { createLogger } from 'c/rflibLogger';\\n${modified}`;\n }\n\n const { exists, variableName } = this.detectLogger(content);\n if (!exists) {\n const exportMatch = content.match(this.EXPORT_DEFAULT_REGEX);\n const className = exportMatch ? exportMatch[1] : componentName;\n const loggerDeclaration = `\\nconst ${variableName} = createLogger('${className}');\\n`;\n modified = modified.replace(this.EXPORT_DEFAULT_REGEX, `${loggerDeclaration}$&`);\n }\n\n return modified;\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({ 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 ?? 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 processMethodLogging(content: string, loggerName: string, options: InstrumentationOptions): string {\n let modified = content.replace(\n this.METHOD_REGEX,\n (match: string, methodName: string, args: string) => {\n const parameters = args\n .split(',')\n .map((p) => p.trim())\n .filter((p) => p);\n const placeholders = parameters.map((_, i) => `{${i}}`).join(', ');\n const logArgs = parameters.length > 0 ? `, ${parameters.join(', ')}` : '';\n\n return `${match}\\n ${loggerName}.info('${methodName}(${placeholders})'${logArgs});`;\n }\n );\n\n if (!options.noIf) {\n modified = this.processIfStatements(modified, loggerName);\n }\n\n return modified;\n }\n\n public static processTryCatchBlocks(content: string, loggerName: string): string {\n return content.replace(\n this.TRY_CATCH_BLOCK_REGEX,\n (match: string, exceptionVar: string, offset: number) => {\n const methodName = this.findEnclosingMethod(content, offset);\n const errorVar = exceptionVar.trim().split(' ')[0] || 'error';\n\n return match.replace(\n /catch\\s*\\(([^)]*)\\)\\s*{/,\n `catch(${exceptionVar}) {\n ${loggerName}.error('An error occurred in function ${methodName}()', ${errorVar});`\n );\n }\n );\n }\n\n public static processPromiseChains(content: string, loggerName: string): string {\n return content.replace(\n this.PROMISE_CHAIN_REGEX,\n (match, type, param, blockBody, singleLineBody, offset: number) => {\n const methodName = this.findEnclosingMethod(content, offset);\n const paramName = typeof param === 'string' ? param.trim() : type === 'then' ? 'result' : 'error';\n const indentation = match.match(/\\n\\s*/)?.[0] ?? '\\n ';\n\n let logStatement: string;\n switch (type) {\n case 'then':\n logStatement = `${loggerName}.info('${methodName}() promise resolved. Result={0}', ${paramName});`;\n break;\n case 'catch':\n logStatement = `${loggerName}.error('An error occurred in function ${methodName}()', ${paramName});`;\n break;\n case 'finally':\n logStatement = `${loggerName}.info('${methodName}() promise chain completed');`;\n break;\n default:\n logStatement = '';\n }\n\n if (singleLineBody) {\n const trimmedBody = (singleLineBody as string).trim();\n const adjustedBody = trimmedBody.split(')').length > trimmedBody.split('(').length\n ? trimmedBody.slice(0, -1)\n : trimmedBody;\n\n return `.${type}((${paramName}) => {\n ${logStatement}\n return ${adjustedBody};\n }`;\n }\n\n if (blockBody) {\n return `.${type}((${paramName}) => {${indentation}${logStatement}${indentation}${blockBody}}`;\n }\n\n return match;\n }\n );\n }\n\n private static findEnclosingMethod(content: string, position: number): string {\n const beforeCatch = content.substring(0, position);\n const methods = [...beforeCatch.matchAll(this.METHOD_REGEX)].reverse();\n const closestMethod = methods[0];\n return closestMethod ? closestMethod[1] : 'unknown';\n }\n}\n\nexport default class RflibLoggingLwcInstrument extends SfCommand<RflibLoggingLwcInstrumentResult> {\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: RflibLoggingLwcInstrumentResult = {\n processedFiles: 0,\n modifiedFiles: 0,\n formattedFiles: 0,\n };\n\n public async run(): Promise<RflibLoggingLwcInstrumentResult> {\n this.logger = await Logger.child(this.ctor.name);\n const { flags } = await this.parse(RflibLoggingLwcInstrument);\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 LWC components in ${flags.sourcepath}...`);\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 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 (\n file.endsWith('.js') &&\n !path.dirname(filePath).includes('aura') &&\n !path.dirname(filePath).includes('__tests__')\n ) {\n await this.instrumentLwcFile(filePath, isDryRun, instrumentationOpts);\n }\n }\n }\n\n private async instrumentLwcFile(\n filePath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions\n ): Promise<void> {\n const componentName = path.basename(path.dirname(filePath));\n this.logger.debug(`Processing LWC: ${componentName}`);\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 && LwcInstrumentationService.isInstrumented(content)) {\n this.logger.info(`Skipping instrumented component: ${componentName}`);\n return;\n }\n\n const { variableName } = LwcInstrumentationService.detectLogger(content);\n content = LwcInstrumentationService.addImportAndLogger(content, componentName);\n content = LwcInstrumentationService.processMethodLogging(content, variableName, instrumentationOpts);\n content = LwcInstrumentationService.processTryCatchBlocks(content, variableName);\n content = LwcInstrumentationService.processPromiseChains(content, variableName);\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n if (!isDryRun) {\n try {\n const finalContent = instrumentationOpts.prettier\n ? await LwcInstrumentationService.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 LWC ${componentName}`, error);\n throw error;\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/lwc/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;AAwBrC,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;AAEvF,MAAM,yBAAyB;IACrB,MAAM,CAAU,YAAY,GAAG,+DAA+D,CAAC;IAC/F,MAAM,CAAU,YAAY,GAAG,yDAAyD,CAAC;IACzF,MAAM,CAAU,YAAY,GAClC,+EAA+E,CAAC;IAC1E,MAAM,CAAU,oBAAoB,GAAG,kCAAkC,CAAC;IAC1E,MAAM,CAAU,kBAAkB,GACxC,0FAA0F,CAAC;IACrF,MAAM,CAAU,UAAU,GAChC,qFAAqF,CAAC;IAChF,MAAM,CAAU,mBAAmB,GACzC,gKAAgK,CAAC;IAC3J,MAAM,CAAU,qBAAqB,GAAG,6CAA6C,CAAC;IACtF,MAAM,CAAU,iBAAiB,GAAG,gEAAgE,CAAC;IAErG,MAAM,CAAU,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AAM,CAAC,IAAI,CAAC,2BAA2B,QAAQ,EAAE,CAAC,CAAC;wBAC1D,CAAC;6BAAM,CAAC;4BACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAC;wBAC5C,CAAC;oBACH,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,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;wBAC5G,MAAM,EAAE,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,wBAAwB,aAAa,EAAE,EAAE,KAAK,CAAC,CAAC;YAClE,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 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 IfCondition = {\n readonly condition: string;\n readonly position: number;\n}\n\nexport type RflibLoggingLwcInstrumentResult = {\n processedFiles: number;\n modifiedFiles: number;\n formattedFiles: number;\n}\n\nMessages.importMessagesDirectoryFromMetaUrl(import.meta.url);\nconst messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.lwc.instrument');\n\nclass LwcInstrumentationService {\n private static readonly IMPORT_REGEX = /import\\s*{\\s*createLogger\\s*}\\s*from\\s*['\"]c\\/rflibLogger['\"]/;\n private static readonly LOGGER_REGEX = /const\\s+(\\w+)\\s*=\\s*createLogger\\s*\\(['\"]([\\w-]+)['\"]\\)/;\n private static readonly METHOD_REGEX =\n /(?:async\\s+)?(?!(?:if|switch|case|while|for|catch)\\b)(\\b\\w+)\\s*\\((.*?)\\)\\s*{/g;\n private static readonly EXPORT_DEFAULT_REGEX = /export\\s+default\\s+class\\s+(\\w+)/;\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 PROMISE_CHAIN_REGEX =\n /\\.(then|catch|finally)\\s*\\(\\s*(?:async\\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 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 };\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.IMPORT_REGEX.test(content);\n }\n\n public static detectLogger(content: string): LoggerInfo {\n const match = content.match(this.LOGGER_REGEX);\n return {\n exists: match !== null,\n variableName: match ? match[1] : 'logger',\n };\n }\n\n public static addImportAndLogger(content: string, componentName: string): string {\n let modified = content;\n\n if (!this.IMPORT_REGEX.test(content)) {\n modified = `import { createLogger } from 'c/rflibLogger';\\n${modified}`;\n }\n\n const { exists, variableName } = this.detectLogger(content);\n if (!exists) {\n const exportMatch = content.match(this.EXPORT_DEFAULT_REGEX);\n const className = exportMatch ? exportMatch[1] : componentName;\n const loggerDeclaration = `\\nconst ${variableName} = createLogger('${className}');\\n`;\n modified = modified.replace(this.EXPORT_DEFAULT_REGEX, `${loggerDeclaration}$&`);\n }\n\n return modified;\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({ 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 ?? 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 processMethodLogging(content: string, loggerName: string, options: InstrumentationOptions): string {\n let modified = content.replace(this.METHOD_REGEX, (match: string, methodName: string, args: string) => {\n const parameters = args\n .split(',')\n .map((p) => p.trim())\n .filter((p) => p);\n const placeholders = parameters.map((_, i) => `{${i}}`).join(', ');\n const logArgs = parameters.length > 0 ? `, ${parameters.join(', ')}` : '';\n\n return `${match}\\n ${loggerName}.info('${methodName}(${placeholders})'${logArgs});`;\n });\n\n if (!options.noIf) {\n modified = this.processIfStatements(modified, loggerName);\n }\n\n return modified;\n }\n\n public static processTryCatchBlocks(content: string, loggerName: string): string {\n return content.replace(this.TRY_CATCH_BLOCK_REGEX, (match: string, exceptionVar: string, offset: number) => {\n const methodName = this.findEnclosingMethod(content, offset);\n const errorVar = exceptionVar.trim().split(' ')[0] || 'error';\n\n return match.replace(\n /catch\\s*\\(([^)]*)\\)\\s*{/,\n `catch(${exceptionVar}) {\n ${loggerName}.error('An error occurred in function ${methodName}()', ${errorVar});`,\n );\n });\n }\n\n public static processPromiseChains(content: string, loggerName: string): string {\n return content.replace(\n this.PROMISE_CHAIN_REGEX,\n (match, type, param, blockBody, singleLineBody, offset: number) => {\n const methodName = this.findEnclosingMethod(content, offset);\n const paramName = typeof param === 'string' ? param.trim() : type === 'then' ? 'result' : 'error';\n const indentation = match.match(/\\n\\s*/)?.[0] ?? '\\n ';\n\n let logStatement: string;\n switch (type) {\n case 'then':\n logStatement = `${loggerName}.info('${methodName}() promise resolved. Result={0}', ${paramName});`;\n break;\n case 'catch':\n logStatement = `${loggerName}.error('An error occurred in function ${methodName}()', ${paramName});`;\n break;\n case 'finally':\n logStatement = `${loggerName}.info('${methodName}() promise chain completed');`;\n break;\n default:\n logStatement = '';\n }\n\n if (singleLineBody) {\n const trimmedBody = (singleLineBody as string).trim();\n const adjustedBody =\n trimmedBody.split(')').length > trimmedBody.split('(').length ? trimmedBody.slice(0, -1) : trimmedBody;\n\n return `.${type}((${paramName}) => {\n ${logStatement}\n return ${adjustedBody};\n }`;\n }\n\n if (blockBody) {\n return `.${type}((${paramName}) => {${indentation}${logStatement}${indentation}${blockBody}}`;\n }\n\n return match;\n },\n );\n }\n\n public 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 private static findEnclosingMethod(content: string, position: number): string {\n const beforeCatch = content.substring(0, position);\n const methods = [...beforeCatch.matchAll(this.METHOD_REGEX)].reverse();\n const closestMethod = methods[0];\n return closestMethod ? closestMethod[1] : 'unknown';\n }\n}\n\nexport default class RflibLoggingLwcInstrument extends SfCommand<RflibLoggingLwcInstrumentResult> {\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: RflibLoggingLwcInstrumentResult = {\n processedFiles: 0,\n modifiedFiles: 0,\n formattedFiles: 0,\n };\n\n public async run(): Promise<RflibLoggingLwcInstrumentResult> {\n this.logger = await Logger.child(this.ctor.name);\n const { flags } = await this.parse(RflibLoggingLwcInstrument);\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 LWC components in ${flags.sourcepath}...`);\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 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 (\n file.endsWith('.js') &&\n !path.dirname(filePath).includes('aura') &&\n !path.dirname(filePath).includes('__tests__')\n ) {\n await this.instrumentLwcFile(filePath, isDryRun, instrumentationOpts);\n }\n }\n }\n\n private async instrumentLwcFile(\n filePath: string,\n isDryRun: boolean,\n instrumentationOpts: InstrumentationOptions,\n ): Promise<void> {\n const componentName = path.basename(path.dirname(filePath));\n this.logger.debug(`Processing LWC: ${componentName}`);\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 && LwcInstrumentationService.isInstrumented(content)) {\n this.logger.info(`Skipping instrumented component: ${componentName}`);\n return;\n }\n\n const { variableName } = LwcInstrumentationService.detectLogger(content);\n content = LwcInstrumentationService.addImportAndLogger(content, componentName);\n content = LwcInstrumentationService.processMethodLogging(content, variableName, instrumentationOpts);\n content = LwcInstrumentationService.processTryCatchBlocks(content, variableName);\n content = LwcInstrumentationService.processPromiseChains(content, variableName);\n content = LwcInstrumentationService.processConsoleStatements(content, variableName);\n\n if (content !== originalContent) {\n this.stats.modifiedFiles++;\n if (!isDryRun) {\n try {\n const finalContent = instrumentationOpts.prettier\n ? await LwcInstrumentationService.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 LWC ${componentName}`, error);\n throw error;\n }\n }\n}\n"]}
|
|
@@ -9,6 +9,7 @@ Analyzes Aura Component files and adds RFLIB logging statements for:
|
|
|
9
9
|
- Error logging in try-catch blocks
|
|
10
10
|
- Error logging in Promise catch handlers
|
|
11
11
|
- Adds rflibLoggerCmp component if not present
|
|
12
|
+
- Replaces console.log and similar method invocations
|
|
12
13
|
- Formats modified files using Prettier (optional)
|
|
13
14
|
|
|
14
15
|
The command processes:
|
|
@@ -11,6 +11,7 @@ Analyzes Lightning Web Component JavaScript files and adds RFLIB logging stateme
|
|
|
11
11
|
- Condition logging in if/else blocks
|
|
12
12
|
- Adds logger import if not present
|
|
13
13
|
- Adds logger initialization if not present
|
|
14
|
+
- Replaces console.log and similar method invocations
|
|
14
15
|
- Formats modified files using Prettier (optional)
|
|
15
16
|
|
|
16
17
|
# flags.sourcepath.summary
|