From 29534d24534c5aa37ed3b3b2e27fbee4b8b1d15c Mon Sep 17 00:00:00 2001 From: Philipp Hugenroth Date: Thu, 9 Feb 2023 17:37:44 +0100 Subject: [PATCH] Add gh-auth Signed-off-by: Philipp Hugenroth --- packages/cli/src/commands/admin/gh-auth.ts | 30 +++++++++++++++++++ .../GithubCreateAppServer.ts | 5 +++- .../src/commands/create-github-app/index.ts | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 packages/cli/src/commands/admin/gh-auth.ts diff --git a/packages/cli/src/commands/admin/gh-auth.ts b/packages/cli/src/commands/admin/gh-auth.ts new file mode 100644 index 0000000000..da3036d087 --- /dev/null +++ b/packages/cli/src/commands/admin/gh-auth.ts @@ -0,0 +1,30 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import chalk from 'chalk'; +import inquirer from 'inquirer'; +import createGithubApp from '../create-github-app'; + +export default async () => { + // TODO: Make the GitHub Org optional + const input = await inquirer.prompt<{ org: string }>([ + { + type: 'input', + name: 'org', + message: chalk.blue('Enter a GitHub Org [required]'), + }, + ]); + await createGithubApp(input.org); +}; diff --git a/packages/cli/src/commands/create-github-app/GithubCreateAppServer.ts b/packages/cli/src/commands/create-github-app/GithubCreateAppServer.ts index 70b8c0ca53..ca5eb2c02a 100644 --- a/packages/cli/src/commands/create-github-app/GithubCreateAppServer.ts +++ b/packages/cli/src/commands/create-github-app/GithubCreateAppServer.ts @@ -117,8 +117,11 @@ export class GithubCreateAppServer { ...(this.permissions.includes('members') && { members: 'read' }), ...(this.permissions.includes('read') && { contents: 'read' }), ...(this.permissions.includes('write') && { + administration: 'write', contents: 'write', - actions: 'write', + pull_requests: 'write', + issues: 'write', + workflows: 'write', }), }, name: 'Backstage-', diff --git a/packages/cli/src/commands/create-github-app/index.ts b/packages/cli/src/commands/create-github-app/index.ts index 6b3e732f18..e04e39fdf6 100644 --- a/packages/cli/src/commands/create-github-app/index.ts +++ b/packages/cli/src/commands/create-github-app/index.ts @@ -26,6 +26,7 @@ import openBrowser from 'react-dev-utils/openBrowser'; // due to lacking support for creating apps from manifests. // https://docs.github.com/en/free-pro-team@latest/developers/apps/creating-a-github-app-from-a-manifest export default async (org: string) => { + // Why is the Org check not done here? const answers: Answers = await inquirer.prompt({ name: 'appType', type: 'checkbox',