@canyonjs/cli 1.0.2 → 1.0.5

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 (3) hide show
  1. package/README.md +0 -9
  2. package/dist/index.js +18 -12
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -1,9 +0,0 @@
1
- 代办项
2
-
3
- upload
4
- - [x] 对于init json,先尝试找input SourceMap
5
-
6
-
7
- 参考 https://docs.hoppscotch.io/documentation/clients/cli/overview#hopp-test
8
-
9
- md.canyonjs.io 玩一下
package/dist/index.js CHANGED
@@ -5,18 +5,25 @@ import node_path from "node:path";
5
5
  import axios from "axios";
6
6
  import { log } from "node:console";
7
7
  var package_namespaceObject = {
8
- rE: "1.0.2"
8
+ rE: "1.0.5"
9
9
  };
10
10
  async function mapCommand(params, options) {
11
- const { dsn, repo_id: repoID, commit_sha: sha, provider } = params;
12
- if (!node_fs.existsSync(node_path.resolve(process.cwd(), ".canyon_output"))) return void log('不存在');
13
- const files = node_fs.readdirSync(node_path.resolve(process.cwd(), ".canyon_output"));
11
+ const { dsn, repo_id: repoID, commit_sha: sha, provider, build_target } = params;
12
+ if (!node_fs.existsSync(node_path.resolve(process.cwd(), '.canyon_output'))) return void log('不存在');
13
+ const files = node_fs.readdirSync(node_path.resolve(process.cwd(), '.canyon_output'));
14
14
  let data = {};
15
15
  for(let i = 0; i < files.length; i++){
16
- const fileCoverageString = node_fs.readFileSync(node_path.resolve(process.cwd(), ".canyon_output", files[i]), "utf-8");
16
+ const fileCoverageString = node_fs.readFileSync(node_path.resolve(process.cwd(), '.canyon_output', files[i]), 'utf-8');
17
+ const fileCoverage = JSON.parse(fileCoverageString);
18
+ if (files[i].includes('-init-')) try {
19
+ const pathString = node_fs.readFileSync(node_path.resolve(Object.keys(fileCoverage)[0] + '.map'), 'utf-8');
20
+ Object.entries(fileCoverage).forEach((item)=>{
21
+ item[1].inputSourceMap = JSON.parse(pathString);
22
+ });
23
+ } catch (e) {}
17
24
  data = {
18
25
  ...data,
19
- ...JSON.parse(fileCoverageString)
26
+ ...fileCoverage
20
27
  };
21
28
  }
22
29
  const p = {
@@ -27,24 +34,23 @@ async function mapCommand(params, options) {
27
34
  instrumentCwd: process.cwd(),
28
35
  reportID: 'initial_coverage_data',
29
36
  reportProvider: 'ci',
30
- buildTarget: '',
37
+ buildTarget: build_target || '',
31
38
  coverage: Object.keys(data)
32
39
  };
33
- log(p);
34
40
  await axios.post(dsn, {
35
41
  ...p,
36
42
  coverage: data
37
43
  });
38
44
  }
39
45
  const accent = chalk.greenBright;
40
- const CLI_BEFORE_ALL_TXT = `canyon: The ${accent("Canyon")} CLI - Version ${package_namespaceObject.rE} (${accent("https://github.com/canyon-project/canyon")}) ${chalk.black.bold.bgYellowBright(" ALPHA ")} \n`;
41
- const CLI_AFTER_ALL_TXT = `\nFor more help, head on to ${accent("https://github.com/canyon-project/canyon")}`;
42
- program.name("canyon").version(package_namespaceObject.rE, "-v, --version", "see the current version of canyon-uploader").usage("[options or commands] arguments").addHelpText("beforeAll", CLI_BEFORE_ALL_TXT).addHelpText("after", CLI_AFTER_ALL_TXT).configureHelp({
46
+ const CLI_BEFORE_ALL_TXT = `canyon: The ${accent('Canyon')} CLI - Version ${package_namespaceObject.rE} (${accent('https://github.com/canyon-project/canyon')}) ${chalk.black.bold.bgYellowBright(' ALPHA ')} \n`;
47
+ const CLI_AFTER_ALL_TXT = `\nFor more help, head on to ${accent('https://github.com/canyon-project/canyon')}`;
48
+ program.name('canyon').version(package_namespaceObject.rE, '-v, --version', 'see the current version of canyon-uploader').usage('[options or commands] arguments').addHelpText('beforeAll', CLI_BEFORE_ALL_TXT).addHelpText('after', CLI_AFTER_ALL_TXT).configureHelp({
43
49
  optionTerm: (option)=>accent(option.flags),
44
50
  subcommandTerm: (cmd)=>accent(cmd.name(), cmd.usage()),
45
51
  argumentTerm: (arg)=>accent(arg.name())
46
52
  }).showHelpAfterError(true);
47
- program.command("upload").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));
53
+ program.command('upload').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));
48
54
  const cli = async (args)=>{
49
55
  try {
50
56
  await program.parseAsync(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canyonjs/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "scripts": {
32
32
  "build": "rslib build",
33
+ "my-test": "npm run build && node ./bin/canyon upload",
33
34
  "check": "biome check --write",
34
35
  "dev": "rslib build --watch",
35
36
  "format": "biome format --write",