A. 团队棱镜图书馆
- 此套件包含一个共享的 Prisma schema, 组织为 多个文件,用于多个储存库/项目.
- 通过集中计划定义,我们确保一致性并减少重复工作:
- 一致性:我们的目标是同一个MongoDB数据库。 如果我们使用不同的计划定义文件,就有可能出现不一致的模型定义,这可能导致冲突和数据覆盖.
- 效率:一个单一的计划定义可以减少冗余的工作. 目前,Schema文件有300多行,随着我们登上更多的收藏品,这可以很容易地发展到1000+行. 通过协作制定单一的计划定义,我们可以精简我们的努力,提高整体质量.
安装
- 要安装此软件包, 请添加以下可选的依赖性( 在
X.Y.Z代表版本 :
"optionalDependencies": {
"@a_team/prisma-win": "npm:@a_team/[email protected]",
"@a_team/prisma-macos": "npm:@a_team/[email protected]",
"@a_team/prisma-linux": "npm:@a_team/[email protected]",
"@a_team/prisma-linux-debian": "npm:@a_team/[email protected]"
}
- 添加以下脚本为
postinstall按服务需求更改( c) :
const fs = require('fs');
const path = require('path');
const getLinuxDistribution = () => {
try {
const osRelease = fs.readFileSync('/etc/os-release', 'utf-8');
const match = osRelease.match(/^ID=(.+)$/m);
return match ? match[1].replace(/"/g, '') : 'unknown';
} catch (error) {
console.error('Failed to detect Linux distribution:', error.message);
return 'unknown';
}
};
const getPlatformPackage = () => {
switch (process.platform) {
case 'darwin':
return '@a_team/prisma-macos';
case 'win32':
return '@a_team/prisma-win';
default:
const linuxDistro = getLinuxDistribution();
if (linuxDistro === 'debian') {
return '@a_team/prisma-linux-debian';
}
return '@a_team/prisma-linux';
}
};
const platformPackage = getPlatformPackage();
const nodeModulesPath = path.join(__dirname, '..', 'node_modules');
const sourcePath = path.join(nodeModulesPath, platformPackage);
const targetPath = path.join(nodeModulesPath, '@a_team/prisma');
if (fs.existsSync(sourcePath)) {
if (fs.existsSync(targetPath)) {
fs.rmSync(targetPath, { recursive: true, force: true });
}
fs.renameSync(sourcePath, targetPath);
console.log(`Renamed ${platformPackage} to @a_team/prisma`);
} else {
console.error(`Platform-specific package ${platformPackage} not found`);
process.exit(1);
}
- 上面的脚本将把所需的OS依赖性作为主要连接起来.
使用量
- 要使用库 :
import { ATeamPrismaClient } from '@a_team/prisma';
export class DbClient extends ATeamPrismaClient {
constructor(connectionUrl: string) {
super(connectionUrl);
}
async onModuleInit() {
await this.connect();
}
async onModuleDestroy() {
await this.disconnect();
}
}
游戏场
- 游乐场是一个专用空间,可以测试并实验棱镜客户端和斯克曼.
- 它包含各种显示如何与数据库模型交互的脚本.
- 在运行任何游乐场脚本之前,确保设置您的环境变量. 首先,复制该
.env.sample文件为.env数字 :
cp .env.sample .env
- 然后,在
.env文档. - 要运行操场脚本,请使用以下命令:
npx ts-node playground/missionSpec.ts
部署版本
- 鉴于版本模式
MAJOR.MINOR.PATCH、递增和释放应作为:MAJOR修改不兼容的服务/代码时必须增加版本,MINOR在以反向兼容的方式实现功能时,必须增加版本,PATCH当反向兼容的bug修正(针对现有特性)时,必须增加版本.
出版新版本
-
调出最新的更改
main分支并推出以下标记到寄存器 :git tag v<major>.<minor>.<patch> # matches v0.0.1 git push origin tag v<major>.<minor>.<patch> # runs the publishing process -
此标签创建了所需的新软件包版本并把它们推向 npm 寄存器,
-
A 类
release编辑github仓库生成, -
随着发行量的改变,向所需的频道发送了不及时的通知.