@canyonjs/cli 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { program } from "commander";
|
|
3
|
+
import { log } from "node:console";
|
|
3
4
|
import node_fs from "node:fs";
|
|
4
5
|
import node_path from "node:path";
|
|
5
6
|
import axios from "axios";
|
|
6
|
-
import { log } from "node:console";
|
|
7
7
|
var package_namespaceObject = {
|
|
8
|
-
rE: "1.0.
|
|
8
|
+
rE: "1.0.18"
|
|
9
9
|
};
|
|
10
10
|
function mergeNumberMaps(a = {}, b = {}) {
|
|
11
11
|
const result = {
|
|
@@ -61,14 +61,20 @@ function mergeCoverageMaps(target = {}, source = {}) {
|
|
|
61
61
|
return out;
|
|
62
62
|
}
|
|
63
63
|
async function mapCommand(params, options) {
|
|
64
|
-
const { dsn, repo_id: repoID, sha
|
|
64
|
+
const { dsn, repo_id: repoID, sha, provider, build_target, debug, instrument_cwd, filter } = params;
|
|
65
65
|
if (!node_fs.existsSync(node_path.resolve(process.cwd(), '.canyon_output'))) return void log('不存在');
|
|
66
66
|
const files = node_fs.readdirSync(node_path.resolve(process.cwd(), '.canyon_output'));
|
|
67
67
|
let data = {};
|
|
68
68
|
for(let i = 0; i < files.length; i++){
|
|
69
69
|
const fileCoverageString = node_fs.readFileSync(node_path.resolve(process.cwd(), '.canyon_output', files[i]), 'utf-8');
|
|
70
70
|
const fileCoverage = JSON.parse(fileCoverageString);
|
|
71
|
-
|
|
71
|
+
let toMerge = fileCoverage;
|
|
72
|
+
if (filter && 'string' == typeof filter) {
|
|
73
|
+
const filteredEntries = Object.entries(fileCoverage).filter(([filePath])=>filePath.includes(filter));
|
|
74
|
+
if (0 === filteredEntries.length) continue;
|
|
75
|
+
toMerge = Object.fromEntries(filteredEntries);
|
|
76
|
+
}
|
|
77
|
+
data = mergeCoverageMaps(data, toMerge);
|
|
72
78
|
}
|
|
73
79
|
const p = {
|
|
74
80
|
dsn,
|
|
@@ -98,7 +104,7 @@ program.name('canyon').version(package_namespaceObject.rE, '-v, --version', 'see
|
|
|
98
104
|
subcommandTerm: (cmd)=>accent(cmd.name(), cmd.usage()),
|
|
99
105
|
argumentTerm: (arg)=>accent(arg.name())
|
|
100
106
|
}).showHelpAfterError(true);
|
|
101
|
-
program.command('upload').option('--debug <dsn>', 'debug').option('--dsn <dsn>', 'dsn of the canyon server').option('--repo_id <repo_id>', 'repo id of the canyon server').option('--instrument_cwd <instrument_cwd>', 'instrument cwd of the canyon server').option('--sha <sha>', 'sha of the canyon server').option('--branch <branch>', 'branch of the canyon server').option('--provider <provider>', 'provider of the canyon server').option('--build_target <build_target>', 'build target of the canyon server').option('--coverage <coverage>', 'coverage of the canyon server').allowExcessArguments(false).allowUnknownOption(false).description('modify react native project code to adapt to canyon').addHelpText('after', `\nFor help, head on to ${accent('https://github.com/canyon-project/canyon')}`).action(async (params, options)=>await mapCommand(params, options));
|
|
107
|
+
program.command('upload').option('--debug <dsn>', 'debug').option('--dsn <dsn>', 'dsn of the canyon server').option('--repo_id <repo_id>', 'repo id of the canyon server').option('--filter <filter>', '仅合并路径包含该子串的文件覆盖率').option('--instrument_cwd <instrument_cwd>', 'instrument cwd of the canyon server').option('--sha <sha>', 'sha of the canyon server').option('--branch <branch>', 'branch of the canyon server').option('--provider <provider>', 'provider of the canyon server').option('--build_target <build_target>', 'build target of the canyon server').option('--coverage <coverage>', 'coverage of the canyon server').allowExcessArguments(false).allowUnknownOption(false).description('modify react native project code to adapt to canyon').addHelpText('after', `\nFor help, head on to ${accent('https://github.com/canyon-project/canyon')}`).action(async (params, options)=>await mapCommand(params, options));
|
|
102
108
|
const cli = async (args)=>{
|
|
103
109
|
try {
|
|
104
110
|
await program.parseAsync(args);
|