@canyonjs/cli 1.0.15 → 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/bin/canyon.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ // * The entry point of the CLI
3
+ import('../dist/index.js').then((m) => m.cli(process.argv));
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.15"
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: sha, provider, build_target, debug, instrument_cwd } = params;
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
- data = mergeCoverageMaps(data, fileCoverage);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canyonjs/cli",
3
- "version": "1.0.15",
3
+ "version": "1.0.18",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -14,7 +14,7 @@
14
14
  "bin"
15
15
  ],
16
16
  "bin": {
17
- "canyon": "bin/canyon"
17
+ "canyon": "bin/canyon.js"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@biomejs/biome": "2.2.3",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "scripts": {
32
32
  "build": "rslib build",
33
- "my-test": "npm run build && node ./bin/canyon upload",
33
+ "my-test": "npm run build && node ./bin/canyon.js upload",
34
34
  "check": "biome check --write",
35
35
  "dev": "rslib build --watch",
36
36
  "format": "biome format --write",
package/bin/canyon DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- // * The entry point of the CLI
3
- import('../dist/index.js').then(m => m.cli(process.argv));