@canyonjs/cli 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -1,23 +1,9 @@
1
- # Rslib project
1
+ 代办项
2
2
 
3
- ## Setup
3
+ upload
4
+ - [x] 对于init json,先尝试找input SourceMap
4
5
 
5
- Install the dependencies:
6
6
 
7
- ```bash
8
- pnpm install
9
- ```
7
+ 参考 https://docs.hoppscotch.io/documentation/clients/cli/overview#hopp-test
10
8
 
11
- ## Get started
12
-
13
- Build the library:
14
-
15
- ```bash
16
- pnpm build
17
- ```
18
-
19
- Build the library in watch mode:
20
-
21
- ```bash
22
- pnpm dev
23
- ```
9
+ md.canyonjs.io 玩一下
@@ -0,0 +1 @@
1
+ export declare function mapCommand(params: any, options: any): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const cli: () => void;
1
+ export declare const cli: (args: string[]) => Promise<void>;
package/dist/index.js CHANGED
@@ -1,4 +1,55 @@
1
- const cli = ()=>{
2
- console.log('cli');
1
+ import chalk from "chalk";
2
+ import { program } from "commander";
3
+ import node_fs from "node:fs";
4
+ import node_path from "node:path";
5
+ import axios from "axios";
6
+ import { log } from "node:console";
7
+ var package_namespaceObject = {
8
+ rE: "1.0.1"
9
+ };
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"));
14
+ let data = {};
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");
17
+ data = {
18
+ ...data,
19
+ ...JSON.parse(fileCoverageString)
20
+ };
21
+ }
22
+ const p = {
23
+ dsn,
24
+ provider: provider || 'gitlab',
25
+ repoID: repoID || process.env.CI_PROJECT_ID,
26
+ sha: sha || process.env.CI_COMMIT_SHA,
27
+ instrumentCwd: process.cwd(),
28
+ reportID: 'initial_coverage_data',
29
+ reportProvider: 'ci',
30
+ buildTarget: '',
31
+ coverage: Object.keys(data)
32
+ };
33
+ log(p);
34
+ await axios.post(dsn, {
35
+ ...p,
36
+ coverage: data
37
+ });
38
+ }
39
+ 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({
43
+ optionTerm: (option)=>accent(option.flags),
44
+ subcommandTerm: (cmd)=>accent(cmd.name(), cmd.usage()),
45
+ argumentTerm: (arg)=>accent(arg.name())
46
+ }).showHelpAfterError(true);
47
+ program.command("upload").option("--dsn <dsn>", "dsn 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
+ const cli = async (args)=>{
49
+ try {
50
+ await program.parseAsync(args);
51
+ } catch (e) {
52
+ console.error(e);
53
+ }
3
54
  };
4
55
  export { cli };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canyonjs/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -23,6 +23,11 @@
23
23
  "@types/node": "^22.18.10",
24
24
  "typescript": "^5.9.3"
25
25
  },
26
+ "dependencies": {
27
+ "axios": "^1.12.2",
28
+ "chalk": "^5.6.2",
29
+ "commander": "^14.0.1"
30
+ },
26
31
  "scripts": {
27
32
  "build": "rslib build",
28
33
  "check": "biome check --write",