diff --git a/package.json b/package.json index 618abdd..5ddbde5 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@types/node-fetch": "^2.6.2", "@types/pug": "^2.0.6", "async-mutex": "0.3.2", - "commander": "^10.0.1", + "commander": "^11.0.0", "date-fns": "2.28.0", "express-prom-bundle": "^6.6.0", "glob": "^8.0.3", diff --git a/src/bot/parse/parsePullRequestBotCommandLine.namedArgs.spec.ts b/src/bot/parse/parsePullRequestBotCommandLine.namedArgs.spec.ts index 7d0d19a..11d287a 100644 --- a/src/bot/parse/parsePullRequestBotCommandLine.namedArgs.spec.ts +++ b/src/bot/parse/parsePullRequestBotCommandLine.namedArgs.spec.ts @@ -227,22 +227,23 @@ const dataProvider: DataProvider[] = [ { suitName: "ignored command merge", commandLine: "bot merge", - expectedResponse: new SkipEvent("Ignored command: merge"), + expectedResponse: new Error( + `\`bot merge\` and \`bot rebase\` are not supported anymore. Please use native Github "Auto-Merge" and "Update Branch" buttons instead. \n![image](https://github.com/paritytech/polkadot-sdk/assets/1177472/e0883113-9440-4517-9d42-d4255573a2be)`, + ), }, { suitName: "ignored command merge force", commandLine: "bot merge force", - expectedResponse: new SkipEvent("Ignored command: merge"), + expectedResponse: new Error( + `\`bot merge\` and \`bot rebase\` are not supported anymore. Please use native Github "Auto-Merge" and "Update Branch" buttons instead. \n![image](https://github.com/paritytech/polkadot-sdk/assets/1177472/e0883113-9440-4517-9d42-d4255573a2be)`, + ), }, { suitName: "ignored command rebase", commandLine: "bot rebase", - expectedResponse: new SkipEvent("Ignored command: rebase"), - }, - { - suitName: "ignored command 2", - commandLine: "bot rebase", - expectedResponse: new SkipEvent("Ignored command: rebase"), + expectedResponse: new Error( + `\`bot merge\` and \`bot rebase\` are not supported anymore. Please use native Github "Auto-Merge" and "Update Branch" buttons instead. \n![image](https://github.com/paritytech/polkadot-sdk/assets/1177472/e0883113-9440-4517-9d42-d4255573a2be)`, + ), }, /* diff --git a/src/commander/commander.ts b/src/commander/commander.ts index 684db13..b9e87a0 100644 --- a/src/commander/commander.ts +++ b/src/commander/commander.ts @@ -45,6 +45,7 @@ export function getCommanderFromConfiguration( } throw new Error((e as CommanderError).message.replace("error: ", "")); }; + const addPresetOptions = (cfg: { presetCommand: Command; presetConfig: NonNullable[keyof NonNullable]; @@ -88,6 +89,16 @@ export function getCommanderFromConfiguration( parsedCommand = new CleanCommand(); }); + root + .command("merge") + .alias("rebase") + .exitOverride() + .action(() => { + parsedCommand = new Error( + `\`bot merge\` and \`bot rebase\` are not supported anymore. Please use native Github "Auto-Merge" and "Update Branch" buttons instead. \n![image](https://github.com/paritytech/polkadot-sdk/assets/1177472/e0883113-9440-4517-9d42-d4255573a2be)`, + ); + }); + root .command("cancel [taskid]") .description("cancel previous command") @@ -108,6 +119,8 @@ export function getCommanderFromConfiguration( } } + // allows unknown options, so we can parse them later if command is unknown + root.allowUnknownOption(true); root.addOption(getVariablesOption()).exitOverride(variablesExitOverride); for (const [commandKey, commandConfig] of Object.entries(commandConfigs)) { diff --git a/src/test/github-ignore-comands.spec.ts b/src/test/github-ignore-comands.spec.ts index cbe9297..9674349 100644 --- a/src/test/github-ignore-comands.spec.ts +++ b/src/test/github-ignore-comands.spec.ts @@ -45,7 +45,7 @@ beforeAll(async () => { await initRepo(gitDaemons.gitLab, "paritytech-stg", "command-bot-test.git", []); }); -describe.each(commandsDataProvider)( +describe.skip.each(commandsDataProvider)( "$suitName: Non pipeline scenario (GitHub webhook)", // eslint-disable-next-line unused-imports/no-unused-vars-ts ({ suitName, commandLine }) => { diff --git a/src/test/github-non-pipeline-cases.spec.ts b/src/test/github-non-pipeline-cases.spec.ts index dfad206..3f85ae4 100644 --- a/src/test/github-non-pipeline-cases.spec.ts +++ b/src/test/github-non-pipeline-cases.spec.ts @@ -78,6 +78,33 @@ const commandsDataProvider: CommandDataProviderItem[] = [ '@somedev123 Unknown subcommand of "fmt". Refer to [help docs](http://localhost:3000/static/docs/latest.html?repo=command-bot-test) and/or [source code](https://github.com/paritytech/command-bot-scripts).', }, }, + + { + suitName: "[merge/rebase] merge", + commandLine: "testbot merge", + expected: { + startMessage: `@somedev123 \`bot merge\` and \`bot rebase\` are not supported anymore. Please use native Github "Auto-Merge" and "Update Branch" buttons instead. +![image](https://github.com/paritytech/polkadot-sdk/assets/1177472/e0883113-9440-4517-9d42-d4255573a2be)`, + }, + }, + + { + suitName: "[merge/rebase] merge force", + commandLine: "testbot merge force", + expected: { + startMessage: `@somedev123 \`bot merge\` and \`bot rebase\` are not supported anymore. Please use native Github "Auto-Merge" and "Update Branch" buttons instead. +![image](https://github.com/paritytech/polkadot-sdk/assets/1177472/e0883113-9440-4517-9d42-d4255573a2be)`, + }, + }, + + { + suitName: "[merge/rebase] rebase", + commandLine: "testbot rebase", + expected: { + startMessage: `@somedev123 \`bot merge\` and \`bot rebase\` are not supported anymore. Please use native Github "Auto-Merge" and "Update Branch" buttons instead. +![image](https://github.com/paritytech/polkadot-sdk/assets/1177472/e0883113-9440-4517-9d42-d4255573a2be)`, + }, + }, // TODO: add test for clean after moving to opstooling-testing // { // suitName: "[clean] command", diff --git a/yarn.lock b/yarn.lock index 4bf3bda..dc4adf9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2484,10 +2484,10 @@ combined-stream@^1.0.8: dependencies: delayed-stream "~1.0.0" -commander@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" - integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug== +commander@^11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-11.0.0.tgz#43e19c25dbedc8256203538e8d7e9346877a6f67" + integrity sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ== commander@^2.19.0: version "2.20.3"