diff --git a/tools/canyon-uploader/package.json b/tools/canyon-uploader/package.json index d81c56e2..677006cf 100644 --- a/tools/canyon-uploader/package.json +++ b/tools/canyon-uploader/package.json @@ -1,6 +1,6 @@ { "name": "canyon-uploader", - "version": "0.0.1-beta.5", + "version": "0.0.1-beta.6", "files": [ "bin", "dist" diff --git a/tools/canyon-uploader/src/commands/hit.ts b/tools/canyon-uploader/src/commands/hit.ts index e199daee..1e2364a2 100644 --- a/tools/canyon-uploader/src/commands/hit.ts +++ b/tools/canyon-uploader/src/commands/hit.ts @@ -3,7 +3,7 @@ import path from "node:path"; import * as process from "node:process"; import axios from "axios"; export async function hitCommand(params, options) { - const { dsn, project_id:projectID, commit_sha:sha } = options; + const { dsn, project_id:projectID, commit_sha:sha } = params; const files = fs.readdirSync(path.resolve(process.cwd(), ".canyon_output")); let data = {}; for (let i = 0; i < files.length; i++) { @@ -22,5 +22,5 @@ export async function hitCommand(params, options) { sha, instrumentCwd: process.cwd(), coverage: JSON.stringify(data), - }, {}); + }); } diff --git a/tools/canyon-uploader/src/commands/map.ts b/tools/canyon-uploader/src/commands/map.ts index c14f78f0..d781a536 100644 --- a/tools/canyon-uploader/src/commands/map.ts +++ b/tools/canyon-uploader/src/commands/map.ts @@ -1,3 +1,26 @@ +import fs from "node:fs"; +import path from "node:path"; +import * as process from "node:process"; +import axios from "axios"; export async function mapCommand(params, options) { - console.log("mapCommand", "mapCommand"); + const { dsn, project_id:projectID, commit_sha:sha } = params; + console.log(dsn, projectID, sha); + const files = fs.readdirSync(path.resolve(process.cwd(), ".canyon_output")); + let data = {}; + for (let i = 0; i < files.length; i++) { + const fileCoverageString = fs.readFileSync( + path.resolve(process.cwd(), ".canyon_output", files[i]), + "utf-8", + ); + data = { + ...data, + ...JSON.parse(fileCoverageString), + }; + } + await axios.post(dsn, { + projectID: projectID||process.env.CI_COMMIT_SHA, + sha: sha||process.env.CI_PROJECT_ID, + instrumentCwd: process.cwd(), + coverage: JSON.stringify(data), + }); }