rflib-plugin 0.3.3 → 0.4.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.
@@ -1,100 +1,67 @@
1
- /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
2
1
  /* eslint-disable no-await-in-loop */
3
- /* eslint-disable @typescript-eslint/quotes */
4
- /* eslint-disable sf-plugin/no-missing-messages */
5
2
  import * as fs from 'node:fs';
6
3
  import * as path from 'node:path';
7
4
  import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
8
5
  import { Messages, Logger } from '@salesforce/core';
9
- // eslint-disable-next-line import/no-extraneous-dependencies
10
6
  import * as prettier from 'prettier';
11
7
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
12
8
  const messages = Messages.loadMessages('rflib-plugin', 'rflib.logging.lwc.instrument');
13
- const importRegex = /import\s*{\s*createLogger\s*}\s*from\s*['"]c\/rflibLogger['"]/;
14
- const loggerRegex = /const\s+(\w+)\s*=\s*createLogger\s*\(['"]([\w-]+)['"]\)/;
15
- const methodRegex = /(?:async\s+)?(?!(?:if|switch|case|while|for|catch)\b)(\b\w+)\s*\((.*?)\)\s*{/g;
16
- const exportDefaultRegex = /export\s+default\s+class\s+(\w+)/;
17
- const ifStatementRegex = /if\s*\((.*?)\)\s*(?:{([^]*?(?:(?<!{){(?:[^]*?)}(?!})[^]*?)*)}|([^{].*?)(?=\s*(?:;|$));)/g;
18
- const elseRegex = /}\s*else(?!\s+if\b)\s*(?:{((?:[^{}]|{(?:[^{}]|{[^{}]*})*})*)}|([^{].*?)(?=\n|;|$))/g;
19
- const promiseChainRegex = /\.(then|catch|finally)\s*\(\s*(?:async\s+)?(?:\(?([^)]*)\)?)?\s*=>\s*(?:\{((?:[^{}]|`[^`]*`)*?)\}|([^{;]*(?:\([^)]*\))*)(?=(?:\)\))|\)|\.))/g;
20
- const tryCatchBlockRegex = /try\s*{[\s\S]*?}\s*catch\s*\(([^)]*)\)\s*{/g;
21
- export default class RflibLoggingLwcInstrument extends SfCommand {
22
- static summary = messages.getMessage('summary');
23
- static description = messages.getMessage('description');
24
- static examples = messages.getMessages('examples');
25
- static flags = {
26
- sourcepath: Flags.string({
27
- char: 's',
28
- required: true,
29
- summary: messages.getMessage('flags.sourcepath.summary'),
30
- description: messages.getMessage('flags.sourcepath.description'),
31
- }),
32
- dryrun: Flags.boolean({
33
- char: 'd',
34
- default: false,
35
- summary: messages.getMessage('flags.dryrun.summary'),
36
- description: messages.getMessage('flags.dryrun.description'),
37
- }),
38
- prettier: Flags.boolean({
39
- char: 'p',
40
- default: false,
41
- summary: messages.getMessage('flags.prettier.summary'),
42
- description: messages.getMessage('flags.prettier.description'),
43
- }),
44
- 'no-if': Flags.boolean({
45
- summary: messages.getMessage('flags.no-if.summary'),
46
- }),
47
- };
48
- logger;
49
- processedFiles = 0;
50
- modifiedFiles = 0;
51
- formattedFiles = 0;
52
- prettierConfig = {
9
+ class LwcInstrumentationService {
10
+ static IMPORT_REGEX = /import\s*{\s*createLogger\s*}\s*from\s*['"]c\/rflibLogger['"]/;
11
+ static LOGGER_REGEX = /const\s+(\w+)\s*=\s*createLogger\s*\(['"]([\w-]+)['"]\)/;
12
+ static METHOD_REGEX = /(?:async\s+)?(?!(?:if|switch|case|while|for|catch)\b)(\b\w+)\s*\((.*?)\)\s*{/g;
13
+ static EXPORT_DEFAULT_REGEX = /export\s+default\s+class\s+(\w+)/;
14
+ static IF_STATEMENT_REGEX = /if\s*\((.*?)\)\s*(?:{([^]*?(?:(?<!{){(?:[^]*?)}(?!})[^]*?)*)}|([^{].*?)(?=\s*(?:;|$));)/g;
15
+ static ELSE_REGEX = /}\s*else(?!\s+if\b)\s*(?:{((?:[^{}]|{(?:[^{}]|{[^{}]*})*})*)}|([^{].*?)(?=\n|;|$))/g;
16
+ static PROMISE_CHAIN_REGEX = /\.(then|catch|finally)\s*\(\s*(?:async\s+)?(?:\(?([^)]*)\)?)?\s*=>\s*(?:\{((?:[^{}]|`[^`]*`)*?)\}|([^{;]*?(?:\.[^{;]*?)*(?:\([^)]*\))?)(?=\s*(?:\)\)|\.|\))))/g;
17
+ static TRY_CATCH_BLOCK_REGEX = /try\s*{[\s\S]*?}\s*catch\s*\(([^)]*)\)\s*{/g;
18
+ static PRETTIER_CONFIG = {
53
19
  parser: 'babel',
54
20
  printWidth: 120,
55
21
  tabWidth: 4,
56
22
  useTabs: false,
57
23
  singleQuote: true,
58
24
  };
59
- static detectExistingImport(content) {
60
- return importRegex.test(content);
25
+ static async formatContent(content) {
26
+ try {
27
+ return await prettier.format(content, this.PRETTIER_CONFIG);
28
+ }
29
+ catch (error) {
30
+ if (error instanceof Error) {
31
+ throw new Error(`Formatting failed: ${error.message}`);
32
+ }
33
+ throw new Error('Formatting failed with unknown error');
34
+ }
61
35
  }
62
- static detectExistingLogger(content) {
63
- const match = content.match(loggerRegex);
36
+ static isInstrumented(content) {
37
+ return this.IMPORT_REGEX.test(content);
38
+ }
39
+ static detectLogger(content) {
40
+ const match = content.match(this.LOGGER_REGEX);
64
41
  return {
65
42
  exists: match !== null,
66
- loggerName: match ? match[1] : 'logger',
43
+ variableName: match ? match[1] : 'logger',
67
44
  };
68
45
  }
69
46
  static addImportAndLogger(content, componentName) {
70
47
  let modified = content;
71
- if (!this.detectExistingImport(content)) {
48
+ if (!this.IMPORT_REGEX.test(content)) {
72
49
  modified = `import { createLogger } from 'c/rflibLogger';\n${modified}`;
73
50
  }
74
- const { exists, loggerName } = this.detectExistingLogger(content);
51
+ const { exists, variableName } = this.detectLogger(content);
75
52
  if (!exists) {
76
- const exportMatch = content.match(exportDefaultRegex);
53
+ const exportMatch = content.match(this.EXPORT_DEFAULT_REGEX);
77
54
  const className = exportMatch ? exportMatch[1] : componentName;
78
- const loggerDeclaration = `\nconst ${loggerName} = createLogger('${className}');\n`;
79
- modified = modified.replace(exportDefaultRegex, `${loggerDeclaration}$&`);
55
+ const loggerDeclaration = `\nconst ${variableName} = createLogger('${className}');\n`;
56
+ modified = modified.replace(this.EXPORT_DEFAULT_REGEX, `${loggerDeclaration}$&`);
80
57
  }
81
58
  return modified;
82
59
  }
83
- static findEnclosingMethod(content, position) {
84
- const beforeCatch = content.substring(0, position);
85
- const methods = [...beforeCatch.matchAll(methodRegex)].reverse();
86
- const closestMethod = methods[0];
87
- return closestMethod ? closestMethod[1] : 'unknown';
88
- }
89
60
  static processIfStatements(content, loggerName) {
90
61
  const conditions = [];
91
- // Process if statements and store conditions with positions
92
- let modified = content.replace(ifStatementRegex, (match, condition, blockBody, singleLineBody, offset) => {
62
+ let modified = content.replace(this.IF_STATEMENT_REGEX, (match, condition, blockBody, singleLineBody, offset) => {
93
63
  const cleanedUpCondition = condition.trim().replaceAll("'", "\\'");
94
- conditions.push({
95
- condition: cleanedUpCondition,
96
- position: offset,
97
- });
64
+ conditions.push({ condition: cleanedUpCondition, position: offset });
98
65
  const logStatement = `${loggerName}.debug('if (${cleanedUpCondition})');\n `;
99
66
  if (blockBody) {
100
67
  return `if (${condition}) {\n ${logStatement}${blockBody}}`;
@@ -105,11 +72,9 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
105
72
  }
106
73
  return match;
107
74
  });
108
- // Process else blocks using nearest if condition
109
- modified = modified.replace(elseRegex, (match, blockBody, singleLineBody, offset) => {
110
- // Find last if statement before this else
75
+ modified = modified.replace(this.ELSE_REGEX, (match, blockBody, singleLineBody, offset) => {
111
76
  const nearestIf = conditions
112
- .filter((c) => c.position <= offset)
77
+ .filter((c) => c.position <= (offset ?? 0))
113
78
  .reduce((prev, curr) => (!prev || curr.position > prev.position ? curr : prev));
114
79
  const logStatement = nearestIf
115
80
  ? `${loggerName}.debug('else for if (${nearestIf.condition})');\n `
@@ -124,9 +89,8 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
124
89
  });
125
90
  return modified;
126
91
  }
127
- static processMethodLogging(content, loggerName, flags) {
128
- // First handle methods
129
- let modified = content.replace(methodRegex, (match, methodName, args) => {
92
+ static processMethodLogging(content, loggerName, options) {
93
+ let modified = content.replace(this.METHOD_REGEX, (match, methodName, args) => {
130
94
  const parameters = args
131
95
  .split(',')
132
96
  .map((p) => p.trim())
@@ -135,17 +99,24 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
135
99
  const logArgs = parameters.length > 0 ? `, ${parameters.join(', ')}` : '';
136
100
  return `${match}\n ${loggerName}.info('${methodName}(${placeholders})'${logArgs});`;
137
101
  });
138
- // Then handle if statements
139
- if (!flags.noIf) {
102
+ if (!options.noIf) {
140
103
  modified = this.processIfStatements(modified, loggerName);
141
104
  }
142
105
  return modified;
143
106
  }
107
+ static processTryCatchBlocks(content, loggerName) {
108
+ return content.replace(this.TRY_CATCH_BLOCK_REGEX, (match, exceptionVar, offset) => {
109
+ const methodName = this.findEnclosingMethod(content, offset);
110
+ const errorVar = exceptionVar.trim().split(' ')[0] || 'error';
111
+ return match.replace(/catch\s*\(([^)]*)\)\s*{/, `catch(${exceptionVar}) {
112
+ ${loggerName}.error('An error occurred in function ${methodName}()', ${errorVar});`);
113
+ });
114
+ }
144
115
  static processPromiseChains(content, loggerName) {
145
- return content.replace(promiseChainRegex, (match, type, param, blockBody, singleLineBody, offset) => {
116
+ return content.replace(this.PROMISE_CHAIN_REGEX, (match, type, param, blockBody, singleLineBody, offset) => {
146
117
  const methodName = this.findEnclosingMethod(content, offset);
147
118
  const paramName = typeof param === 'string' ? param.trim() : type === 'then' ? 'result' : 'error';
148
- const indentation = match.match(/\n\s*/)?.[0] || '\n ';
119
+ const indentation = match.match(/\n\s*/)?.[0] ?? '\n ';
149
120
  let logStatement;
150
121
  switch (type) {
151
122
  case 'then':
@@ -161,14 +132,14 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
161
132
  logStatement = '';
162
133
  }
163
134
  if (singleLineBody) {
164
- let trimmedSingleLineBody = singleLineBody.trim();
165
- if (trimmedSingleLineBody.split(')').length > trimmedSingleLineBody.split('(').length) {
166
- trimmedSingleLineBody = trimmedSingleLineBody.slice(0, -1);
167
- }
135
+ const trimmedBody = singleLineBody.trim();
136
+ const adjustedBody = trimmedBody.split(')').length > trimmedBody.split('(').length
137
+ ? trimmedBody.slice(0, -1)
138
+ : trimmedBody;
168
139
  return `.${type}((${paramName}) => {
169
- ${logStatement}
170
- return ${trimmedSingleLineBody};
171
- }`;
140
+ ${logStatement}
141
+ return ${adjustedBody};
142
+ }`;
172
143
  }
173
144
  if (blockBody) {
174
145
  return `.${type}((${paramName}) => {${indentation}${logStatement}${indentation}${blockBody}}`;
@@ -176,71 +147,112 @@ export default class RflibLoggingLwcInstrument extends SfCommand {
176
147
  return match;
177
148
  });
178
149
  }
179
- static processTryCatchBlocks(content, loggerName) {
180
- return content.replace(tryCatchBlockRegex, (match, exceptionVar, offset) => {
181
- const methodName = this.findEnclosingMethod(content, offset);
182
- const errorVar = exceptionVar.trim().split(' ')[0] || 'error';
183
- return match.replace(/catch\s*\(([^)]*)\)\s*{/, `catch(${exceptionVar}) {
184
- ${loggerName}.error('An error occurred in function ${methodName}()', ${errorVar});`);
185
- });
150
+ static findEnclosingMethod(content, position) {
151
+ const beforeCatch = content.substring(0, position);
152
+ const methods = [...beforeCatch.matchAll(this.METHOD_REGEX)].reverse();
153
+ const closestMethod = methods[0];
154
+ return closestMethod ? closestMethod[1] : 'unknown';
186
155
  }
156
+ }
157
+ export default class RflibLoggingLwcInstrument extends SfCommand {
158
+ static summary = messages.getMessage('summary');
159
+ static description = messages.getMessage('description');
160
+ static examples = messages.getMessages('examples');
161
+ static flags = {
162
+ sourcepath: Flags.string({
163
+ char: 's',
164
+ required: true,
165
+ summary: messages.getMessage('flags.sourcepath.summary'),
166
+ description: messages.getMessage('flags.sourcepath.description'),
167
+ }),
168
+ dryrun: Flags.boolean({
169
+ char: 'd',
170
+ default: false,
171
+ summary: messages.getMessage('flags.dryrun.summary'),
172
+ description: messages.getMessage('flags.dryrun.description'),
173
+ }),
174
+ prettier: Flags.boolean({
175
+ char: 'p',
176
+ default: false,
177
+ summary: messages.getMessage('flags.prettier.summary'),
178
+ description: messages.getMessage('flags.prettier.description'),
179
+ }),
180
+ 'no-if': Flags.boolean({
181
+ summary: messages.getMessage('flags.no-if.summary'),
182
+ description: messages.getMessage('flags.no-if.description'),
183
+ default: false,
184
+ }),
185
+ 'skip-instrumented': Flags.boolean({
186
+ summary: messages.getMessage('flags.skip-instrumented.summary'),
187
+ description: messages.getMessage('flags.skip-instrumented.description'),
188
+ default: false,
189
+ }),
190
+ };
191
+ logger;
192
+ stats = {
193
+ processedFiles: 0,
194
+ modifiedFiles: 0,
195
+ formattedFiles: 0,
196
+ };
187
197
  async run() {
188
198
  this.logger = await Logger.child(this.ctor.name);
189
199
  const { flags } = await this.parse(RflibLoggingLwcInstrument);
190
- const instrumentationFlags = {
200
+ const instrumentationOpts = {
191
201
  prettier: flags.prettier,
192
202
  noIf: flags['no-if'],
203
+ skipInstrumented: flags['skip-instrumented'],
193
204
  };
194
205
  this.log(`Scanning LWC components in ${flags.sourcepath}...`);
195
206
  this.spinner.start('Running...');
196
- await this.processDirectory(flags.sourcepath, flags.dryrun, instrumentationFlags);
207
+ await this.processDirectory(flags.sourcepath, flags.dryrun, instrumentationOpts);
197
208
  this.spinner.stop();
198
- this.log(`\nInstrumentation complete.`);
199
- this.log(`Processed files: ${this.processedFiles}`);
200
- this.log(`Modified files: ${this.modifiedFiles}`);
201
- this.log(`Formatted files: ${this.formattedFiles}`);
202
- return {
203
- processedFiles: this.processedFiles,
204
- modifiedFiles: this.modifiedFiles,
205
- formattedFiles: this.formattedFiles,
206
- };
209
+ this.log('\nInstrumentation complete.');
210
+ this.log(`Processed files: ${this.stats.processedFiles}`);
211
+ this.log(`Modified files: ${this.stats.modifiedFiles}`);
212
+ this.log(`Formatted files: ${this.stats.formattedFiles}`);
213
+ return { ...this.stats };
207
214
  }
208
- async processDirectory(dirPath, isDryRun, flags) {
215
+ async processDirectory(dirPath, isDryRun, instrumentationOpts) {
209
216
  const files = await fs.promises.readdir(dirPath);
210
217
  for (const file of files) {
211
218
  const filePath = path.join(dirPath, file);
212
219
  const stat = await fs.promises.stat(filePath);
213
220
  if (stat.isDirectory()) {
214
- await this.processDirectory(filePath, isDryRun, flags);
221
+ await this.processDirectory(filePath, isDryRun, instrumentationOpts);
215
222
  }
216
223
  else if (file.endsWith('.js') &&
217
224
  !path.dirname(filePath).includes('aura') &&
218
225
  !path.dirname(filePath).includes('__tests__')) {
219
- await this.instrumentLwcFile(filePath, isDryRun, flags);
226
+ await this.instrumentLwcFile(filePath, isDryRun, instrumentationOpts);
220
227
  }
221
228
  }
222
229
  }
223
- async instrumentLwcFile(filePath, isDryRun, flags) {
230
+ async instrumentLwcFile(filePath, isDryRun, instrumentationOpts) {
224
231
  const componentName = path.basename(path.dirname(filePath));
225
232
  this.logger.debug(`Processing LWC: ${componentName}`);
226
- const usePrettier = flags.prettier;
227
233
  try {
228
- this.processedFiles++;
234
+ this.stats.processedFiles++;
229
235
  let content = await fs.promises.readFile(filePath, 'utf8');
230
236
  const originalContent = content;
231
- const { loggerName } = RflibLoggingLwcInstrument.detectExistingLogger(content);
232
- content = RflibLoggingLwcInstrument.addImportAndLogger(content, componentName);
233
- content = RflibLoggingLwcInstrument.processMethodLogging(content, loggerName, flags);
234
- content = RflibLoggingLwcInstrument.processTryCatchBlocks(content, loggerName);
235
- content = RflibLoggingLwcInstrument.processPromiseChains(content, loggerName);
237
+ if (instrumentationOpts.skipInstrumented && LwcInstrumentationService.isInstrumented(content)) {
238
+ this.logger.info(`Skipping instrumented component: ${componentName}`);
239
+ return;
240
+ }
241
+ const { variableName } = LwcInstrumentationService.detectLogger(content);
242
+ content = LwcInstrumentationService.addImportAndLogger(content, componentName);
243
+ content = LwcInstrumentationService.processMethodLogging(content, variableName, instrumentationOpts);
244
+ content = LwcInstrumentationService.processTryCatchBlocks(content, variableName);
245
+ content = LwcInstrumentationService.processPromiseChains(content, variableName);
236
246
  if (content !== originalContent) {
237
- this.modifiedFiles++;
247
+ this.stats.modifiedFiles++;
238
248
  if (!isDryRun) {
239
249
  try {
240
- const finalContent = usePrettier ? await prettier.format(content, this.prettierConfig) : content;
250
+ const finalContent = instrumentationOpts.prettier
251
+ ? await LwcInstrumentationService.formatContent(content)
252
+ : content;
241
253
  await fs.promises.writeFile(filePath, finalContent);
242
- if (usePrettier) {
243
- this.formattedFiles++;
254
+ if (instrumentationOpts.prettier) {
255
+ this.stats.formattedFiles++;
244
256
  this.logger.info(`Modified and formatted: ${filePath}`);
245
257
  }
246
258
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../../../src/commands/rflib/logging/lwc/instrument.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,qCAAqC;AACrC,8CAA8C;AAC9C,kDAAkD;AAClD,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,6DAA6D;AAC7D,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,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,WAAW,GAAG,+DAA+D,CAAC;AACpF,MAAM,WAAW,GAAG,yDAAyD,CAAC;AAC9E,MAAM,WAAW,GAAG,+EAA+E,CAAC;AACpG,MAAM,kBAAkB,GAAG,kCAAkC,CAAC;AAC9D,MAAM,gBAAgB,GAAG,0FAA0F,CAAC;AACpH,MAAM,SAAS,GAAG,qFAAqF,CAAC;AACxG,MAAM,iBAAiB,GACrB,8IAA8I,CAAC;AACjJ,MAAM,kBAAkB,GAAG,6CAA6C,CAAC;AAkBzE,MAAM,CAAC,O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AC,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\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}"]}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe,EAAE,CAAC","sourcesContent":["export default {};\n"]}
@@ -44,6 +44,15 @@ Exclude the instrumentation of if-else statements.
44
44
 
45
45
  When provided, the command will not add log statements inside of `if` and `else` blocks.
46
46
 
47
+
48
+ # flags.skip-instrumented.summary
49
+
50
+ Skips any files where a logger is already present.
51
+
52
+ # flags.skip-instrumented.description
53
+
54
+ When provided, the command will not add log statements to any Apex class that contains the `rflib_Logger` reference.
55
+
47
56
  # examples
48
57
 
49
58
  - Add logging statements to all Apex classes in a directory:
@@ -56,5 +65,4 @@ $ sf rflib logging apex instrument --sourcepath force-app/main/default/classes -
56
65
 
57
66
  - Add logging statements and format code:
58
67
 
59
- $ sf rflib logging apex instrument --sourcepath force-app/main/default/classes --prettier
60
-
68
+ $ sf rflib logging apex instrument --sourcepath force-app/main/default/classes --prettier
@@ -63,6 +63,14 @@ Exclude the instrumentation of if-else statements.
63
63
 
64
64
  When provided, the command will not add log statements inside of `if` and `else` blocks.
65
65
 
66
+ # flags.skip-instrumented.summary
67
+
68
+ Skips any files where a logger is already present.
69
+
70
+ # flags.skip-instrumented.description
71
+
72
+ When provided, the command will not add log statements to any Aura component that contains the `` component.
73
+
66
74
  # examples
67
75
 
68
76
  - Add logging to all aura files:
@@ -75,4 +83,4 @@ $ sf rflib logging aura instrument --sourcepath force-app --dryrun
75
83
  $ sf rflib logging aura instrument --sourcepath force-app --prettier
76
84
 
77
85
  - Process specific component:
78
- $ sf rflib logging aura instrument --sourcepath force-app/main/default/aura/myComponent
86
+ $ sf rflib logging aura instrument --sourcepath force-app/main/default/aura/myComponent
@@ -57,6 +57,14 @@ Exclude the instrumentation of if-else statements.
57
57
 
58
58
  When provided, the command will not add log statements inside of `if` and `else` blocks.
59
59
 
60
+ # flags.skip-instrumented.summary
61
+
62
+ Skips any files where a logger is already present.
63
+
64
+ # flags.skip-instrumented.description
65
+
66
+ When provided, the command will not add log statements to any Apex class that contains the `rflib` import statement.
67
+
60
68
  # examples
61
69
 
62
70
  - Add logging to all LWC files: