diff --git a/tools/canyon-uploader/package.json b/tools/canyon-uploader/package.json index d18da6ca..f87a2f82 100644 --- a/tools/canyon-uploader/package.json +++ b/tools/canyon-uploader/package.json @@ -1,6 +1,6 @@ { "name": "canyon-uploader", - "version": "0.0.1-beta.1", + "version": "0.0.1-beta.2", "files": [ "bin", "dist" diff --git a/tools/canyon-uploader/src/commands/hit.ts b/tools/canyon-uploader/src/commands/hit.ts new file mode 100644 index 00000000..a4f41e63 --- /dev/null +++ b/tools/canyon-uploader/src/commands/hit.ts @@ -0,0 +1,3 @@ +export async function hitCommand(params, options) { + console.log("hitCommand", "aasaaaaa"); +} diff --git a/tools/canyon-uploader/src/commands/map.ts b/tools/canyon-uploader/src/commands/map.ts new file mode 100644 index 00000000..c14f78f0 --- /dev/null +++ b/tools/canyon-uploader/src/commands/map.ts @@ -0,0 +1,3 @@ +export async function mapCommand(params, options) { + console.log("mapCommand", "mapCommand"); +} diff --git a/tools/canyon-uploader/src/main.ts b/tools/canyon-uploader/src/main.ts index 6871b53f..1e08906e 100644 --- a/tools/canyon-uploader/src/main.ts +++ b/tools/canyon-uploader/src/main.ts @@ -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{ - 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 of the canyon server" - ) - .option( - "--reporter ", - "reporter auth token" - ) - .option( - "--project_id ", - "id of the project" - ) - .option("--commit_sha ", "commit sha of the project") - .option("--branch ", "branch of the project") - .option("--buildId ", "buildId of the project") - .option("--report_id ", "report id of the case") - .option("--gitlab_url ", "gitlab url of the project") - .option("--payload_path ", "payload_path") - .option("--appid ", "appid") - .option("--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 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 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.'); diff --git a/tools/canyon-uploader/tsconfig.json b/tools/canyon-uploader/tsconfig.json new file mode 100644 index 00000000..d3425075 --- /dev/null +++ b/tools/canyon-uploader/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "resolveJsonModule": true, + "esModuleInterop": true, + }, + "include": ["src"] +}