Skip to content

Commit

Permalink
chore: repo overall update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 29, 2024
1 parent 311173b commit 6cc73f3
Show file tree
Hide file tree
Showing 38 changed files with 302 additions and 500 deletions.
22 changes: 11 additions & 11 deletions packages/canyon-collect/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parser: "@typescript-eslint/parser",
parserOptions: {
project: 'tsconfig.json',
project: "tsconfig.json",
tsconfigRootDir: __dirname,
sourceType: 'module',
sourceType: "module",
},
plugins: ['@typescript-eslint/eslint-plugin'],
plugins: ["@typescript-eslint/eslint-plugin"],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
ignorePatterns: [".eslintrc.js"],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
},
};
5 changes: 1 addition & 4 deletions packages/canyon-collect/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{
"singleQuote": true,
"trailingComma": "all"
}
{}
3 changes: 2 additions & 1 deletion packages/canyon-collect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"vercel-build": "prisma generate && nest build",
"build": "prisma generate && nest build",
"start": "prisma generate && nest start",
"preinstall": "prisma generate"
"preinstall": "prisma generate",
"format": "prettier --write ."
},
"dependencies": {
"@mongodb-js/zstd": "^1.2.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/canyon-collect/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { Controller, Get } from "@nestjs/common";
import { AppService } from "./app.service";

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get('api/vi/health')
@Get("api/vi/health")
getHello(): string {
return this.appService.getHello();
}
Expand Down
18 changes: 9 additions & 9 deletions packages/canyon-collect/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { CollectModule } from './apps/collect/collect.module';
import { PrismaService } from './prisma/prisma.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CoveragediskEntity } from './apps/collect/entity/coveragedisk.entity';
import { Module } from "@nestjs/common";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import { CollectModule } from "./apps/collect/collect.module";
import { PrismaService } from "./prisma/prisma.service";
import { TypeOrmModule } from "@nestjs/typeorm";
import { CoveragediskEntity } from "./apps/collect/entity/coveragedisk.entity";
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'sqlite',
database: 'db/sql',
type: "sqlite",
database: "db/sql",
synchronize: true,
entities: [CoveragediskEntity],
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/canyon-collect/src/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common';
import { Injectable } from "@nestjs/common";

@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
return "Hello World!";
}
}
26 changes: 13 additions & 13 deletions packages/canyon-collect/src/apps/collect/collect.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import {
Post,
UploadedFile,
UseInterceptors,
} from '@nestjs/common';
import { PrismaService } from '../../prisma/prisma.service';
import { CoverageClientService } from './services/coverage-client.service';
import { CoverageClientDto } from './dto/coverage-client.dto';
import { FileInterceptor } from '@nestjs/platform-express';
import { CoverageMapClientService } from './services/coverage-map-client.service';
import { CoverageMapClientDto } from './dto/coverage-map-client.dto';
import zlib from 'zlib';
} from "@nestjs/common";
import { PrismaService } from "../../prisma/prisma.service";
import { CoverageClientService } from "./services/coverage-client.service";
import { CoverageClientDto } from "./dto/coverage-client.dto";
import { FileInterceptor } from "@nestjs/platform-express";
import { CoverageMapClientService } from "./services/coverage-map-client.service";
import { CoverageMapClientDto } from "./dto/coverage-map-client.dto";
import zlib from "zlib";
// 解压 GZIP 的 Buffer 数据
async function decompressData(buffer) {
return new Promise((resolve, reject) => {
zlib.gunzip(buffer, (err, decompressed) => {
if (err) {
return reject(err);
}
resolve(decompressed.toString('utf-8')); // 转换为字符串返回
resolve(decompressed.toString("utf-8")); // 转换为字符串返回
});
});
}
Expand All @@ -39,8 +39,8 @@ export class CollectController {
4. 经过测试在macbookpro上compressDataWithStream压缩1600kb的数据,压缩后64kb左右,耗时8ms左右
TODO 得调研8ms对navigator.sendBeacon有没有影响
*/
@UseInterceptors(FileInterceptor('coverage'))
@Post('coverage/client')
@UseInterceptors(FileInterceptor("coverage"))
@Post("coverage/client")
async coverageClient(
@UploadedFile() cov: any,
@Body() coverageClientDto: CoverageClientDto,
Expand All @@ -50,7 +50,7 @@ export class CollectController {
return this.coverageClientService.invoke(coverageClientDto);
}
let coverage = {};
if (cov.mimetype === 'application/octet-stream') {
if (cov.mimetype === "application/octet-stream") {
coverage = await decompressData(cov.buffer).then((jsonString: any) =>
JSON.parse(jsonString),
);
Expand All @@ -67,7 +67,7 @@ export class CollectController {
});
}

@Post('coverage/map/client')
@Post("coverage/map/client")
coverageMapClient(@Body() coverageMapClientDto: CoverageMapClientDto) {
return this.coverageMapClientService.invoke(coverageMapClientDto);
}
Expand Down
18 changes: 9 additions & 9 deletions packages/canyon-collect/src/apps/collect/collect.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Module } from '@nestjs/common';
import { CollectController } from './collect.controller';
import { CoverageClientService } from './services/coverage-client.service';
import { CoverageMapClientService } from './services/coverage-map-client.service';
import { CoveragediskService } from './services/core/coveragedisk.service';
import { ConsumerCoverageService } from './services/core/consumer-coverage.service';
import { CoveragediskEntity } from './entity/coveragedisk.entity';
import { TypeOrmModule } from '@nestjs/typeorm';
import { PrismaService } from '../../prisma/prisma.service';
import { Module } from "@nestjs/common";
import { CollectController } from "./collect.controller";
import { CoverageClientService } from "./services/coverage-client.service";
import { CoverageMapClientService } from "./services/coverage-map-client.service";
import { CoveragediskService } from "./services/core/coveragedisk.service";
import { ConsumerCoverageService } from "./services/core/consumer-coverage.service";
import { CoveragediskEntity } from "./entity/coveragedisk.entity";
import { TypeOrmModule } from "@nestjs/typeorm";
import { PrismaService } from "../../prisma/prisma.service";

@Module({
imports: [TypeOrmModule.forFeature([CoveragediskEntity])],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import {
Matches,
MinLength,
Validate,
} from 'class-validator';
import { IsValidCoverage } from '../valids/is-valid-coverage';
} from "class-validator";
import { IsValidCoverage } from "../valids/is-valid-coverage";

export class CoverageClientDto {
// git仓库相关
@IsString()
@Matches(/^[a-f0-9]{40}$/i, { message: 'sha格式不正确' })
@IsNotEmpty({ message: 'sha 不能为空' })
@Matches(/^[a-f0-9]{40}$/i, { message: "sha格式不正确" })
@IsNotEmpty({ message: "sha 不能为空" })
sha: string;

// @IsString()
Expand Down Expand Up @@ -41,7 +41,7 @@ export class CoverageClientDto {
// key: string;

@IsString()
@IsNotEmpty({ message: 'projectID 不能为空' })
@IsNotEmpty({ message: "projectID 不能为空" })
projectID: string;

// // 单次 case 触发相关
Expand All @@ -52,8 +52,8 @@ export class CoverageClientDto {

// istanbul覆盖率相关
@IsString()
@MinLength(1, { message: 'reportID长度最小为1' })
@IsNotEmpty({ message: 'instrumentCwd不能为空' })
@MinLength(1, { message: "reportID长度最小为1" })
@IsNotEmpty({ message: "instrumentCwd不能为空" })
instrumentCwd: string;

// @IsNotEmpty({ message: 'coverage不能为空' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import {
Matches,
MinLength,
Validate,
} from 'class-validator';
import { IsValidCoverage } from '../valids/is-valid-coverage-map';
} from "class-validator";
import { IsValidCoverage } from "../valids/is-valid-coverage-map";

export class CoverageMapClientDto {
// git仓库相关
@IsString()
@Matches(/^[a-f0-9]{40}$/i, { message: 'sha格式不正确' })
@IsNotEmpty({ message: 'sha 不能为空' })
@Matches(/^[a-f0-9]{40}$/i, { message: "sha格式不正确" })
@IsNotEmpty({ message: "sha 不能为空" })
sha: string;

@IsString()
@MinLength(1, { message: 'branch长度最小为1' })
@IsOptional({ message: 'branch 可以为空' })
@MinLength(1, { message: "branch长度最小为1" })
@IsOptional({ message: "branch 可以为空" })
branch: string;

// @IsString()
Expand All @@ -42,7 +42,7 @@ export class CoverageMapClientDto {
// key: string;

@IsString()
@IsNotEmpty({ message: 'projectID 不能为空' })
@IsNotEmpty({ message: "projectID 不能为空" })
projectID: string;

// // 单次 case 触发相关
Expand All @@ -53,11 +53,11 @@ export class CoverageMapClientDto {

// istanbul覆盖率相关
@IsString()
@MinLength(1, { message: 'reportID长度最小为1' })
@IsNotEmpty({ message: 'instrumentCwd不能为空' })
@MinLength(1, { message: "reportID长度最小为1" })
@IsNotEmpty({ message: "instrumentCwd不能为空" })
instrumentCwd: string;

@IsNotEmpty({ message: 'coverage不能为空' })
@IsNotEmpty({ message: "coverage不能为空" })
@Validate(IsValidCoverage)
coverage: any;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity('coveragedisk')
@Entity("coveragedisk")
export class CoveragediskEntity {
@PrimaryGeneratedColumn()
id: number;
Expand Down
28 changes: 14 additions & 14 deletions packages/canyon-collect/src/apps/collect/models/coverage.model.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
export const coverageObj = {
// id: require('cuid')(), // 假设这里有类似cuid的函数来生成唯一ID,需根据实际情况引入相应库
branch: '-',
compareTarget: '',
provider: '',
buildProvider: '',
buildID: '',
projectID: '',
sha: '',
reporter: '',
reportID: '',
covType: '',
branch: "-",
compareTarget: "",
provider: "",
buildProvider: "",
buildID: "",
projectID: "",
sha: "",
reporter: "",
reportID: "",
covType: "",
statementsTotal: 0,
statementsCovered: 0,
summary: '',
hit: '',
map: '',
instrumentCwd: '',
summary: "",
hit: "",
map: "",
instrumentCwd: "",
// createdAt: new Date(),
// updatedAt: new Date(),
};
Loading

0 comments on commit 6cc73f3

Please sign in to comment.