-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated package names, added additional migrations
- Loading branch information
1 parent
954f94c
commit 09cef2f
Showing
6 changed files
with
127 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Project, ts } from 'ts-morph'; | ||
import { visitNotIgnoredFiles } from './tools/visit-not-ignored-files'; | ||
import { log } from '@clack/prompts'; | ||
|
||
export function replaceImportInFiles(oldImport: string, newImport: string, library: string) { | ||
const project = new Project(); | ||
|
||
visitNotIgnoredFiles('.', (path) => { | ||
if (!path.endsWith('.ts')) { | ||
return; | ||
} | ||
project.addSourceFileAtPath(path); | ||
}); | ||
|
||
project.getSourceFiles().forEach((sourceFile) => { | ||
let hasChanges = false; | ||
|
||
sourceFile.getImportDeclarations().forEach((importDeclaration) => { | ||
if (importDeclaration.getModuleSpecifierValue() === library) { | ||
importDeclaration.getNamedImports().forEach((namedImport) => { | ||
if (namedImport.getName() === oldImport) { | ||
namedImport.renameAlias(newImport); | ||
hasChanges = true; | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
sourceFile.getDescendantsOfKind(ts.SyntaxKind.Identifier).forEach((identifier) => { | ||
if (identifier.getText() === oldImport) { | ||
identifier.replaceWithText(newImport); | ||
hasChanges = true; | ||
} | ||
}); | ||
|
||
if (hasChanges) { | ||
sourceFile.saveSync(); | ||
log.info(`Updated imports of "${oldImport}" in ${sourceFile.getFilePath()}`); | ||
} | ||
}); | ||
} |
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,5 +1,6 @@ | ||
export const versions = { | ||
'@qwik.dev/qwik': '2.0.0', | ||
'@qwik.dev/city': '2.0.0', | ||
'@qwik.dev/core': '2.0.0', | ||
'@qwik.dev/router': '2.0.0', | ||
'@qwik.dev/react': '2.0.0', | ||
'eslint-plugin-qwik': '2.0.0', | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.