Skip to content

Commit c91e75f

Browse files
committed
Resolving TODOs
1 parent 43cace6 commit c91e75f

File tree

3 files changed

+21
-32
lines changed

3 files changed

+21
-32
lines changed

src/core/changelog/generate-change-log.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import {
22
ParsedFile,
33
Skip,
44
UnparsedApexBundle,
5-
UnparsedCustomFieldBundle,
6-
UnparsedCustomObjectBundle,
75
UnparsedSourceBundle,
86
UserDefinedChangelogConfig,
97
} from '../shared/types';
@@ -21,6 +19,7 @@ import { skip } from '../shared/utils';
2119
import { reflectCustomFieldsAndObjects } from '../reflection/sobject/reflectCustomFieldsAndObjects';
2220
import { CustomObjectMetadata } from '../reflection/sobject/reflect-custom-object-sources';
2321
import { Type } from '@cparra/apex-reflection';
22+
import { filterApexSourceFiles, filterCustomObjectsAndFields } from '#utils/source-bundle-utils';
2423

2524
export type ChangeLogPageData = {
2625
content: string;
@@ -55,27 +54,12 @@ export function generateChangeLog(
5554
}
5655

5756
function reflect(bundles: UnparsedSourceBundle[], config: Omit<UserDefinedChangelogConfig, 'targetGenerator'>) {
58-
// TODO: Move to utility and reuse
59-
function filterApexSourceFiles(sourceFiles: UnparsedSourceBundle[]): UnparsedApexBundle[] {
60-
return sourceFiles.filter((sourceFile): sourceFile is UnparsedApexBundle => sourceFile.type === 'apex');
61-
}
62-
6357
const filterOutOfScopeApex = apply(filterScope, config.scope);
6458

6559
function reflectApexFiles(sourceFiles: UnparsedApexBundle[]) {
6660
return pipe(reflectApexSource(sourceFiles), TE.map(filterOutOfScopeApex));
6761
}
6862

69-
// TODO: Move to utility and reuse
70-
function filterCustomObjectsAndFields(
71-
sourceFiles: UnparsedSourceBundle[],
72-
): (UnparsedCustomObjectBundle | UnparsedCustomFieldBundle)[] {
73-
return sourceFiles.filter(
74-
(sourceFile): sourceFile is UnparsedCustomObjectBundle =>
75-
sourceFile.type === 'customobject' || sourceFile.type === 'customfield',
76-
);
77-
}
78-
7963
return pipe(
8064
reflectApexFiles(filterApexSourceFiles(bundles)),
8165
TE.chain((parsedApexFiles) => {

src/core/markdown/generate-docs.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ import {
1717
DocPageReference,
1818
TransformReference,
1919
ParsedFile,
20-
UnparsedCustomObjectBundle,
2120
UnparsedSourceBundle,
22-
UnparsedCustomFieldBundle,
2321
} from '../shared/types';
2422
import { parsedFilesToRenderableBundle } from './adapters/renderable-bundle';
2523
import { reflectApexSource } from '../reflection/apex/reflect-apex-source';
@@ -37,6 +35,7 @@ import { HookError } from '../errors/errors';
3735
import { CustomObjectMetadata } from '../reflection/sobject/reflect-custom-object-sources';
3836
import { Type } from '@cparra/apex-reflection';
3937
import { reflectCustomFieldsAndObjects } from '../reflection/sobject/reflectCustomFieldsAndObjects';
38+
import { filterApexSourceFiles, filterCustomObjectsAndFields } from '#utils/source-bundle-utils';
4039

4140
export type MarkdownGeneratorConfig = Omit<
4241
UserDefinedMarkdownConfig,
@@ -55,19 +54,6 @@ export function generateDocs(unparsedBundles: UnparsedSourceBundle[], config: Ma
5554
);
5655
const sort = apply(sortTypesAndMembers, config.sortAlphabetically);
5756

58-
function filterApexSourceFiles(sourceFiles: UnparsedSourceBundle[]): UnparsedApexBundle[] {
59-
return sourceFiles.filter((sourceFile): sourceFile is UnparsedApexBundle => sourceFile.type === 'apex');
60-
}
61-
62-
function filterCustomObjectsAndFields(
63-
sourceFiles: UnparsedSourceBundle[],
64-
): (UnparsedCustomObjectBundle | UnparsedCustomFieldBundle)[] {
65-
return sourceFiles.filter(
66-
(sourceFile): sourceFile is UnparsedCustomObjectBundle =>
67-
sourceFile.type === 'customobject' || sourceFile.type === 'customfield',
68-
);
69-
}
70-
7157
function filterOutCustomFields(parsedFiles: ParsedFile[]): ParsedFile<Type | CustomObjectMetadata>[] {
7258
return parsedFiles.filter(
7359
(parsedFile): parsedFile is ParsedFile<Type | CustomObjectMetadata> => parsedFile.source.type !== 'customfield',

src/util/source-bundle-utils.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {
2+
UnparsedApexBundle,
3+
UnparsedCustomFieldBundle,
4+
UnparsedCustomObjectBundle,
5+
UnparsedSourceBundle,
6+
} from '../core/shared/types';
7+
8+
export function filterApexSourceFiles(sourceFiles: UnparsedSourceBundle[]): UnparsedApexBundle[] {
9+
return sourceFiles.filter((sourceFile): sourceFile is UnparsedApexBundle => sourceFile.type === 'apex');
10+
}
11+
12+
export function filterCustomObjectsAndFields(
13+
sourceFiles: UnparsedSourceBundle[],
14+
): (UnparsedCustomObjectBundle | UnparsedCustomFieldBundle)[] {
15+
return sourceFiles.filter(
16+
(sourceFile): sourceFile is UnparsedCustomObjectBundle =>
17+
sourceFile.type === 'customobject' || sourceFile.type === 'customfield',
18+
);
19+
}

0 commit comments

Comments
 (0)