代码模组
@prisma/codemods 包可帮助你随着 Prisma ORM 的发展升级代码库。
¥The @prisma/codemods package helps you to upgrade your codebase as Prisma ORM evolves.
你可以在此处查看存储库:https://github.com/prisma/codemods
¥You can checkout the repository, here: https://github.com/prisma/codemods
用法
¥Usage
$ npx @prisma/codemods <transform> <path> <...options>
-
<transform>- 请参阅 变换 了解可用选项¥
<transform>- See Transforms for available choices -
<path>- 你的应用的目录。即./my-awesome-project¥
<path>- The directory of your app. i.e ./my-awesome-project
选项
¥Options
-
(-f)orce- 绕过 Git 安全检查并强制运行 codemod¥
(-f)orce- Bypass Git safety checks and forcibly run codemods -
(-s)chemaPath- 指定 ./prisma/schema.prisma 的路径¥
(-s)chemaPath- Specify a path to your ./prisma/schema.prisma -
(-d)ry- 试运行(不对文件进行任何更改)¥
(-d)ry- Dry run (no changes are made to files) -
(-p)rint- 将转换后的文件打印到你的终端¥
(-p)rint- Print transformed files to your terminal -
--instanceNames=myClient- 在导入已实例化的客户端时很有用(即从 './myClient' 导入 myClient)¥
--instanceNames=myClient- Useful when importing an already instantiated client (i.e import myClient from './myClient')
变换
¥Transforms
<transform> | 描述 | 示例 |
|---|---|---|
namespace | @prisma/client 命名空间更改的 Codemod | npx @prisma/codemods namespace ./my-project |
findUnique | 将 prisma.x.findOne 转换为 prisma.x.findUnique | npx @prisma/codemods findUnique ./my-project |
to$ | 至$:将已弃用的 prisma.x 方法转换为 prisma.$x | npx @prisma/codemods to$ ./my-project |
update-2.12 | 包括 namespace/findUnique/to$ | npx @prisma/codemods update-2.12 ./my-project |