Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RLC Changelog Generation Based on Inline Usage #8751

Merged
merged 40 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
472b6c1
Support RLC Changelog Generation Based on Inline Usage
wanlwanl Aug 1, 2024
0e2560d
Fixed test
wanlwanl Aug 1, 2024
86b2040
Updated version
wanlwanl Aug 1, 2024
a16f0d8
Updated ts config
wanlwanl Aug 1, 2024
e2a1489
Update
wanlwanl Aug 1, 2024
9dc4012
Updated
wanlwanl Aug 1, 2024
ec84c88
Updated test
wanlwanl Aug 1, 2024
7fffccf
Updated for all kinds of changelog items
wanlwanl Aug 2, 2024
f15580b
Update package version
wanlwanl Aug 2, 2024
549a189
Made compatible check stricter
wanlwanl Aug 6, 2024
f451e16
Updated version to resolve pipeline issue
wanlwanl Aug 6, 2024
486aa92
Moved breaking change detection tool to js release tool
wanlwanl Aug 6, 2024
ee3c307
Removed unused file
wanlwanl Aug 6, 2024
d5b7d94
Updated CI
wanlwanl Aug 7, 2024
d91f362
Cleanup test files
wanlwanl Aug 8, 2024
db9b509
Cleaned up more test files
wanlwanl Aug 8, 2024
d71068e
Updated ApiVersionTypeExtractor
wanlwanl Aug 8, 2024
0dbd282
Merge branch 'main' into wanl/support-changelog-in-rlc
wanlwanl Aug 12, 2024
07d0555
Remove
wanlwanl Aug 12, 2024
20e6c58
Update changelogGenerator.ts
wanlwanl Aug 12, 2024
5531c71
Merge remote-tracking branch 'Azure/main' into wanl/support-changelog…
wanlwanl Aug 13, 2024
42a6407
Merge remote-tracking branch 'Azure/main' into wanl/support-changelog…
wanlwanl Aug 13, 2024
1d09c29
Merge remote-tracking branch 'Azure/main' into wanl/support-changelog…
wanlwanl Aug 14, 2024
92c9da8
Update
wanlwanl Aug 14, 2024
42446fb
debug
wanlwanl Aug 14, 2024
def3cf5
debug
wanlwanl Aug 14, 2024
aef3b35
fixed endless calls
wanlwanl Aug 14, 2024
b94e3a9
Fix recursive issue
wanlwanl Aug 15, 2024
02966da
Add Recursive test case
wanlwanl Aug 15, 2024
d41730f
Fix signature issue
wanlwanl Aug 15, 2024
95551f4
Merge remote-tracking branch 'Azure/main' into wanl/support-changelog…
wanlwanl Aug 15, 2024
4c643f8
Update CI
wanlwanl Aug 15, 2024
2f7ad47
Update gitignore
wanlwanl Aug 15, 2024
e16f54d
Move folder
wanlwanl Aug 15, 2024
1c76aea
Update version in detector
wanlwanl Aug 16, 2024
1a4bd02
.
wanlwanl Aug 16, 2024
073122d
Update
wanlwanl Aug 16, 2024
d139c08
Add lock
wanlwanl Aug 16, 2024
e09ac84
Add lock
wanlwanl Aug 19, 2024
a622d02
Add gitignore
wanlwanl Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
912 changes: 561 additions & 351 deletions tools/js-sdk-release-tools/package-lock.json

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions tools/js-sdk-release-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.7.11",
"description": "",
"scripts": {
"dev": "nodemon src/changelogToolCli.ts",
"dev": "tsx watch src/changelogToolCli.ts",
"start": "node dist/changelogToolCli.js",
"debug": "node --inspect-brk dist/changelogToolCli.js",
"build": "rimraf dist && tsc -p .",
Expand Down Expand Up @@ -32,16 +32,15 @@
"semver": "^7.3.5",
"shelljs": "^0.8.4",
"simple-git": "^3.5.0",
"ts-morph": "^12.0.0",
"tslib": "^1.9.3",
"ts-morph": "^23.0.0",
wanlwanl marked this conversation as resolved.
Show resolved Hide resolved
"typescript-codegen-breaking-change-detector": "^0.4.4",
"yaml": "^1.10.2"
},
"devDependencies": {
"@types/node": "^20.12.12",
"@types/shelljs": "^0.8.15",
"nodemon": "^3.1.0",
"rimraf": "^3.0.2",
"ts-node": "^10.9.2",
"tsx": "^4.16.3",
"typescript": "^5.4.5",
"vitest": "^1.6.0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { InlineDeclarationNameSetMessage, NodeContext } from 'typescript-codegen-breaking-change-detector';
import { Changelog, ChangelogItem } from './changelogGenerator';

export class RestLevelClientChangelogPostProcessor {
private changelog: Changelog;
private message: InlineDeclarationNameSetMessage;
constructor(changelog: Changelog, message: InlineDeclarationNameSetMessage) {
this.changelog = changelog;
this.message = message;
}

public run() {
this.handleChangelogItems(this.changelog.addedOperationGroup);
this.handleChangelogItems(this.changelog.removedOperationGroup);
this.handleChangelogItems(this.changelog.addedOperation);
this.handleChangelogItems(this.changelog.addedInterface);
this.handleChangelogItems(this.changelog.addedClass);
this.handleChangelogItems(this.changelog.addedTypeAlias);
this.handleChangelogItems(this.changelog.interfaceAddOptionalParam);
this.handleChangelogItems(this.changelog.interfaceParamTypeExtended);
this.handleChangelogItems(this.changelog.typeAliasAddInherit);
this.handleChangelogItems(this.changelog.typeAliasAddParam);
this.handleChangelogItems(this.changelog.addedEnum);
this.handleChangelogItems(this.changelog.addedEnumValue);
this.handleChangelogItems(this.changelog.addedFunction);
this.handleChangelogItems(this.changelog.removedOperation);
this.handleChangelogItems(this.changelog.operationSignatureChange);
this.handleChangelogItems(this.changelog.deletedClass);
this.handleChangelogItems(this.changelog.classSignatureChange);
this.handleChangelogItems(this.changelog.interfaceParamDelete);
this.handleChangelogItems(this.changelog.interfaceParamAddRequired);
this.handleChangelogItems(this.changelog.interfaceParamTypeChanged);
this.handleChangelogItems(this.changelog.interfaceParamChangeRequired);
this.handleChangelogItems(this.changelog.classParamDelete);
this.handleChangelogItems(this.changelog.classParamChangeRequired);
this.handleChangelogItems(this.changelog.typeAliasDeleteInherit);
this.handleChangelogItems(this.changelog.typeAliasParamDelete);
this.handleChangelogItems(this.changelog.typeAliasAddRequiredParam);
this.handleChangelogItems(this.changelog.typeAliasParamChangeRequired);
this.handleChangelogItems(this.changelog.removedEnum);
this.handleChangelogItems(this.changelog.removedEnumValue);
this.handleChangelogItems(this.changelog.removedFunction);
}

private getCurrentNodeContext(name: string | undefined): NodeContext | undefined {
if (!name) return undefined;
return this.message.current.get(name);
}

private getBaselineNodeContext(name: string | undefined): NodeContext | undefined {
if (!name) return undefined;
return this.message.baseline.get(name);
}

private findCompatibleNodeContext(
inputContext: NodeContext,
contextMapToFind: Map<string, NodeContext>,
checkAssignableFromInputToFound: boolean
): NodeContext | undefined {
for (const [_, foundContext] of contextMapToFind) {
const isCompatible = checkAssignableFromInputToFound
? inputContext.node.getType().isAssignableTo(foundContext.node.getType())
: foundContext.node.getType().isAssignableTo(inputContext.node.getType());
if (isCompatible) return foundContext;
}
return undefined;
}

private tryIgnoreInlineTypeInChangelogItem(
inputContext: NodeContext,
nodeContextMapToFind: Map<string, NodeContext>,
checkAssignableFromInputToFound: boolean,
item: ChangelogItem
) {
if (!inputContext) return;
const foundContext = this.findCompatibleNodeContext(
inputContext,
nodeContextMapToFind,
checkAssignableFromInputToFound
);
if (foundContext) {
inputContext.used = true;
foundContext.used = true;
item.toDelete = true;
}
return;
}

private handleChangelogItems(items: ChangelogItem[]) {
items.forEach((item) => {
if (!item.oldName && !item.newName) return;

if (item.newName && item.oldName) {
const currentContext = this.getCurrentNodeContext(item.newName);
if (!currentContext) return;
const baselineContext = this.getBaselineNodeContext(item.oldName);
if (!baselineContext) return;
const currentType = currentContext.node.getType();
const baselineType = baselineContext.node.getType();
if (currentType.isAssignableTo(baselineType)) {
item.toDelete = true;
currentContext.used = true;
baselineContext.used = true;
}
return;
}

if (item.newName) {
const inputContext = this.getCurrentNodeContext(item.newName);
if (!inputContext) return;
this.tryIgnoreInlineTypeInChangelogItem(inputContext, this.message.baseline, true, item);
return;
}

// item.baselineName exists
const inputContext = this.getBaselineNodeContext(item.oldName);
if (!inputContext) return;
this.tryIgnoreInlineTypeInChangelogItem(inputContext, this.message.current, false, item);
return;
});
}
}
Loading
Loading