forked from unlight/prisma-nestjs-graphql
-
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.
feat: Export all classes from one file
close unlight#5
- Loading branch information
Showing
8 changed files
with
102 additions
and
9 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
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
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { reexport } from './reexport'; | ||
export { remove } from './remove'; | ||
export { update } from './update'; |
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,32 @@ | ||
import { Project, SourceFile } from 'ts-morph'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await | ||
export async function reexport(project: Project) { | ||
const nextFiles = new Set<SourceFile>(); | ||
for (const sourceFile of project.getSourceFiles()) { | ||
const directoryPath = sourceFile.getDirectory().getPath(); | ||
const testIndexFile = `${directoryPath}/index.ts`; | ||
const sourceIndexFile = | ||
project.getSourceFile(testIndexFile) || | ||
project.createSourceFile(testIndexFile); | ||
sourceIndexFile.addExportDeclaration({ | ||
namedExports: sourceFile | ||
.getExportSymbols() | ||
.map(s => ({ name: s.getName() })), | ||
moduleSpecifier: `./${sourceFile.getBaseNameWithoutExtension()}`, | ||
}); | ||
|
||
nextFiles.add(sourceIndexFile); | ||
} | ||
|
||
const sourceIndexFile = project.createSourceFile('/index.ts'); | ||
for (const sourceFile of nextFiles) { | ||
const moduleSpecifier = `.${sourceFile.getDirectory().getPath()}`; | ||
sourceIndexFile.addExportDeclaration({ | ||
namedExports: sourceFile | ||
.getExportSymbols() | ||
.map(s => ({ name: s.getName() })), | ||
moduleSpecifier, | ||
}); | ||
} | ||
} |
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
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
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