Skip to content

Commit

Permalink
feat(canyon-uploader): update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 7, 2024
1 parent 4e9bf0b commit 18f1916
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 82 deletions.
9 changes: 5 additions & 4 deletions tools/canyon-uploader/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "canyon-uploader",
"version": "0.0.1",
"type": "module",
"version": "0.0.1-beta.1",
"files": [
"bin",
"dist"
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
}
})
155 changes: 78 additions & 77 deletions tools/canyon-uploader/src/main.ts
Original file line number Diff line number Diff line change
@@ -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<any>{
// 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>",
// "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));
//
import { program } from "commander";
import { version } from "../package.json";


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"
)} 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>",
"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));

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) {}
};

Expand Down

0 comments on commit 18f1916

Please sign in to comment.