diff --git a/docs/tooling/cli/04-templates.md b/docs/tooling/cli/04-templates.md index a4b3a07db1..47a4f4d663 100644 --- a/docs/tooling/cli/04-templates.md +++ b/docs/tooling/cli/04-templates.md @@ -106,7 +106,6 @@ Your first step in creating your own CLI template is composing your yaml file: name: custom-plugin role: frontend-plugin description: Description of my CLI template # optional -files: ./template # optional templateValues: # optional pluginVar: '{{ camelCase pluginId }}Plugin' ``` @@ -116,7 +115,6 @@ The following properties are supported: - `name` **(required)** - The name of your template, used by the user to select it. - `role` **(required)** - The role of the template, similar to package role. See [Template Roles](#template-roles) for more details. - `description` - A description of the type of package that this template produces. -- `files` - A directory or list of relative file paths pointing to the contents of your template. Defaults to the current directory. - `parameters` - A map of pre-filled parameters that will be used instead of prompting the user for input. - `templateValues` - A map of additional values that will be present during templating. The values are themselves templated and can reference other values. diff --git a/packages/cli/src/lib/new/preparation/loadPortableTemplate.test.ts b/packages/cli/src/lib/new/preparation/loadPortableTemplate.test.ts index 89a8e0c6aa..ad81862379 100644 --- a/packages/cli/src/lib/new/preparation/loadPortableTemplate.test.ts +++ b/packages/cli/src/lib/new/preparation/loadPortableTemplate.test.ts @@ -49,32 +49,6 @@ describe('loadTemplate', () => { }); }); - it('should load a valid template with files in a separate dir', async () => { - mockDir.setContent({ - 'path/to/template.yaml': ` - name: template1 - role: frontend-plugin - files: content - parameters: - foo: bar - `, - 'path/to/content/hello.txt': 'hello world', - }); - - await expect( - loadPortableTemplate({ - name: 'template1', - target: mockDir.resolve('path/to/template.yaml'), - }), - ).resolves.toEqual({ - name: 'template1', - role: 'frontend-plugin', - files: [{ path: 'hello.txt', content: 'hello world' }], - parameters: { foo: 'bar' }, - templateValues: {}, - }); - }); - it('should throw an error if template file does not exist', async () => { mockDir.setContent({}); @@ -117,7 +91,6 @@ describe('loadTemplate', () => { 'path/to/template1.yaml': ` name: x role: invalid-role - files: template1 `, }); @@ -132,25 +105,4 @@ describe('loadTemplate', () => { )}'; caused by Validation error: Invalid enum value`, ); }); - - it('should throw an error if template directory does not exist', async () => { - mockDir.setContent({ - 'path/to/template1.yaml': ` - name: x - role: frontend-plugin - files: template1 - `, - }); - - await expect( - loadPortableTemplate({ - name: 'template1', - target: mockDir.resolve('path/to/template1.yaml'), - }), - ).rejects.toThrow( - `Failed to load template contents from '${mockDir.resolve( - 'path/to/template1', - )}'`, - ); - }); }); diff --git a/packages/cli/src/lib/new/preparation/loadPortableTemplate.ts b/packages/cli/src/lib/new/preparation/loadPortableTemplate.ts index 60246351e6..eaf6ecc90b 100644 --- a/packages/cli/src/lib/new/preparation/loadPortableTemplate.ts +++ b/packages/cli/src/lib/new/preparation/loadPortableTemplate.ts @@ -35,7 +35,6 @@ const templateDefinitionSchema = z name: z.string(), role: z.enum(TEMPLATE_ROLES), description: z.string().optional(), - files: z.string().optional(), parameters: z.record(z.string()).optional(), templateValues: z.record(z.string()).optional(), }) @@ -65,14 +64,9 @@ export async function loadPortableTemplate( ); } - const { - role, - files = '.', - parameters = {}, - templateValues = {}, - } = parsed.data; + const { role, parameters = {}, templateValues = {} } = parsed.data; - const templatePath = resolvePath(dirname(pointer.target), files); + const templatePath = resolvePath(dirname(pointer.target)); const filePaths = await recursiveReaddir(templatePath).catch(error => { throw new ForwardedError( `Failed to load template contents from '${templatePath}'`,