From 2d66d0dc0f2506e0a319e7ccda2841da5d895e97 Mon Sep 17 00:00:00 2001 From: aramissennyeydd Date: Sat, 5 Apr 2025 16:11:10 -0400 Subject: [PATCH] move create-github-app to its own module Signed-off-by: aramissennyeydd --- packages/cli/src/alpha.ts | 1 + packages/cli/src/commands/index.ts | 3 +- .../src/modules/create-github-app/alpha.ts | 38 +++++++++++++++++++ .../GithubCreateAppServer.ts | 0 .../commands/create-github-app/index.ts | 0 .../src/modules/create-github-app/index.ts | 29 ++++++++++++++ packages/cli/src/modules/new/alpha.ts | 15 -------- packages/cli/src/modules/new/index.ts | 5 --- 8 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 packages/cli/src/modules/create-github-app/alpha.ts rename packages/cli/src/modules/{new => create-github-app}/commands/create-github-app/GithubCreateAppServer.ts (100%) rename packages/cli/src/modules/{new => create-github-app}/commands/create-github-app/index.ts (100%) create mode 100644 packages/cli/src/modules/create-github-app/index.ts diff --git a/packages/cli/src/alpha.ts b/packages/cli/src/alpha.ts index 6bb16f0f7e..3324ed8d75 100644 --- a/packages/cli/src/alpha.ts +++ b/packages/cli/src/alpha.ts @@ -26,6 +26,7 @@ import chalk from 'chalk'; ); const initializer = new CliInitializer(); initializer.add(import('./modules/new/alpha')); + initializer.add(import('./modules/create-github-app/alpha')); initializer.add(import('./modules/info/alpha')); initializer.add(import('./modules/config/alpha')); initializer.add(import('./modules/build/alpha')); diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 3f32bd396f..3640091f60 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -42,6 +42,7 @@ import { } from '../modules/maintenance'; import { removed } from '../lib/removed'; import { registerCommands as registerNewCommands } from '../modules/new'; +import { registerCommands as registerCreateGithubAppCommands } from '../modules/create-github-app'; export function registerRepoCommand(program: Command) { const command = program @@ -75,7 +76,7 @@ export function registerCommands(program: Command) { registerBuildCommands(program); registerInfoCommands(program); registerNewCommands(program); - + registerCreateGithubAppCommands(program); // Notifications for removed commands program diff --git a/packages/cli/src/modules/create-github-app/alpha.ts b/packages/cli/src/modules/create-github-app/alpha.ts new file mode 100644 index 0000000000..da1e04aaac --- /dev/null +++ b/packages/cli/src/modules/create-github-app/alpha.ts @@ -0,0 +1,38 @@ +/* + * Copyright 2025 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 { createCliPlugin } from '../../wiring/factory'; +import { Command } from 'commander'; +import { lazy } from '../../lib/lazy'; + +export default createCliPlugin({ + pluginId: 'new', + init: async reg => { + reg.addCommand({ + path: ['create-github-app'], + description: 'Create new GitHub App in your organization.', + execute: async ({ args }) => { + const command = new Command(); + const defaultCommand = command + .argument('') + .action( + lazy(() => import('./commands/create-github-app'), 'default'), + ); + + await defaultCommand.parseAsync(args, { from: 'user' }); + }, + }); + }, +}); diff --git a/packages/cli/src/modules/new/commands/create-github-app/GithubCreateAppServer.ts b/packages/cli/src/modules/create-github-app/commands/create-github-app/GithubCreateAppServer.ts similarity index 100% rename from packages/cli/src/modules/new/commands/create-github-app/GithubCreateAppServer.ts rename to packages/cli/src/modules/create-github-app/commands/create-github-app/GithubCreateAppServer.ts diff --git a/packages/cli/src/modules/new/commands/create-github-app/index.ts b/packages/cli/src/modules/create-github-app/commands/create-github-app/index.ts similarity index 100% rename from packages/cli/src/modules/new/commands/create-github-app/index.ts rename to packages/cli/src/modules/create-github-app/commands/create-github-app/index.ts diff --git a/packages/cli/src/modules/create-github-app/index.ts b/packages/cli/src/modules/create-github-app/index.ts new file mode 100644 index 0000000000..f69230cd77 --- /dev/null +++ b/packages/cli/src/modules/create-github-app/index.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2025 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 { Command } from 'commander'; +import { lazy } from '../../lib/lazy'; + +export function registerCommands(program: Command) { + program + .command('create-github-app ') + .description('Create new GitHub App in your organization.') + .action( + lazy( + () => import('../create-github-app/commands/create-github-app'), + 'default', + ), + ); +} diff --git a/packages/cli/src/modules/new/alpha.ts b/packages/cli/src/modules/new/alpha.ts index d9b1f44daf..9a9b26e85a 100644 --- a/packages/cli/src/modules/new/alpha.ts +++ b/packages/cli/src/modules/new/alpha.ts @@ -80,20 +80,5 @@ export default createCliPlugin({ removed("use 'backstage-cli new' instead")(); }, }); - - reg.addCommand({ - path: ['create-github-app'], - description: 'Create new GitHub App in your organization.', - execute: async ({ args }) => { - const command = new Command(); - const defaultCommand = command - .argument('') - .action( - lazy(() => import('./commands/create-github-app'), 'default'), - ); - - await defaultCommand.parseAsync(args, { from: 'user' }); - }, - }); }, }); diff --git a/packages/cli/src/modules/new/index.ts b/packages/cli/src/modules/new/index.ts index ec7b2eca3b..fa288f5f46 100644 --- a/packages/cli/src/modules/new/index.ts +++ b/packages/cli/src/modules/new/index.ts @@ -54,11 +54,6 @@ export function registerCommands(program: Command) { .option('--no-private', 'Do not mark new packages as private') .action(lazy(() => import('./commands/new'), 'default')); - program - .command('create-github-app ') - .description('Create new GitHub App in your organization.') - .action(lazy(() => import('./commands/create-github-app'), 'default')); - program .command('create') .allowUnknownOption(true)