Skip to content

Commit

Permalink
Merge branch 'main' into check-git
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre-Herve authored Sep 21, 2023
2 parents 6cd756d + 21b2265 commit 5d7e541
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 333 deletions.
6 changes: 0 additions & 6 deletions projects/openapi-io/src/write/yaml-roundtrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,3 @@ function insert<T>(arr: T[], index: number, item: any) {
copy.splice(index, 0, item);
return copy;
}

function remove<T>(arr: T[], index: number) {
const copy = [...arr];
copy.splice(index, 1);
return copy;
}
4 changes: 0 additions & 4 deletions projects/openapi-utilities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
} from './openapi3/implementations/openapi3/sourcemap-reader';

export { defaultEmptySpec } from './openapi3/constants';
export * from './legacy-ci-types';
export * from './openapi3/implementations/openapi3/types';

export { SPEC_TAG_REGEXP, sanitizeGitTag } from './specs/tags';
Expand All @@ -75,11 +74,8 @@ export {
groupChangesAndRules,
} from './utilities/group-changes';
export { traverseSpec } from './utilities/traverse-spec';
export { generateChangelogData } from './utilities/generate-changelog-data';
export { compareChangesByPath } from './utilities/compare-changes-by-path';
export {
getOperationsModifsLabel,
countOperationsModifications,
getLabel,
getOperationsChanged,
getOperationsChangedLabel,
Expand Down
9 changes: 0 additions & 9 deletions projects/openapi-utilities/src/legacy-ci-types.ts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,62 +1,12 @@
import { getEndpointDiffs, typeofV3Diffs } from '../openapi3/group-diff';
import { isChangeVariant } from '../openapi3/sdk/isType';
import { OpenApiKind, IChange, ChangeType } from '../openapi3/sdk/types';
import { ChangeType } from '../openapi3/sdk/types';
import { GroupedDiffs } from '../openapi3/group-diff';

const getChangeOperationId = (change: IChange) => {
const path = (change.location.conceptualLocation as any).path;
const method = (change.location.conceptualLocation as any).method;
if (!path || !method) return null;
return `${path}.${method}`;
};

export const countOperationsModifications = (changes: IChange[]) => {
const operationsChanges = changes.filter((c) =>
isChangeVariant(c, OpenApiKind.Operation)
);

const operationsAdded = operationsChanges.filter(
(c) => c.changeType === ChangeType.Added
);
const operationsRemoved = operationsChanges.filter(
(c) => c.changeType === ChangeType.Removed
);
const operationsChanged = operationsChanges.filter(
(c) => c.changeType === ChangeType.Changed
);

const operationsByChange = {
[ChangeType.Added]: new Set(
operationsAdded.map(getChangeOperationId).filter((id) => !!id)
),
[ChangeType.Changed]: new Set(
operationsChanged.map(getChangeOperationId).filter((id) => !!id)
),
[ChangeType.Removed]: new Set(
operationsRemoved.map(getChangeOperationId).filter((id) => !!id)
),
};

const operationWasAddedOrRemoved = (operationId: string) =>
operationsByChange.added.has(operationId) ||
operationsByChange.removed.has(operationId);

for (const change of changes) {
const operationId = getChangeOperationId(change);
if (!operationId || operationWasAddedOrRemoved(operationId)) continue;
operationsByChange.changed.add(operationId);
}

return {
[ChangeType.Added]: operationsByChange[ChangeType.Added].size,
[ChangeType.Changed]: operationsByChange[ChangeType.Changed].size,
[ChangeType.Removed]: operationsByChange[ChangeType.Removed].size,
};
};

export const getLabel = (
operationsModifsCount: ReturnType<typeof countOperationsModifications>
) =>
export const getLabel = (operationsModifsCount: {
[ChangeType.Added]: number;
[ChangeType.Changed]: number;
[ChangeType.Removed]: number;
}) =>
Object.keys(operationsModifsCount)
.filter((k) => (operationsModifsCount as any)[k])
.map(
Expand All @@ -71,9 +21,6 @@ export const getLabel = (
)
.join(', ');

export const getOperationsModifsLabel = (changes: IChange[]) =>
getLabel(countOperationsModifications(changes));

export const getOperationsChanged = (
groupedDiffs: GroupedDiffs
): {
Expand Down

This file was deleted.

Loading

0 comments on commit 5d7e541

Please sign in to comment.