-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove current user from createAuthResolver
- Loading branch information
1 parent
305d888
commit 79a0f4e
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Project, SyntaxKind } from "ts-morph"; | ||
|
||
export default async function removeCurrentUserFromAuthModule() { | ||
console.log("Remove Current User From Auth Module"); | ||
|
||
const project = new Project({ tsConfigFilePath: "./api/tsconfig.json" }); | ||
const sourceFiles = project.getSourceFiles("api/src/**/*.ts"); | ||
sourceFiles.forEach((sourceFile) => { | ||
const createAuthResolverCall = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).find((callExpression) => { | ||
const expression = callExpression.getExpression(); | ||
return expression.getText() === "createAuthResolver"; | ||
}); | ||
|
||
if (createAuthResolverCall) { | ||
const argument = createAuthResolverCall.getArguments()[0]; | ||
if (argument && argument.getKind() === SyntaxKind.ObjectLiteralExpression) { | ||
const objectLiteral = argument.asKindOrThrow(SyntaxKind.ObjectLiteralExpression); | ||
const currentUserProp = objectLiteral.getProperty("currentUser"); | ||
if (currentUserProp) { | ||
console.log("Found createAuthResolver and removed currentUser in ", sourceFile.getFilePath()); | ||
|
||
currentUserProp.remove(); | ||
} | ||
} | ||
} | ||
sourceFile.save(); | ||
}); | ||
} |