From 8d886dd33e03bb47687a6de0826e35162475a731 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 31 Aug 2022 18:51:46 +0200 Subject: [PATCH 1/2] cli: new new command Signed-off-by: Patrik Oldsberg --- .changeset/afraid-garlics-glow.md | 5 +++ .changeset/selfish-wasps-cough.md | 14 ++++++ package.json | 5 +-- packages/cli/cli-report.md | 44 +++++++------------ packages/cli/src/commands/index.ts | 30 +++++++++++-- .../templates/default-app/package.json.hbs | 2 +- 6 files changed, 64 insertions(+), 36 deletions(-) create mode 100644 .changeset/afraid-garlics-glow.md create mode 100644 .changeset/selfish-wasps-cough.md diff --git a/.changeset/afraid-garlics-glow.md b/.changeset/afraid-garlics-glow.md new file mode 100644 index 0000000000..dfe2596869 --- /dev/null +++ b/.changeset/afraid-garlics-glow.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +The `create-plugin` and `create` commands have both been deprecated in favor of a new `new` command. The `new` command is functionally identical to `create`, but the new naming makes it possible to use as yarn script, since `yarn create` is reserved. diff --git a/.changeset/selfish-wasps-cough.md b/.changeset/selfish-wasps-cough.md new file mode 100644 index 0000000000..cc00520385 --- /dev/null +++ b/.changeset/selfish-wasps-cough.md @@ -0,0 +1,14 @@ +--- +'@backstage/create-app': patch +--- + +Added `yarn new` as one of the scripts installed by default, which calls `backstage-cli new`. This script replaces `create-plugin`, which you can now remove if you want to. It is kept in the `create-app` template for backwards compatibility. + +The `remove-plugin` command has been removed, as it has been removed from the Backstage CLI. + +To apply these changes to an existing app, make the following change to the root `package.json`: + +```diff +- "remove-plugin": "backstage-cli remove-plugin" ++ "new": "backstage-cli new --scope internal" +``` diff --git a/package.json b/package.json index 6cad8106a1..77ee1dccc5 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,8 @@ "lint:all": "backstage-cli repo lint", "lint:type-deps": "node scripts/check-type-dependencies.js", "docker-build": "yarn tsc && yarn workspace example-backend build --build-dependencies && yarn workspace example-backend build-image", - "backstage-create": "backstage-cli create --scope backstage --no-private", - "create-plugin": "yarn backstage-create --select plugin", - "remove-plugin": "backstage-cli remove-plugin", + "new": "backstage-cli new --scope backstage --no-private", + "create-plugin": "echo \"use 'yarn new' instead\"", "release": "node scripts/prepare-release.js && changeset version && yarn diff --yes && yarn prettier --write '{packages,plugins}/*/{package.json,CHANGELOG.md}' '.changeset/*.json' && yarn install --no-immutable", "prettier:check": "prettier --check .", "lerna": "lerna", diff --git a/packages/cli/cli-report.md b/packages/cli/cli-report.md index 14e548eeaf..1c86c8723c 100644 --- a/packages/cli/cli-report.md +++ b/packages/cli/cli-report.md @@ -12,8 +12,7 @@ Options: -h, --help Commands: - create [options] - create-plugin [options] + new [options] plugin:diff [options] test config:docs [options] @@ -100,20 +99,6 @@ Options: -h, --help ``` -### `backstage-cli create` - -``` -Usage: backstage-cli create [options] - -Options: - --select - --option = - --scope - --npm-registry - --no-private - -h, --help -``` - ### `backstage-cli create-github-app` ``` @@ -123,19 +108,6 @@ Options: -h, --help ``` -### `backstage-cli create-plugin` - -``` -Usage: backstage-cli create-plugin [options] - -Options: - --backend - --scope - --npm-registry - --no-private - -h, --help -``` - ### `backstage-cli info` ``` @@ -197,6 +169,20 @@ Options: -h, --help ``` +### `backstage-cli new` + +``` +Usage: backstage-cli new [options] + +Options: + --select + --option = + --scope + --npm-registry + --no-private + -h, --help +``` + ### `backstage-cli package` ``` diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 9c543f8853..07c9ac92d1 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -198,7 +198,7 @@ export function registerMigrateCommand(program: Command) { export function registerCommands(program: Command) { program - .command('create') + .command('new') .storeOptionsAsProperties(false) .description( 'Open up an interactive guide to creating new things in your app', @@ -222,12 +222,36 @@ export function registerCommands(program: Command) { .action(lazy(() => import('./create/create').then(m => m.default))); program - .command('create-plugin') + .command('create', { hidden: true }) + .storeOptionsAsProperties(false) + .description( + 'Open up an interactive guide to creating new things in your app [DEPRECATED]', + ) + .option( + '--select ', + 'Select the thing you want to be creating upfront', + ) + .option( + '--option =', + 'Pre-fill options for the creation process', + (opt, arr: string[]) => [...arr, opt], + [], + ) + .option('--scope ', 'The scope to use for new packages') + .option( + '--npm-registry ', + 'The package registry to use for new packages', + ) + .option('--no-private', 'Do not mark new packages as private') + .action(lazy(() => import('./create/create').then(m => m.default))); + + program + .command('create-plugin', { hidden: true }) .option( '--backend', 'Create plugin with the backend dependencies as default', ) - .description('Creates a new plugin in the current repository') + .description('Creates a new plugin in the current repository [DEPRECATED]') .option('--scope ', 'npm scope') .option('--npm-registry ', 'npm registry URL') .option('--no-private', 'Public npm package') diff --git a/packages/create-app/templates/default-app/package.json.hbs b/packages/create-app/templates/default-app/package.json.hbs index 26c6a61972..9e20ebfa64 100644 --- a/packages/create-app/templates/default-app/package.json.hbs +++ b/packages/create-app/templates/default-app/package.json.hbs @@ -21,7 +21,7 @@ "lint:all": "backstage-cli repo lint", "prettier:check": "prettier --check .", "create-plugin": "backstage-cli create-plugin --scope internal", - "remove-plugin": "backstage-cli remove-plugin" + "new": "backstage-cli new --scope internal" }, "workspaces": { "packages": [ From 99cf5ffb1e06f2a73f4d8b7fc3a0555ae0788ce8 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 1 Sep 2022 17:51:51 +0200 Subject: [PATCH 2/2] cli: internal rename of create -> new Signed-off-by: Patrik Oldsberg --- packages/cli/src/commands/index.ts | 4 ++-- packages/cli/src/commands/{create/create.ts => new/new.ts} | 2 +- packages/cli/src/lib/{create => new}/FactoryRegistry.ts | 0 .../src/lib/{create => new}/factories/backendPlugin.test.ts | 0 .../cli/src/lib/{create => new}/factories/backendPlugin.ts | 0 .../cli/src/lib/{create => new}/factories/common/prompts.ts | 0 .../src/lib/{create => new}/factories/common/tasks.test.ts | 0 .../cli/src/lib/{create => new}/factories/common/tasks.ts | 0 .../cli/src/lib/{create => new}/factories/common/testUtils.ts | 0 .../src/lib/{create => new}/factories/frontendPlugin.test.ts | 0 .../cli/src/lib/{create => new}/factories/frontendPlugin.ts | 0 packages/cli/src/lib/{create => new}/factories/index.ts | 0 .../src/lib/{create => new}/factories/pluginCommon.test.ts | 0 .../cli/src/lib/{create => new}/factories/pluginCommon.ts | 0 .../lib/{create => new}/factories/scaffolderModule.test.ts | 0 .../cli/src/lib/{create => new}/factories/scaffolderModule.ts | 0 packages/cli/src/lib/{create => new}/types.ts | 0 17 files changed, 3 insertions(+), 3 deletions(-) rename packages/cli/src/commands/{create/create.ts => new/new.ts} (98%) rename packages/cli/src/lib/{create => new}/FactoryRegistry.ts (100%) rename packages/cli/src/lib/{create => new}/factories/backendPlugin.test.ts (100%) rename packages/cli/src/lib/{create => new}/factories/backendPlugin.ts (100%) rename packages/cli/src/lib/{create => new}/factories/common/prompts.ts (100%) rename packages/cli/src/lib/{create => new}/factories/common/tasks.test.ts (100%) rename packages/cli/src/lib/{create => new}/factories/common/tasks.ts (100%) rename packages/cli/src/lib/{create => new}/factories/common/testUtils.ts (100%) rename packages/cli/src/lib/{create => new}/factories/frontendPlugin.test.ts (100%) rename packages/cli/src/lib/{create => new}/factories/frontendPlugin.ts (100%) rename packages/cli/src/lib/{create => new}/factories/index.ts (100%) rename packages/cli/src/lib/{create => new}/factories/pluginCommon.test.ts (100%) rename packages/cli/src/lib/{create => new}/factories/pluginCommon.ts (100%) rename packages/cli/src/lib/{create => new}/factories/scaffolderModule.test.ts (100%) rename packages/cli/src/lib/{create => new}/factories/scaffolderModule.ts (100%) rename packages/cli/src/lib/{create => new}/types.ts (100%) diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 07c9ac92d1..0af1674b6c 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -219,7 +219,7 @@ export function registerCommands(program: Command) { 'The package registry to use for new packages', ) .option('--no-private', 'Do not mark new packages as private') - .action(lazy(() => import('./create/create').then(m => m.default))); + .action(lazy(() => import('./new/new').then(m => m.default))); program .command('create', { hidden: true }) @@ -243,7 +243,7 @@ export function registerCommands(program: Command) { 'The package registry to use for new packages', ) .option('--no-private', 'Do not mark new packages as private') - .action(lazy(() => import('./create/create').then(m => m.default))); + .action(lazy(() => import('./new/new').then(m => m.default))); program .command('create-plugin', { hidden: true }) diff --git a/packages/cli/src/commands/create/create.ts b/packages/cli/src/commands/new/new.ts similarity index 98% rename from packages/cli/src/commands/create/create.ts rename to packages/cli/src/commands/new/new.ts index c784307738..b0d30c0415 100644 --- a/packages/cli/src/commands/create/create.ts +++ b/packages/cli/src/commands/new/new.ts @@ -18,7 +18,7 @@ import os from 'os'; import fs from 'fs-extra'; import { join as joinPath } from 'path'; import { OptionValues } from 'commander'; -import { FactoryRegistry } from '../../lib/create/FactoryRegistry'; +import { FactoryRegistry } from '../../lib/new/FactoryRegistry'; import { paths } from '../../lib/paths'; import { assertError } from '@backstage/errors'; import { Task } from '../../lib/tasks'; diff --git a/packages/cli/src/lib/create/FactoryRegistry.ts b/packages/cli/src/lib/new/FactoryRegistry.ts similarity index 100% rename from packages/cli/src/lib/create/FactoryRegistry.ts rename to packages/cli/src/lib/new/FactoryRegistry.ts diff --git a/packages/cli/src/lib/create/factories/backendPlugin.test.ts b/packages/cli/src/lib/new/factories/backendPlugin.test.ts similarity index 100% rename from packages/cli/src/lib/create/factories/backendPlugin.test.ts rename to packages/cli/src/lib/new/factories/backendPlugin.test.ts diff --git a/packages/cli/src/lib/create/factories/backendPlugin.ts b/packages/cli/src/lib/new/factories/backendPlugin.ts similarity index 100% rename from packages/cli/src/lib/create/factories/backendPlugin.ts rename to packages/cli/src/lib/new/factories/backendPlugin.ts diff --git a/packages/cli/src/lib/create/factories/common/prompts.ts b/packages/cli/src/lib/new/factories/common/prompts.ts similarity index 100% rename from packages/cli/src/lib/create/factories/common/prompts.ts rename to packages/cli/src/lib/new/factories/common/prompts.ts diff --git a/packages/cli/src/lib/create/factories/common/tasks.test.ts b/packages/cli/src/lib/new/factories/common/tasks.test.ts similarity index 100% rename from packages/cli/src/lib/create/factories/common/tasks.test.ts rename to packages/cli/src/lib/new/factories/common/tasks.test.ts diff --git a/packages/cli/src/lib/create/factories/common/tasks.ts b/packages/cli/src/lib/new/factories/common/tasks.ts similarity index 100% rename from packages/cli/src/lib/create/factories/common/tasks.ts rename to packages/cli/src/lib/new/factories/common/tasks.ts diff --git a/packages/cli/src/lib/create/factories/common/testUtils.ts b/packages/cli/src/lib/new/factories/common/testUtils.ts similarity index 100% rename from packages/cli/src/lib/create/factories/common/testUtils.ts rename to packages/cli/src/lib/new/factories/common/testUtils.ts diff --git a/packages/cli/src/lib/create/factories/frontendPlugin.test.ts b/packages/cli/src/lib/new/factories/frontendPlugin.test.ts similarity index 100% rename from packages/cli/src/lib/create/factories/frontendPlugin.test.ts rename to packages/cli/src/lib/new/factories/frontendPlugin.test.ts diff --git a/packages/cli/src/lib/create/factories/frontendPlugin.ts b/packages/cli/src/lib/new/factories/frontendPlugin.ts similarity index 100% rename from packages/cli/src/lib/create/factories/frontendPlugin.ts rename to packages/cli/src/lib/new/factories/frontendPlugin.ts diff --git a/packages/cli/src/lib/create/factories/index.ts b/packages/cli/src/lib/new/factories/index.ts similarity index 100% rename from packages/cli/src/lib/create/factories/index.ts rename to packages/cli/src/lib/new/factories/index.ts diff --git a/packages/cli/src/lib/create/factories/pluginCommon.test.ts b/packages/cli/src/lib/new/factories/pluginCommon.test.ts similarity index 100% rename from packages/cli/src/lib/create/factories/pluginCommon.test.ts rename to packages/cli/src/lib/new/factories/pluginCommon.test.ts diff --git a/packages/cli/src/lib/create/factories/pluginCommon.ts b/packages/cli/src/lib/new/factories/pluginCommon.ts similarity index 100% rename from packages/cli/src/lib/create/factories/pluginCommon.ts rename to packages/cli/src/lib/new/factories/pluginCommon.ts diff --git a/packages/cli/src/lib/create/factories/scaffolderModule.test.ts b/packages/cli/src/lib/new/factories/scaffolderModule.test.ts similarity index 100% rename from packages/cli/src/lib/create/factories/scaffolderModule.test.ts rename to packages/cli/src/lib/new/factories/scaffolderModule.test.ts diff --git a/packages/cli/src/lib/create/factories/scaffolderModule.ts b/packages/cli/src/lib/new/factories/scaffolderModule.ts similarity index 100% rename from packages/cli/src/lib/create/factories/scaffolderModule.ts rename to packages/cli/src/lib/new/factories/scaffolderModule.ts diff --git a/packages/cli/src/lib/create/types.ts b/packages/cli/src/lib/new/types.ts similarity index 100% rename from packages/cli/src/lib/create/types.ts rename to packages/cli/src/lib/new/types.ts