@canyonjs/cli 1.0.25 → 1.0.26

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.
Files changed (2) hide show
  1. package/dist/index.js +15 -4
  2. package/package.json +3 -3
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
+ import { error, log } from "node:console";
4
4
  import node_fs from "node:fs";
5
5
  import node_path from "node:path";
6
6
  import axios from "axios";
7
7
  var package_namespaceObject = {
8
- rE: "1.0.25"
8
+ rE: "1.0.26"
9
9
  };
10
10
  function mergeNumberMaps(a = {}, b = {}) {
11
11
  const result = {
@@ -62,7 +62,7 @@ function mergeCoverageMaps(target = {}, source = {}) {
62
62
  }
63
63
  async function mapCommand(params, options) {
64
64
  log('Current working directory:', process.cwd());
65
- const { dsn, repo_id: repoID, sha, provider, build_target, debug, instrument_cwd, filter } = params;
65
+ const { dsn, repo_id: repoID, sha, provider, build_target, debug, instrument_cwd, filter, scene } = params;
66
66
  if (!node_fs.existsSync(node_path.resolve(process.cwd(), '.canyon_output'))) return void log('不存在');
67
67
  const files = node_fs.readdirSync(node_path.resolve(process.cwd(), '.canyon_output'));
68
68
  let data = {};
@@ -82,6 +82,14 @@ async function mapCommand(params, options) {
82
82
  const env_branch = process.env.CI_COMMIT_BRANCH;
83
83
  const env_buildID = process.env.CI_JOB_ID;
84
84
  const env_buildProvider = 'gitlab_runner';
85
+ let sceneMap;
86
+ if (scene) try {
87
+ sceneMap = 'string' == typeof scene ? JSON.parse(scene) : scene;
88
+ if ('object' != typeof sceneMap || Array.isArray(sceneMap)) throw new Error('scene must be a valid JSON object');
89
+ } catch (e) {
90
+ error(`Failed to parse scene parameter: ${e}. Expected JSON format like '{"key1":"value1","key2":"value2"}'`);
91
+ return;
92
+ }
85
93
  const p = {
86
94
  dsn,
87
95
  provider: provider || 'gitlab',
@@ -96,6 +104,9 @@ async function mapCommand(params, options) {
96
104
  buildProvider: env_buildProvider,
97
105
  buildID: env_buildID,
98
106
  branch: env_branch
107
+ },
108
+ ...sceneMap && {
109
+ scene: sceneMap
99
110
  }
100
111
  };
101
112
  if ('true' === debug) log(p);
@@ -119,7 +130,7 @@ program.name('canyon').version(package_namespaceObject.rE, '-v, --version', 'see
119
130
  subcommandTerm: (cmd)=>accent(cmd.name(), cmd.usage()),
120
131
  argumentTerm: (arg)=>accent(arg.name())
121
132
  }).showHelpAfterError(true);
122
- 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));
133
+ 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').option('--scene <scene>', 'scene map in JSON format, e.g. \'{"key1":"value1","key2":"value2"}\'').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));
123
134
  const cli = async (args)=>{
124
135
  try {
125
136
  await program.parseAsync(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canyonjs/cli",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "scripts": {
31
31
  "build": "rslib build",
32
- "my-test": "npm run build && node ./bin/canyon.js upload --debug=true",
33
- "dev": "rslib build --watch"
32
+ "my-test": "npm run build && node ./bin/canyon.js upload --debug=true --scene='{\"key1\":\"value1\",\"key2\":\"value2\"}'",
33
+ "dev-cli": "rslib build --watch"
34
34
  }
35
35
  }