diff --git a/packages/cli/src/commands/new/new.ts b/packages/cli/src/commands/new/new.ts index 6eb027aed2..d683aeaa6b 100644 --- a/packages/cli/src/commands/new/new.ts +++ b/packages/cli/src/commands/new/new.ts @@ -16,9 +16,10 @@ import os from 'os'; import fs from 'fs-extra'; -import { join as joinPath } from 'path'; +import { join as joinPath, dirname } from 'path'; import { OptionValues } from 'commander'; import inquirer from 'inquirer'; +import { parse } from 'yaml'; import { FactoryRegistry } from '../../lib/new/FactoryRegistry'; import { isMonoRepo } from '@backstage/cli-node'; import { paths } from '../../lib/paths'; @@ -26,6 +27,22 @@ import { assertError } from '@backstage/errors'; import { Task } from '../../lib/tasks'; import defaultTemplates from '../../../templates/alpha/all-default-templates'; +type ConfigurablePrompt = + | { + id: string; + prompt: string; + default?: string | boolean; + } + | string; + +interface Template { + description?: string; + template: string; + targetPath: string; + prompts?: ConfigurablePrompt[]; + additionalActions?: string[]; +} + interface TemplateLocation { id: string; target: string; @@ -79,12 +96,29 @@ async function templateSelector( return answer.name; } +async function verifyTemplate({ target }: TemplateLocation): Promise