From 18f1916e1ac6b524298304c3b42dfb6997d79e3c Mon Sep 17 00:00:00 2001 From: Allen Zhang <37892968+zhangtao25@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:52:09 +0800 Subject: [PATCH] feat(canyon-uploader): update --- tools/canyon-uploader/package.json | 9 +- ...{rolldown.config.js => rolldown.config.ts} | 8 +- tools/canyon-uploader/src/main.ts | 155 +++++++++--------- 3 files changed, 90 insertions(+), 82 deletions(-) rename tools/canyon-uploader/{rolldown.config.js => rolldown.config.ts} (54%) diff --git a/tools/canyon-uploader/package.json b/tools/canyon-uploader/package.json index 4d5d87d1..d18da6ca 100644 --- a/tools/canyon-uploader/package.json +++ b/tools/canyon-uploader/package.json @@ -1,7 +1,6 @@ { "name": "canyon-uploader", - "version": "0.0.1", - "type": "module", + "version": "0.0.1-beta.1", "files": [ "bin", "dist" @@ -10,12 +9,14 @@ "canyon-uploader": "bin/canyon-uploader" }, "scripts": { - "build": "rolldown -c", + "build": "swc ./rolldown.config.ts -o dist/rolldown.config.mjs && rolldown -c dist/rolldown.config.mjs", "format": "biome check --write --unsafe ./src", - "prepublishOnly": "rolldown -c" + "prepublishOnly": "npm run build" }, "devDependencies": { "@biomejs/biome": "1.9.4", + "@swc/cli": "0.4.1-nightly.20240914", + "@swc/core": "1.7.40", "rolldown": "nightly" }, "dependencies": { diff --git a/tools/canyon-uploader/rolldown.config.js b/tools/canyon-uploader/rolldown.config.ts similarity index 54% rename from tools/canyon-uploader/rolldown.config.js rename to tools/canyon-uploader/rolldown.config.ts index 91fbfbab..d230daa0 100644 --- a/tools/canyon-uploader/rolldown.config.js +++ b/tools/canyon-uploader/rolldown.config.ts @@ -1,6 +1,12 @@ import { defineConfig } from 'rolldown' - +const obj:{name:number} = { + name:1 +} +console.log(obj.name) export default defineConfig({ input: 'src/main.ts', platform: 'node', + output:{ + format:'commonjs' + } }) diff --git a/tools/canyon-uploader/src/main.ts b/tools/canyon-uploader/src/main.ts index fc2dcfd3..6871b53f 100644 --- a/tools/canyon-uploader/src/main.ts +++ b/tools/canyon-uploader/src/main.ts @@ -1,83 +1,84 @@ import chalk from "chalk"; -// import { program } from "commander"; -// import { version } from "../package.json"; -// -// -// const accent = chalk.greenBright; -// -// async function crnAction(params: any, options: any): Promise{ -// console.log('????') -// } -// -// /** -// * * Program Default Configuration -// */ -// const CLI_BEFORE_ALL_TXT = `canyon: The ${accent( -// "Canyon" -// )} CLI - Version ${version} (${accent( -// "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" -// )}`; -// -// 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); -// -// -// /** -// * * CLI Commands -// */ -// -// 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)); -// +import { program } from "commander"; +import { version } from "../package.json"; + + +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" +)} CLI - Version ${version} (${accent( + "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" +)}`; + +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); + + +/** + * * CLI Commands + */ + +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)); + export const cli = async (args: string[]) => { try { - console.log("???", chalk.greenBright("canyon-cli")); - // await program.parseAsync(args); + // console.log("???", chalk.greenBright("canyon-cli")); + await program.parseAsync(args); } catch (e) {} };