Skip to content

Commit

Permalink
feat(canyon-uploader): update
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Nov 11, 2024
1 parent decfd3d commit e2e3c64
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 59 deletions.
2 changes: 1 addition & 1 deletion tools/canyon-uploader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canyon-uploader",
"version": "0.0.1-beta.1",
"version": "0.0.1-beta.2",
"files": [
"bin",
"dist"
Expand Down
3 changes: 3 additions & 0 deletions tools/canyon-uploader/src/commands/hit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function hitCommand(params, options) {
console.log("hitCommand", "aasaaaaa");
}
3 changes: 3 additions & 0 deletions tools/canyon-uploader/src/commands/map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function mapCommand(params, options) {
console.log("mapCommand", "mapCommand");
}
112 changes: 54 additions & 58 deletions tools/canyon-uploader/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,85 +1,81 @@
import chalk from "chalk";
import { program } from "commander";
import { version } from "../package.json";

import { hitCommand } from "./commands/hit";
import { mapCommand } from "./commands/map";

const accent = chalk.greenBright;

async function crnAction(params: any, options: any): Promise<any>{
console.log('????')
return ['123']
}

/**
* * Program Default Configuration
*/
const CLI_BEFORE_ALL_TXT = `canyon: The ${accent(
"Canyon"
"Canyon",
)} CLI - Version ${version} (${accent(
"https://github.com/canyon-project/canyon"
"https://github.com/canyon-project/canyon",
)}) ${chalk.black.bold.bgYellowBright(" ALPHA ")} \n`;

const CLI_AFTER_ALL_TXT = `\nFor more help, head on to ${accent(
"https://github.com/canyon-project/canyon"
"https://github.com/canyon-project/canyon",
)}`;

program
.name("canyon")
.version(version, "-v, --version", "see the current version of canyon-cli")
.usage("[options or commands] arguments")
.addHelpText("beforeAll", CLI_BEFORE_ALL_TXT)
.addHelpText("after", CLI_AFTER_ALL_TXT)
.configureHelp({
optionTerm: (option) => accent(option.flags),
subcommandTerm: (cmd) => accent(cmd.name(), cmd.usage()),
argumentTerm: (arg) => accent(arg.name()),
})
.addHelpCommand(false)
.showHelpAfterError(true);

.name("canyon")
.version(
version,
"-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({
optionTerm: (option) => accent(option.flags),
subcommandTerm: (cmd) => accent(cmd.name(), cmd.usage()),
argumentTerm: (arg) => accent(arg.name()),
})
.addHelpCommand(false)
.showHelpAfterError(true);

/**
* * CLI Commands
* * CLI Commands with hit
*/

program
.command("crn")
.option(
"--dsn <dsn>",
"dsn of the canyon server"
)
.option(
"--reporter <reporter>",
"reporter auth token"
)
.option(
"--project_id <project_id>",
"id of the project"
)
.option("--commit_sha <commit_sha>", "commit sha of the project")
.option("--branch <branch>", "branch of the project")
.option("--buildId <buildId>", "buildId of the project")
.option("--report_id <report_id>", "report id of the case")
.option("--gitlab_url <gitlab_url>", "gitlab url of the project")
.option("--payload_path <payload_path>", "payload_path")
.option("--appid <appid>", "appid")
.option("--module <module>", "module")
.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 crnAction(params, options));
.command("hit")
.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 hitCommand(params, options));

/**
* * CLI Commands with map
*/
program
.command("map")
.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));

export const cli = async (args: string[]) => {
try {
// console.log("???", chalk.greenBright("canyon-cli"));
await program.parseAsync(args);
} catch (e) {}
} catch (e) {
console.error(e);
}
};

// console.log('canyon: xtaro config/index.js updated successfully.');
7 changes: 7 additions & 0 deletions tools/canyon-uploader/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"esModuleInterop": true,
},
"include": ["src"]
}

0 comments on commit e2e3c64

Please sign in to comment.