From 4cc42d3737996442780778d0d6f4cbcd62bacd0b Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 30 May 2024 15:08:57 +0200 Subject: [PATCH 01/10] index.ts Added -nc 'no credentials' feature to skip asking for credential, I also modified -p options so if the first option is '' it will skip asking for plugins. this update aims at easier testing as well as faster creation of templates. --- packages/create-robo/src/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/create-robo/src/index.ts b/packages/create-robo/src/index.ts index 787a2f10..e265d6a9 100644 --- a/packages/create-robo/src/index.ts +++ b/packages/create-robo/src/index.ts @@ -24,6 +24,7 @@ export interface CommandOptions { verbose?: boolean roboVersion?: string update?: boolean + noCreds?: boolean } new Command('create-robo ') @@ -40,6 +41,7 @@ new Command('create-robo ') .option('-v --verbose', 'print more information for debugging') .option('-rv, --robo-version ', 'specify a Robo.js version to use') .option('-k, --kit ', 'choose a kit to start off with your Robo') + .option('-nc, --no-creds', 'Skips asking for the credentials') .action(async (options: CommandOptions, { args }) => { logger({ level: options.verbose ? 'debug' : 'info' @@ -156,11 +158,15 @@ new Command('create-robo ') } // Want some plugins? - await robo.plugins() + if (options.plugins !== undefined && options.plugins.length > 0 && options.plugins[0] === '') { + } else { + await robo.plugins() + } // Ask the user for their Discord credentials (token and client ID) and store them for later use // Skip this step if the user is creating a plugin - if (!robo.isPlugin) { + // + if (!robo.isPlugin && options.noCreds) { logger.debug(`Asking for Discord credentials...`) await robo.askForDiscordCredentials() } From 62873cfdf272da03e17488803ab6f7b1f7e49ba2 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 30 May 2024 15:12:40 +0200 Subject: [PATCH 02/10] update --- packages/create-robo/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/create-robo/src/index.ts b/packages/create-robo/src/index.ts index e265d6a9..b3ce09e6 100644 --- a/packages/create-robo/src/index.ts +++ b/packages/create-robo/src/index.ts @@ -158,7 +158,8 @@ new Command('create-robo ') } // Want some plugins? - if (options.plugins !== undefined && options.plugins.length > 0 && options.plugins[0] === '') { + // if there are plugins specified with the command we skip asking for more. + if (options.plugins !== undefined && options.plugins.length > 0) { } else { await robo.plugins() } From 745326a906449ad3ff9fcde63e4d3475d2fc8f82 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 30 May 2024 19:55:36 +0200 Subject: [PATCH 03/10] chore(index.ts): negated if to replace empty scope --- packages/create-robo/src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/create-robo/src/index.ts b/packages/create-robo/src/index.ts index b3ce09e6..3178fe30 100644 --- a/packages/create-robo/src/index.ts +++ b/packages/create-robo/src/index.ts @@ -159,8 +159,7 @@ new Command('create-robo ') // Want some plugins? // if there are plugins specified with the command we skip asking for more. - if (options.plugins !== undefined && options.plugins.length > 0) { - } else { + if (options.plugins === undefined && options.plugins.length <= 0) { await robo.plugins() } From 4039563ca1160a30558622637db2fada0ba27ba8 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 30 May 2024 19:56:46 +0200 Subject: [PATCH 04/10] oopsy it was not workey --- packages/create-robo/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-robo/src/index.ts b/packages/create-robo/src/index.ts index 3178fe30..43815c03 100644 --- a/packages/create-robo/src/index.ts +++ b/packages/create-robo/src/index.ts @@ -159,7 +159,7 @@ new Command('create-robo ') // Want some plugins? // if there are plugins specified with the command we skip asking for more. - if (options.plugins === undefined && options.plugins.length <= 0) { + if (options.plugins === undefined || options.plugins.length <= 0) { await robo.plugins() } From 5e782601ce9d4efe17a99cd04ee18a67518a7ae8 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 31 May 2024 18:31:47 +0200 Subject: [PATCH 05/10] changeset --- .changeset/kind-goats-heal.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/kind-goats-heal.md diff --git a/.changeset/kind-goats-heal.md b/.changeset/kind-goats-heal.md new file mode 100644 index 00000000..2ddecf50 --- /dev/null +++ b/.changeset/kind-goats-heal.md @@ -0,0 +1,5 @@ +--- +'create-robo': patch +--- + +feat(create-robo): `--no-creds` option From a5e58da45283632d1fafd2709d83c212aa90d702 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 2 Jun 2024 03:07:27 +0200 Subject: [PATCH 06/10] fix(index.ts) Condition to ask for no creds was broken --- .changeset/hip-spoons-pretend.md | 5 +++++ packages/create-robo/src/index.ts | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/hip-spoons-pretend.md diff --git a/.changeset/hip-spoons-pretend.md b/.changeset/hip-spoons-pretend.md new file mode 100644 index 00000000..4d22b81b --- /dev/null +++ b/.changeset/hip-spoons-pretend.md @@ -0,0 +1,5 @@ +--- +'create-robo': patch +--- + +fix(create-robo): no creds flag. diff --git a/packages/create-robo/src/index.ts b/packages/create-robo/src/index.ts index 43815c03..000593f9 100644 --- a/packages/create-robo/src/index.ts +++ b/packages/create-robo/src/index.ts @@ -24,7 +24,7 @@ export interface CommandOptions { verbose?: boolean roboVersion?: string update?: boolean - noCreds?: boolean + creds?: boolean } new Command('create-robo ') @@ -41,7 +41,7 @@ new Command('create-robo ') .option('-v --verbose', 'print more information for debugging') .option('-rv, --robo-version ', 'specify a Robo.js version to use') .option('-k, --kit ', 'choose a kit to start off with your Robo') - .option('-nc, --no-creds', 'Skips asking for the credentials') + .option('-nc, --no-creds ', 'Skips asking for the credentials', false) .action(async (options: CommandOptions, { args }) => { logger({ level: options.verbose ? 'debug' : 'info' @@ -166,7 +166,8 @@ new Command('create-robo ') // Ask the user for their Discord credentials (token and client ID) and store them for later use // Skip this step if the user is creating a plugin // - if (!robo.isPlugin && options.noCreds) { + + if (!robo.isPlugin && !options.creds) { logger.debug(`Asking for Discord credentials...`) await robo.askForDiscordCredentials() } From b3ae1a151bb848383aca88445ebe88f0d6ad0e3c Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 3 Jun 2024 18:24:10 +0200 Subject: [PATCH 07/10] fix(index.ts) wasnt following best practices --- packages/create-robo/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-robo/src/index.ts b/packages/create-robo/src/index.ts index 000593f9..92434be1 100644 --- a/packages/create-robo/src/index.ts +++ b/packages/create-robo/src/index.ts @@ -41,7 +41,7 @@ new Command('create-robo ') .option('-v --verbose', 'print more information for debugging') .option('-rv, --robo-version ', 'specify a Robo.js version to use') .option('-k, --kit ', 'choose a kit to start off with your Robo') - .option('-nc, --no-creds ', 'Skips asking for the credentials', false) + .option('-nc, --no-creds', 'Skips asking for the credentials') .action(async (options: CommandOptions, { args }) => { logger({ level: options.verbose ? 'debug' : 'info' From 75a9e401ce804b91fc18c830345435d13d4477ea Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 3 Jun 2024 18:27:42 +0200 Subject: [PATCH 08/10] fix ??? --- packages/create-robo/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-robo/src/index.ts b/packages/create-robo/src/index.ts index f4326b55..ec2e5f38 100644 --- a/packages/create-robo/src/index.ts +++ b/packages/create-robo/src/index.ts @@ -166,7 +166,7 @@ new Command('create-robo ') // Ask the user for their Discord credentials (token and client ID) and store them for later use // Skip this step if the user is creating a plugin // - if (!robo.isPlugin && options.noCreds) { + if (!robo.isPlugin && !options.creds) { logger.debug(`Asking for Discord credentials...`) await robo.askForDiscordCredentials() } From 834e338c349b551e101f903b827b2f04436e2f42 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 3 Jun 2024 20:12:00 +0200 Subject: [PATCH 09/10] fix(index.ts) I hate commander --- packages/create-robo/src/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/create-robo/src/index.ts b/packages/create-robo/src/index.ts index ec2e5f38..1c5fbfbd 100644 --- a/packages/create-robo/src/index.ts +++ b/packages/create-robo/src/index.ts @@ -41,7 +41,7 @@ new Command('create-robo ') .option('-v --verbose', 'print more information for debugging') .option('-rv, --robo-version ', 'specify a Robo.js version to use') .option('-k, --kit ', 'choose a kit to start off with your Robo') - .option('-nc, --no-creds', 'Skips asking for the credentials') + .option('-nc --no-creds', 'Skips asking for the credentials') .action(async (options: CommandOptions, { args }) => { logger({ level: options.verbose ? 'debug' : 'info' @@ -165,8 +165,7 @@ new Command('create-robo ') // Ask the user for their Discord credentials (token and client ID) and store them for later use // Skip this step if the user is creating a plugin - // - if (!robo.isPlugin && !options.creds) { + if (!robo.isPlugin && options.creds) { logger.debug(`Asking for Discord credentials...`) await robo.askForDiscordCredentials() } From f37fc2c499b03236a3f5ab3c28f1499e0175c783 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 3 Jun 2024 20:34:58 +0200 Subject: [PATCH 10/10] WIP --- packages/create-robo/src/index.ts | 2 +- packages/create-robo/src/robo.ts | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/create-robo/src/index.ts b/packages/create-robo/src/index.ts index 1c5fbfbd..a4452e92 100644 --- a/packages/create-robo/src/index.ts +++ b/packages/create-robo/src/index.ts @@ -165,7 +165,7 @@ new Command('create-robo ') // Ask the user for their Discord credentials (token and client ID) and store them for later use // Skip this step if the user is creating a plugin - if (!robo.isPlugin && options.creds) { + if (!robo.isPlugin) { logger.debug(`Asking for Discord credentials...`) await robo.askForDiscordCredentials() } diff --git a/packages/create-robo/src/robo.ts b/packages/create-robo/src/robo.ts index cc8d6d8a..2bb8f4c2 100644 --- a/packages/create-robo/src/robo.ts +++ b/packages/create-robo/src/robo.ts @@ -837,20 +837,25 @@ export default class Robo { const discordPortalUrl = chalk.bold.blue('https://discord.com/developers/applications') const officialGuide = 'Guide:' const officialGuideUrl = chalk.bold.blue('https://roboplay.dev/' + (this._isApp ? 'appkey' : 'botkey')) + + let discordClientId = '' + let discordToken = '' logger.log('') logger.log(Indent, chalk.bold('🔑 Setting up credentials')) logger.log(Indent, ' Get your credentials from the Discord Developer portal.\n') logger.log(Indent, ` ${discordPortal} ${discordPortalUrl}`) logger.log(Indent, ` ${officialGuide} ${officialGuideUrl}\n`) - const discordClientId = await input({ - message: 'Enter your Discord Client ID (press Enter to skip):' - }) - const discordToken = await input({ - message: this._isApp - ? 'Enter your Discord Client Secret (press enter to skip)' - : 'Enter your Discord Token (press Enter to skip):' - }) + if (this._cliOptions.creds) { + discordClientId = await input({ + message: 'Enter your Discord Client ID (press Enter to skip):' + }) + discordToken = await input({ + message: this._isApp + ? 'Enter your Discord Client Secret (press enter to skip)' + : 'Enter your Discord Token (press Enter to skip):' + }) + } if (!discordClientId || !discordToken) { this._missingEnv = true