-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Allen Zhang (张涛)
committed
Nov 11, 2024
1 parent
decfd3d
commit e2e3c64
Showing
5 changed files
with
68 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export async function hitCommand(params, options) { | ||
console.log("hitCommand", "aasaaaaa"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export async function mapCommand(params, options) { | ||
console.log("mapCommand", "mapCommand"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
}, | ||
"include": ["src"] | ||
} |