@cparra/apexdocs 3.17.1-beta.2 → 3.17.1-beta.4

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,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var Apexdocs = require('../Apexdocs-C2wTTG_T.js');
4
+ var logger$1 = require('../logger-WfBgFc4u.js');
5
5
  var cosmiconfig = require('cosmiconfig');
6
6
  var yargs = require('yargs');
7
7
  var E = require('fp-ts/Either');
@@ -24,9 +24,9 @@ require('fp-ts/boolean');
24
24
  require('fp-ts/Array');
25
25
  require('fs');
26
26
  require('fp-ts/lib/TaskEither');
27
- require('chalk');
28
27
  require('minimatch');
29
28
  require('@salesforce/source-deploy-retrieve');
29
+ require('chalk');
30
30
 
31
31
  function _interopNamespaceDefault(e) {
32
32
  var n = Object.create(null);
@@ -79,42 +79,42 @@ const markdownOptions = {
79
79
  targetDir: {
80
80
  type: "string",
81
81
  alias: "t",
82
- default: Apexdocs.markdownDefaults.targetDir,
82
+ default: logger$1.markdownDefaults.targetDir,
83
83
  describe: "The directory location where documentation will be generated to."
84
84
  },
85
85
  scope: {
86
86
  type: "string",
87
87
  array: true,
88
88
  alias: "p",
89
- default: Apexdocs.markdownDefaults.scope,
89
+ default: logger$1.markdownDefaults.scope,
90
90
  describe: "A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. Annotations are supported and should be passed lowercased and without the @ symbol, e.g. namespaceaccessible auraenabled."
91
91
  },
92
92
  customObjectVisibility: {
93
93
  type: "string",
94
94
  array: true,
95
95
  alias: "v",
96
- default: Apexdocs.markdownDefaults.customObjectVisibility,
96
+ default: logger$1.markdownDefaults.customObjectVisibility,
97
97
  choices: ["public", "protected", "packageprotected"],
98
98
  describe: "Controls which custom objects are documented. Values should be separated by a space."
99
99
  },
100
100
  defaultGroupName: {
101
101
  type: "string",
102
- default: Apexdocs.markdownDefaults.defaultGroupName,
102
+ default: logger$1.markdownDefaults.defaultGroupName,
103
103
  describe: "Defines the @group name to be used when a file does not specify it."
104
104
  },
105
105
  customObjectsGroupName: {
106
106
  type: "string",
107
- default: Apexdocs.markdownDefaults.customObjectsGroupName,
107
+ default: logger$1.markdownDefaults.customObjectsGroupName,
108
108
  describe: "The name under which custom objects will be grouped in the Reference Guide"
109
109
  },
110
110
  triggersGroupName: {
111
111
  type: "string",
112
- default: Apexdocs.markdownDefaults.triggersGroupName,
112
+ default: logger$1.markdownDefaults.triggersGroupName,
113
113
  describe: "The name under which triggers will be grouped in the Reference Guide"
114
114
  },
115
115
  lwcGroupName: {
116
116
  type: "string",
117
- default: Apexdocs.markdownDefaults.lwcGroupName,
117
+ default: logger$1.markdownDefaults.lwcGroupName,
118
118
  describe: "The name under which Lightning Web Components will be grouped in the Reference Guide"
119
119
  },
120
120
  namespace: {
@@ -124,28 +124,28 @@ const markdownOptions = {
124
124
  sortAlphabetically: {
125
125
  type: "boolean",
126
126
  describe: "Whether to sort files and members alphabetically.",
127
- default: Apexdocs.markdownDefaults.sortAlphabetically
127
+ default: logger$1.markdownDefaults.sortAlphabetically
128
128
  },
129
129
  includeMetadata: {
130
130
  type: "boolean",
131
131
  describe: "Whether to include the file's meta.xml information: Whether it is active and and the API version",
132
- default: Apexdocs.markdownDefaults.includeMetadata
132
+ default: logger$1.markdownDefaults.includeMetadata
133
133
  },
134
134
  linkingStrategy: {
135
135
  type: "string",
136
136
  describe: "The strategy to use when linking to other documentation pages.",
137
137
  choices: ["relative", "no-link", "none"],
138
- default: Apexdocs.markdownDefaults.linkingStrategy
138
+ default: logger$1.markdownDefaults.linkingStrategy
139
139
  },
140
140
  referenceGuideTitle: {
141
141
  type: "string",
142
142
  describe: "The title of the reference guide.",
143
- default: Apexdocs.markdownDefaults.referenceGuideTitle
143
+ default: logger$1.markdownDefaults.referenceGuideTitle
144
144
  },
145
145
  includeFieldSecurityMetadata: {
146
146
  type: "boolean",
147
147
  describe: "Whether to include the compliance category and security classification for fields in the generated files.",
148
- default: Apexdocs.markdownDefaults.includeFieldSecurityMetadata
148
+ default: logger$1.markdownDefaults.includeFieldSecurityMetadata
149
149
  },
150
150
  includeInlineHelpTextMetadata: {
151
151
  type: "boolean",
@@ -154,17 +154,17 @@ const markdownOptions = {
154
154
  experimentalLwcSupport: {
155
155
  type: "boolean",
156
156
  describe: "Enable experimental support for documenting Lightning Web Components (LWC).",
157
- default: Apexdocs.markdownDefaults.experimentalLwcSupport
157
+ default: logger$1.markdownDefaults.experimentalLwcSupport
158
158
  },
159
159
  parallelReflection: {
160
160
  type: "boolean",
161
161
  describe: "Parallelize CPU-heavy reflection via worker threads.",
162
- default: Apexdocs.markdownDefaults.parallelReflection
162
+ default: logger$1.markdownDefaults.parallelReflection
163
163
  },
164
164
  parallelReflectionMaxWorkers: {
165
165
  type: "number",
166
166
  describe: "Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value based on CPU count.",
167
- default: Apexdocs.markdownDefaults.parallelReflectionMaxWorkers
167
+ default: logger$1.markdownDefaults.parallelReflectionMaxWorkers
168
168
  }
169
169
  };
170
170
 
@@ -200,12 +200,12 @@ const openApiOptions = {
200
200
  targetDir: {
201
201
  type: "string",
202
202
  alias: "t",
203
- default: Apexdocs.openApiDefaults.targetDir,
203
+ default: logger$1.openApiDefaults.targetDir,
204
204
  describe: "The directory location where the OpenApi file will be generated."
205
205
  },
206
206
  fileName: {
207
207
  type: "string",
208
- default: Apexdocs.openApiDefaults.fileName,
208
+ default: logger$1.openApiDefaults.fileName,
209
209
  describe: "The name of the OpenApi file to be generated."
210
210
  },
211
211
  namespace: {
@@ -214,23 +214,23 @@ const openApiOptions = {
214
214
  },
215
215
  title: {
216
216
  type: "string",
217
- default: Apexdocs.openApiDefaults.title,
217
+ default: logger$1.openApiDefaults.title,
218
218
  describe: "The title of the OpenApi file."
219
219
  },
220
220
  apiVersion: {
221
221
  type: "string",
222
- default: Apexdocs.openApiDefaults.apiVersion,
222
+ default: logger$1.openApiDefaults.apiVersion,
223
223
  describe: "The version of the OpenApi file."
224
224
  },
225
225
  parallelReflection: {
226
226
  type: "boolean",
227
227
  describe: "Parallelize CPU-heavy reflection via worker threads.",
228
- default: Apexdocs.openApiDefaults.parallelReflection
228
+ default: logger$1.openApiDefaults.parallelReflection
229
229
  },
230
230
  parallelReflectionMaxWorkers: {
231
231
  type: "number",
232
232
  describe: "Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value based on CPU count.",
233
- default: Apexdocs.openApiDefaults.parallelReflectionMaxWorkers
233
+ default: logger$1.openApiDefaults.parallelReflectionMaxWorkers
234
234
  }
235
235
  };
236
236
 
@@ -249,12 +249,12 @@ const changeLogOptions = {
249
249
  parallelReflection: {
250
250
  type: "boolean",
251
251
  describe: "Parallelize CPU-heavy reflection via worker threads.",
252
- default: Apexdocs.markdownDefaults.parallelReflection
252
+ default: logger$1.markdownDefaults.parallelReflection
253
253
  },
254
254
  parallelReflectionMaxWorkers: {
255
255
  type: "number",
256
256
  describe: "Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value based on CPU count.",
257
- default: Apexdocs.markdownDefaults.parallelReflectionMaxWorkers
257
+ default: logger$1.markdownDefaults.parallelReflectionMaxWorkers
258
258
  },
259
259
  previousVersionDir: {
260
260
  type: "string",
@@ -273,32 +273,32 @@ const changeLogOptions = {
273
273
  targetDir: {
274
274
  type: "string",
275
275
  alias: "t",
276
- default: Apexdocs.changeLogDefaults.targetDir,
276
+ default: logger$1.changeLogDefaults.targetDir,
277
277
  describe: "The directory location where the changelog file will be generated."
278
278
  },
279
279
  fileName: {
280
280
  type: "string",
281
- default: Apexdocs.changeLogDefaults.fileName,
281
+ default: logger$1.changeLogDefaults.fileName,
282
282
  describe: "The name of the changelog file to be generated."
283
283
  },
284
284
  scope: {
285
285
  type: "string",
286
286
  array: true,
287
287
  alias: "s",
288
- default: Apexdocs.changeLogDefaults.scope,
288
+ default: logger$1.changeLogDefaults.scope,
289
289
  describe: "The list of scope to respect when generating the changelog. Values should be separated by a space, e.g --scope global public namespaceaccessible. Annotations are supported and should be passed lowercased and without the @ symbol, e.g. namespaceaccessible auraenabled."
290
290
  },
291
291
  customObjectVisibility: {
292
292
  type: "string",
293
293
  array: true,
294
294
  alias: "v",
295
- default: Apexdocs.changeLogDefaults.customObjectVisibility,
295
+ default: logger$1.changeLogDefaults.customObjectVisibility,
296
296
  choices: ["public", "protected", "packageprotected"],
297
297
  describe: "Controls which custom objects are documented. Values should be separated by a space."
298
298
  },
299
299
  skipIfNoChanges: {
300
300
  type: "boolean",
301
- default: Apexdocs.changeLogDefaults.skipIfNoChanges,
301
+ default: logger$1.changeLogDefaults.skipIfNoChanges,
302
302
  describe: "Skip the changelog generation if there are no changes between the previous and current version."
303
303
  }
304
304
  };
@@ -406,13 +406,13 @@ function extractArgsForCommandProvidedThroughCli(extractFromProcessFn, config) {
406
406
  switch (mergedConfig.targetGenerator) {
407
407
  case "markdown":
408
408
  return _function.pipe(
409
- Apexdocs.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
409
+ logger$1.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
410
410
  E__namespace.mapLeft((error) => new Error(`Invalid markdown configuration: ${error.message}`)),
411
411
  E__namespace.map(() => __spreadValues(__spreadValues({}, configOnlyMarkdownDefaults), mergedConfig))
412
412
  );
413
413
  case "openapi":
414
414
  return _function.pipe(
415
- Apexdocs.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
415
+ logger$1.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
416
416
  E__namespace.mapLeft((error) => new Error(`Invalid openapi configuration: ${error.message}`)),
417
417
  E__namespace.map(() => __spreadValues(__spreadValues({}, configOnlyOpenApiDefaults), mergedConfig))
418
418
  );
@@ -440,7 +440,7 @@ function extractArgsForCommandsProvidedInConfig(extractFromProcessFn, config) {
440
440
  E__namespace.flatMap((cliArgs) => {
441
441
  const mergedConfig = __spreadValues(__spreadValues(__spreadValues({}, configOnlyMarkdownDefaults), generatorConfig), cliArgs);
442
442
  return _function.pipe(
443
- Apexdocs.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
443
+ logger$1.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
444
444
  E__namespace.mapLeft((error) => new Error(`Invalid markdown configuration: ${error.message}`)),
445
445
  E__namespace.map(() => mergedConfig)
446
446
  );
@@ -452,7 +452,7 @@ function extractArgsForCommandsProvidedInConfig(extractFromProcessFn, config) {
452
452
  E__namespace.flatMap((cliArgs) => {
453
453
  const mergedConfig = __spreadValues(__spreadValues(__spreadValues({}, configOnlyOpenApiDefaults), generatorConfig), cliArgs);
454
454
  return _function.pipe(
455
- Apexdocs.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
455
+ logger$1.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
456
456
  E__namespace.mapLeft((error) => new Error(`Invalid openapi configuration: ${error.message}`)),
457
457
  E__namespace.map(() => mergedConfig)
458
458
  );
@@ -557,8 +557,8 @@ function validateChangelogConfig(config) {
557
557
  };
558
558
  return _function.pipe(
559
559
  E__namespace.Do,
560
- E__namespace.bind("previousValid", () => Apexdocs.validateSourceDirectoryConfig(previousVersionConfig)),
561
- E__namespace.bind("currentValid", () => Apexdocs.validateSourceDirectoryConfig(currentVersionConfig)),
560
+ E__namespace.bind("previousValid", () => logger$1.validateSourceDirectoryConfig(previousVersionConfig)),
561
+ E__namespace.bind("currentValid", () => logger$1.validateSourceDirectoryConfig(currentVersionConfig)),
562
562
  E__namespace.map(() => config)
563
563
  );
564
564
  }
@@ -586,11 +586,9 @@ var __async = (__this, __arguments, generator) => {
586
586
  function isDebugEnabledFromProcessArgs() {
587
587
  return process.argv.includes("--debug");
588
588
  }
589
- const logger = new Apexdocs.StdOutLogger();
589
+ const logger = new logger$1.StdOutLogger();
590
590
  logger.setDebug(isDebugEnabledFromProcessArgs());
591
- if (logger.isDebugEnabled()) {
592
- process.env.APEXDOCS_DEBUG = "true";
593
- }
591
+ const reflectionDebugLogger = logger$1.createReflectionDebugLogger(logger);
594
592
  function main() {
595
593
  const aggregatedFailures = [];
596
594
  let commandsRun = 0;
@@ -632,7 +630,7 @@ function main() {
632
630
  if (logger.isDebugEnabled()) {
633
631
  logger.debug(`Currently processing generator: ${config.targetGenerator}`);
634
632
  }
635
- const result = yield Apexdocs.Apexdocs.generate(config, logger);
633
+ const result = yield logger$1.Apexdocs.generate(config, { logger, reflectionDebugLogger });
636
634
  if (logger.isDebugEnabled()) {
637
635
  logger.logSingle(
638
636
  `${config.targetGenerator}: ${E__namespace.isRight(result) ? "success" : "failure"}`,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var Apexdocs = require('./Apexdocs-C2wTTG_T.js');
4
+ var logger = require('./logger-WfBgFc4u.js');
5
5
  var E = require('fp-ts/Either');
6
6
  require('fp-ts/function');
7
7
  require('fp-ts/TaskEither');
@@ -21,9 +21,9 @@ require('fp-ts/boolean');
21
21
  require('fp-ts/Array');
22
22
  require('fs');
23
23
  require('fp-ts/lib/TaskEither');
24
- require('chalk');
25
24
  require('minimatch');
26
25
  require('@salesforce/source-deploy-retrieve');
26
+ require('chalk');
27
27
 
28
28
  function _interopNamespaceDefault(e) {
29
29
  var n = Object.create(null);
@@ -82,12 +82,13 @@ var __async = (__this, __arguments, generator) => {
82
82
  };
83
83
  function process(config) {
84
84
  return __async(this, null, function* () {
85
- const logger = new Apexdocs.NoLogger();
85
+ const logger$1 = new logger.NoLogger();
86
+ const reflectionDebugLogger = logger.createReflectionDebugLogger(logger$1);
86
87
  const configWithDefaults = __spreadValues$1(__spreadValues$1({}, getDefault(config)), config);
87
88
  if (!configWithDefaults.sourceDir) {
88
89
  throw new Error("sourceDir is required");
89
90
  }
90
- const result = yield Apexdocs.Apexdocs.generate(configWithDefaults, logger);
91
+ const result = yield logger.Apexdocs.generate(configWithDefaults, { logger: logger$1, reflectionDebugLogger });
91
92
  E__namespace.match(
92
93
  (errors) => {
93
94
  throw errors;
@@ -100,11 +101,11 @@ function process(config) {
100
101
  function getDefault(config) {
101
102
  switch (config.targetGenerator) {
102
103
  case "markdown":
103
- return Apexdocs.markdownDefaults;
104
+ return logger.markdownDefaults;
104
105
  case "openapi":
105
- return Apexdocs.openApiDefaults;
106
+ return logger.openApiDefaults;
106
107
  case "changelog":
107
- return Apexdocs.changeLogDefaults;
108
+ return logger.changeLogDefaults;
108
109
  default:
109
110
  throw new Error("Unknown target generator");
110
111
  }
@@ -130,23 +131,23 @@ var __spreadValues = (a, b) => {
130
131
  };
131
132
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
132
133
  function defineMarkdownConfig(config) {
133
- return __spreadProps(__spreadValues(__spreadValues({}, Apexdocs.markdownDefaults), config), {
134
+ return __spreadProps(__spreadValues(__spreadValues({}, logger.markdownDefaults), config), {
134
135
  targetGenerator: "markdown"
135
136
  });
136
137
  }
137
138
  function defineOpenApiConfig(config) {
138
- return __spreadProps(__spreadValues(__spreadValues({}, Apexdocs.openApiDefaults), config), {
139
+ return __spreadProps(__spreadValues(__spreadValues({}, logger.openApiDefaults), config), {
139
140
  targetGenerator: "openapi"
140
141
  });
141
142
  }
142
143
  function defineChangelogConfig(config) {
143
- return __spreadProps(__spreadValues(__spreadValues({}, Apexdocs.changeLogDefaults), config), {
144
+ return __spreadProps(__spreadValues(__spreadValues({}, logger.changeLogDefaults), config), {
144
145
  targetGenerator: "changelog"
145
146
  });
146
147
  }
147
148
 
148
- exports.skip = Apexdocs.skip;
149
- exports.templateHelpers = Apexdocs.templateHelpers;
149
+ exports.skip = logger.skip;
150
+ exports.templateHelpers = logger.templateHelpers;
150
151
  exports.defineChangelogConfig = defineChangelogConfig;
151
152
  exports.defineMarkdownConfig = defineMarkdownConfig;
152
153
  exports.defineOpenApiConfig = defineOpenApiConfig;
@@ -19,9 +19,9 @@ var boolean = require('fp-ts/boolean');
19
19
  var A$1 = require('fp-ts/Array');
20
20
  var fs$1 = require('fs');
21
21
  var TE$1 = require('fp-ts/lib/TaskEither');
22
- var chalk = require('chalk');
23
22
  var minimatch = require('minimatch');
24
23
  var sourceDeployRetrieve = require('@salesforce/source-deploy-retrieve');
24
+ var chalk = require('chalk');
25
25
 
26
26
  function _interopNamespaceDefault(e) {
27
27
  var n = Object.create(null);
@@ -1420,15 +1420,14 @@ var __async$5 = (__this, __arguments, generator) => {
1420
1420
  step((generator = generator.apply(__this, __arguments)).next());
1421
1421
  });
1422
1422
  };
1423
- const noopDebugLogger = {
1424
- onStart: () => {
1425
- },
1423
+ const noopReflectionDebugLogger = {
1426
1424
  onSuccess: () => {
1427
1425
  },
1428
1426
  onFailure: () => {
1429
1427
  }
1430
1428
  };
1431
- function reflectAsync$1(rawSource) {
1429
+ const noopDebugLogger = noopReflectionDebugLogger;
1430
+ function reflectAsync(rawSource) {
1432
1431
  return __async$5(this, null, function* () {
1433
1432
  return new Promise((resolve, reject) => {
1434
1433
  const result = apexReflection.reflect(rawSource);
@@ -1484,7 +1483,6 @@ function reflectApexSourceBestEffort(apexBundles, config, debugLogger = noopDebu
1484
1483
  return _function.pipe(
1485
1484
  apexBundles,
1486
1485
  A__namespace.traverse(Ap)((bundle) => {
1487
- debugLogger.onStart(bundle.filePath);
1488
1486
  return _function.pipe(
1489
1487
  reflectBundle$2(bundle),
1490
1488
  TE__namespace.map((parsed) => {
@@ -1514,9 +1512,7 @@ function reflectApexSourceBestEffort(apexBundles, config, debugLogger = noopDebu
1514
1512
  try {
1515
1513
  const results = yield Promise.allSettled(
1516
1514
  apexBundles.map((bundle) => __async$5(null, null, function* () {
1517
- debugLogger.onStart(bundle.filePath);
1518
- const typeMirror = yield pool.run({ content: bundle.content });
1519
- return typeMirror;
1515
+ return yield pool.run({ content: bundle.content });
1520
1516
  }))
1521
1517
  );
1522
1518
  const errors = [];
@@ -1567,7 +1563,7 @@ function reflectBundle$2(apexBundle) {
1567
1563
  }
1568
1564
  function reflectAsTask$1(apexBundle) {
1569
1565
  return TE__namespace.tryCatch(
1570
- () => reflectAsync$1(apexBundle.content),
1566
+ () => reflectAsync(apexBundle.content),
1571
1567
  (error) => new ReflectionErrors([new ReflectionError(apexBundle.filePath, error.message)])
1572
1568
  );
1573
1569
  }
@@ -3427,13 +3423,13 @@ function toParsedFile$1(filePath, triggerMirror) {
3427
3423
  }
3428
3424
  function reflectAsTask(triggerContent) {
3429
3425
  return TE__namespace.tryCatch(
3430
- () => reflectAsync(triggerContent.content),
3426
+ () => reflect(triggerContent.content),
3431
3427
  (error) => new ReflectionErrors([new ReflectionError(triggerContent.filePath, error.message)])
3432
3428
  );
3433
3429
  }
3434
- function reflectAsync(triggerContent) {
3430
+ function reflect(triggerContent) {
3435
3431
  return __async$4(this, null, function* () {
3436
- const reflectionResult = yield apexReflection.reflectTriggerAsync(triggerContent);
3432
+ const reflectionResult = apexReflection.reflectTrigger(triggerContent);
3437
3433
  if (reflectionResult.error) {
3438
3434
  throw reflectionResult.error;
3439
3435
  }
@@ -4788,6 +4784,21 @@ class OpenApiDocsProcessor {
4788
4784
  }
4789
4785
  }
4790
4786
 
4787
+ function createReflectionDebugLogger(logger) {
4788
+ if (!logger.isDebugEnabled()) {
4789
+ return noopReflectionDebugLogger;
4790
+ }
4791
+ return {
4792
+ onSuccess: (filePath) => {
4793
+ logger.debug(`Parsing: ${filePath} OK`);
4794
+ },
4795
+ onFailure: (filePath, errorMessage) => {
4796
+ logger.debug(`Parsing: ${filePath} FAILED`);
4797
+ logger.debug(`Parsing error: ${filePath} - ${errorMessage}`);
4798
+ }
4799
+ };
4800
+ }
4801
+
4791
4802
  var __defProp$2 = Object.defineProperty;
4792
4803
  var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
4793
4804
  var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
@@ -4835,21 +4846,7 @@ function openApi(logger, fileBodies, config) {
4835
4846
  namespace: config.namespace,
4836
4847
  version: config.apiVersion
4837
4848
  });
4838
- const debugLogger = {
4839
- onStart: (filePath) => {
4840
- if (!logger.isDebugEnabled()) return;
4841
- logger.debug(`Parsing: ${filePath}`);
4842
- },
4843
- onSuccess: (filePath) => {
4844
- if (!logger.isDebugEnabled()) return;
4845
- logger.logSingle(`Parsing: ${filePath} OK`, "green");
4846
- },
4847
- onFailure: (filePath, errorMessage) => {
4848
- if (!logger.isDebugEnabled()) return;
4849
- logger.logSingle(`Parsing: ${filePath} FAILED`, "red");
4850
- logger.debug(`Parsing error: ${filePath} - ${errorMessage}`);
4851
- }
4852
- };
4849
+ const debugLogger = createReflectionDebugLogger(logger);
4853
4850
  const reflectedEither = yield reflectApexSourceBestEffort(
4854
4851
  fileBodies,
4855
4852
  {
@@ -5528,71 +5525,6 @@ function changelogToSourceChangelog(changelog) {
5528
5525
  };
5529
5526
  }
5530
5527
 
5531
- class StdOutLogger {
5532
- constructor(options) {
5533
- this.debugEnabled = false;
5534
- var _a;
5535
- this.debugEnabled = (_a = options == null ? void 0 : options.debug) != null ? _a : false;
5536
- }
5537
- setDebug(enabled) {
5538
- this.debugEnabled = enabled;
5539
- }
5540
- isDebugEnabled() {
5541
- return this.debugEnabled;
5542
- }
5543
- debug(message) {
5544
- if (!this.debugEnabled) {
5545
- return;
5546
- }
5547
- this.logSingle(`[debug] ${String(message)}`);
5548
- }
5549
- /**
5550
- * Logs a message with optional arguments.
5551
- * @param message The message to log.
5552
- * @param args Optional arguments.
5553
- */
5554
- log(message, ...args) {
5555
- this.logSingle(message);
5556
- args.forEach((arg) => {
5557
- this.logSingle(arg);
5558
- });
5559
- }
5560
- /**
5561
- * Logs an error message with optional arguments.
5562
- * @param message The error message to log.
5563
- * @param args Optional arguments.
5564
- */
5565
- error(message, ...args) {
5566
- this.logSingle(message, "red");
5567
- args.forEach(() => {
5568
- this.logSingle(message, "red");
5569
- });
5570
- }
5571
- logSingle(text, color = "green") {
5572
- const logMessage = `${this.getChalkFn(color)((/* @__PURE__ */ new Date()).toLocaleString() + ": ")}${text}
5573
- `;
5574
- process.stdout.write(logMessage);
5575
- }
5576
- getChalkFn(color) {
5577
- return color === "green" ? chalk.green : chalk.red;
5578
- }
5579
- }
5580
- class NoLogger {
5581
- setDebug(enabled) {
5582
- }
5583
- isDebugEnabled() {
5584
- return false;
5585
- }
5586
- debug(message) {
5587
- }
5588
- log(message, ...args) {
5589
- }
5590
- error(message, ...args) {
5591
- }
5592
- logSingle(text, color) {
5593
- }
5594
- }
5595
-
5596
5528
  var __defProp$1 = Object.defineProperty;
5597
5529
  var __defProps$1 = Object.defineProperties;
5598
5530
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
@@ -5638,34 +5570,7 @@ function changelogReflectionConfig(config) {
5638
5570
  parallelReflectionMaxWorkers: config.parallelReflectionMaxWorkers
5639
5571
  };
5640
5572
  }
5641
- function getDebugLogger() {
5642
- var _a, _b;
5643
- const enabled = ((_a = process.env.APEXDOCS_DEBUG) != null ? _a : "").toLowerCase() === "true" || ((_b = process.env.APEXDOCS_DEBUG) != null ? _b : "").toLowerCase() === "1";
5644
- const logger = new StdOutLogger({ debug: enabled });
5645
- if (!enabled) {
5646
- return {
5647
- onStart: () => {
5648
- },
5649
- onSuccess: () => {
5650
- },
5651
- onFailure: () => {
5652
- }
5653
- };
5654
- }
5655
- return {
5656
- onStart: (filePath) => {
5657
- logger.debug(`Parsing: ${filePath}`);
5658
- },
5659
- onSuccess: (filePath) => {
5660
- logger.logSingle(`Parsing: ${filePath} OK`, "green");
5661
- },
5662
- onFailure: (filePath, errorMessage) => {
5663
- logger.logSingle(`Parsing: ${filePath} FAILED`, "red");
5664
- logger.debug(`Parsing error: ${filePath} - ${errorMessage}`);
5665
- }
5666
- };
5667
- }
5668
- function generateChangeLog(oldBundles, newBundles, config) {
5573
+ function generateChangeLog(oldBundles, newBundles, config, debugLogger) {
5669
5574
  const convertToPageData = apply(toPageData, config.fileName);
5670
5575
  function handleConversion({ changelog, newManifest }) {
5671
5576
  if (config.skipIfNoChanges && !hasChanges(changelog)) {
@@ -5680,12 +5585,10 @@ function generateChangeLog(oldBundles, newBundles, config) {
5680
5585
  }
5681
5586
  const reflectVersionBestEffort = (bundles) => {
5682
5587
  const filterOutOfScopeApex = apply(filterScope, config.scope);
5683
- const debugLogger = getDebugLogger();
5684
5588
  const apexConfig = changelogReflectionConfig(config);
5685
5589
  return _function.pipe(
5686
5590
  TE__namespace.right(bundles),
5687
5591
  TE__namespace.bindTo("bundles"),
5688
- // 1) Apex
5689
5592
  TE__namespace.bind(
5690
5593
  "apex",
5691
5594
  ({ bundles: bundles2 }) => _function.pipe(
@@ -5698,11 +5601,9 @@ function generateChangeLog(oldBundles, newBundles, config) {
5698
5601
  parsedFiles: filterOutOfScopeApex(successes),
5699
5602
  errors
5700
5603
  })),
5701
- // Best-effort: if the reflection system itself fails unexpectedly, treat that as a single error and continue.
5702
5604
  TE__namespace.orElseW((errs) => TE__namespace.right({ parsedFiles: [], errors: errs }))
5703
5605
  )
5704
5606
  ),
5705
- // 2) Custom objects / fields / metadata records
5706
5607
  TE__namespace.bind(
5707
5608
  "objects",
5708
5609
  ({ bundles: bundles2, apex }) => _function.pipe(
@@ -5714,13 +5615,12 @@ function generateChangeLog(oldBundles, newBundles, config) {
5714
5615
  parsedFiles: [...apex.parsedFiles, ...parsedObjectFiles],
5715
5616
  errors: apex.errors
5716
5617
  })),
5717
- // For best-effort semantics we swallow failures here and keep going, because
5618
+ // We swallow failures here and keep going, because
5718
5619
  // this helper's left type is `never`. Any such failures are treated as if
5719
5620
  // this step produced no additional parsed files.
5720
5621
  TE__namespace.orElseW(() => TE__namespace.right({ parsedFiles: apex.parsedFiles, errors: apex.errors }))
5721
5622
  )
5722
5623
  ),
5723
- // 3) Triggers
5724
5624
  TE__namespace.bind(
5725
5625
  "all",
5726
5626
  ({ objects, bundles: bundles2 }) => _function.pipe(
@@ -5729,7 +5629,7 @@ function generateChangeLog(oldBundles, newBundles, config) {
5729
5629
  parsedFiles: [...objects.parsedFiles, ...parsedTriggerFiles],
5730
5630
  errors: objects.errors
5731
5631
  })),
5732
- // For best-effort semantics we swallow failures here and keep going, because
5632
+ // We swallow failures here and keep going, because
5733
5633
  // this helper's left type is `never`. Any such failures are treated as if
5734
5634
  // no triggers were parsed.
5735
5635
  TE__namespace.orElseW(() => TE__namespace.right({ parsedFiles: objects.parsedFiles, errors: objects.errors }))
@@ -5845,14 +5745,14 @@ function postHookCompile(page) {
5845
5745
  });
5846
5746
  }
5847
5747
 
5848
- function generate(oldBundles, newBundles, config) {
5748
+ function generate(oldBundles, newBundles, config, debugLogger) {
5849
5749
  function handleFile(file) {
5850
5750
  if (isSkip(file)) {
5851
5751
  return TE__namespace.right("\u2714\uFE0F Done! Skipped writing files to the system.");
5852
5752
  }
5853
5753
  return writeFilesToSystem(file, config.targetDir);
5854
5754
  }
5855
- return _function.pipe(generateChangeLog(oldBundles, newBundles, config), TE__namespace.flatMap(handleFile));
5755
+ return _function.pipe(generateChangeLog(oldBundles, newBundles, config, debugLogger), TE__namespace.flatMap(handleFile));
5856
5756
  }
5857
5757
  function writeFilesToSystem(pageData, outputDir) {
5858
5758
  return _function.pipe(
@@ -6268,19 +6168,15 @@ var __async = (__this, __arguments, generator) => {
6268
6168
  class Apexdocs {
6269
6169
  /**
6270
6170
  * Generates documentation out of Apex source files.
6271
- *
6272
- * NOTE:
6273
- * - Markdown + Changelog generators are now expected to be "best-effort" and may return both successes and
6274
- * recoverable parse/reflection failures (to be presented at the end of the run).
6275
- * - OpenAPI is handled separately and already has its own logging/reporting behavior.
6276
6171
  */
6277
- static generate(config, logger) {
6172
+ static generate(config, deps) {
6278
6173
  return __async(this, null, function* () {
6174
+ const { logger, reflectionDebugLogger } = deps;
6279
6175
  logger.logSingle(`Generating ${config.targetGenerator} documentation...`);
6280
6176
  try {
6281
6177
  switch (config.targetGenerator) {
6282
6178
  case "markdown": {
6283
- return (yield processMarkdown(config, logger))();
6179
+ return (yield processMarkdown(config, logger, reflectionDebugLogger))();
6284
6180
  }
6285
6181
  case "openapi": {
6286
6182
  const task = yield processOpenApi(config, logger);
@@ -6291,7 +6187,7 @@ class Apexdocs {
6291
6187
  return E__namespace.right("\u2714\uFE0F Documentation generated successfully!");
6292
6188
  }
6293
6189
  case "changelog": {
6294
- return (yield processChangeLog(config, logger))();
6190
+ return (yield processChangeLog(config, logger, reflectionDebugLogger))();
6295
6191
  }
6296
6192
  }
6297
6193
  } catch (error) {
@@ -6301,23 +6197,9 @@ class Apexdocs {
6301
6197
  }
6302
6198
  }
6303
6199
  const readFiles = apply(processFiles, new DefaultFileSystem());
6304
- function processMarkdown(config, logger) {
6200
+ function processMarkdown(config, logger, reflectionDebugLogger) {
6305
6201
  return __async(this, null, function* () {
6306
- const debugLogger = {
6307
- onStart: (filePath) => {
6308
- if (!logger.isDebugEnabled()) return;
6309
- logger.debug(`Parsing: ${filePath}`);
6310
- },
6311
- onSuccess: (filePath) => {
6312
- if (!logger.isDebugEnabled()) return;
6313
- logger.logSingle(`Parsing: ${filePath} OK`, "green");
6314
- },
6315
- onFailure: (filePath, errorMessage) => {
6316
- if (!logger.isDebugEnabled()) return;
6317
- logger.logSingle(`Parsing: ${filePath} FAILED`, "red");
6318
- logger.debug(`Parsing error: ${filePath} - ${errorMessage}`);
6319
- }
6320
- };
6202
+ const debugLogger = reflectionDebugLogger;
6321
6203
  return _function.pipe(
6322
6204
  resolveAndValidateSourceDirectories(config),
6323
6205
  E__namespace.mapLeft((error) => new FileReadingError(`Failed to resolve source directories: ${error.message}`, error)),
@@ -6332,8 +6214,6 @@ function processMarkdown(config, logger) {
6332
6214
  TE__namespace.fromEither,
6333
6215
  TE__namespace.flatMap((fileBodies) => generate$1(fileBodies, config, debugLogger)),
6334
6216
  TE__namespace.map(() => "\u2714\uFE0F Documentation generated successfully!"),
6335
- // Best-effort behavior: if there were recoverable parse/reflection failures, they should be returned here
6336
- // (for presentation to the user at the end of the run), not thrown earlier.
6337
6217
  TE__namespace.mapLeft((err) => {
6338
6218
  const errors = toErrors(err);
6339
6219
  if (logger.isDebugEnabled()) {
@@ -6365,7 +6245,7 @@ function processOpenApi(config, logger) {
6365
6245
  );
6366
6246
  });
6367
6247
  }
6368
- function processChangeLog(config, logger) {
6248
+ function processChangeLog(config, logger, reflectionDebugLogger) {
6369
6249
  return __async(this, null, function* () {
6370
6250
  function loadFiles() {
6371
6251
  const previousVersionConfig = {
@@ -6403,9 +6283,7 @@ function processChangeLog(config, logger) {
6403
6283
  return _function.pipe(
6404
6284
  loadFiles(),
6405
6285
  TE__namespace.fromEither,
6406
- TE__namespace.flatMap(([previous, current]) => generate(previous, current, config)),
6407
- // Best-effort behavior: if there were recoverable parse/reflection failures, they should be returned here
6408
- // (for presentation to the user at the end of the run), not thrown earlier.
6286
+ TE__namespace.flatMap(([previous, current]) => generate(previous, current, config, reflectionDebugLogger)),
6409
6287
  TE__namespace.mapLeft((err) => {
6410
6288
  const errors = toErrors(err);
6411
6289
  if (logger.isDebugEnabled()) {
@@ -6437,10 +6315,76 @@ ${error.message}
6437
6315
  `;
6438
6316
  }
6439
6317
 
6318
+ class StdOutLogger {
6319
+ constructor(options) {
6320
+ this.debugEnabled = false;
6321
+ var _a;
6322
+ this.debugEnabled = (_a = options == null ? void 0 : options.debug) != null ? _a : false;
6323
+ }
6324
+ setDebug(enabled) {
6325
+ this.debugEnabled = enabled;
6326
+ }
6327
+ isDebugEnabled() {
6328
+ return this.debugEnabled;
6329
+ }
6330
+ debug(message) {
6331
+ if (!this.debugEnabled) {
6332
+ return;
6333
+ }
6334
+ this.logSingle(`[debug] ${String(message)}`);
6335
+ }
6336
+ /**
6337
+ * Logs a message with optional arguments.
6338
+ * @param message The message to log.
6339
+ * @param args Optional arguments.
6340
+ */
6341
+ log(message, ...args) {
6342
+ this.logSingle(message);
6343
+ args.forEach((arg) => {
6344
+ this.logSingle(arg);
6345
+ });
6346
+ }
6347
+ /**
6348
+ * Logs an error message with optional arguments.
6349
+ * @param message The error message to log.
6350
+ * @param args Optional arguments.
6351
+ */
6352
+ error(message, ...args) {
6353
+ this.logSingle(message, "red");
6354
+ args.forEach(() => {
6355
+ this.logSingle(message, "red");
6356
+ });
6357
+ }
6358
+ logSingle(text, color = "green") {
6359
+ const logMessage = `${this.getChalkFn(color)((/* @__PURE__ */ new Date()).toLocaleString() + ": ")}${text}
6360
+ `;
6361
+ process.stdout.write(logMessage);
6362
+ }
6363
+ getChalkFn(color) {
6364
+ return color === "green" ? chalk.green : chalk.red;
6365
+ }
6366
+ }
6367
+ class NoLogger {
6368
+ setDebug(enabled) {
6369
+ }
6370
+ isDebugEnabled() {
6371
+ return false;
6372
+ }
6373
+ debug(message) {
6374
+ }
6375
+ log(message, ...args) {
6376
+ }
6377
+ error(message, ...args) {
6378
+ }
6379
+ logSingle(text, color) {
6380
+ }
6381
+ }
6382
+
6440
6383
  exports.Apexdocs = Apexdocs;
6441
6384
  exports.NoLogger = NoLogger;
6442
6385
  exports.StdOutLogger = StdOutLogger;
6443
6386
  exports.changeLogDefaults = changeLogDefaults;
6387
+ exports.createReflectionDebugLogger = createReflectionDebugLogger;
6444
6388
  exports.markdownDefaults = markdownDefaults;
6445
6389
  exports.openApiDefaults = openApiDefaults;
6446
6390
  exports.skip = skip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cparra/apexdocs",
3
- "version": "3.17.1-beta.2",
3
+ "version": "3.17.1-beta.4",
4
4
  "description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -96,7 +96,7 @@
96
96
  ]
97
97
  },
98
98
  "dependencies": {
99
- "@cparra/apex-reflection": "2.22.0",
99
+ "@cparra/apex-reflection": "2.22.0-dev.20251224093546",
100
100
  "@salesforce/source-deploy-retrieve": "^12.20.1",
101
101
  "@types/js-yaml": "^4.0.9",
102
102
  "@types/yargs": "^17.0.32",