dotnet/templating

Make it easier to invoke templates from other ecosystems/tools as .NET templates

baronfel opened this issue · 1 comments

Is your feature request related to a problem? Please describe.

The JS Project System templates for Visual Studio have lightweight VS template wrappers that guide the invocation of various npm init templates. For example npm init vue@latest <appName> -- [various flags].

It would be great if there was a way to 'delegate' the template invocation to another binary in this way. Ideally a template could be very lightweight and consist of a number of options/flags that the dotnet CLI could surface and transform, then pass to the command/tool that is going to be invoked. The actual generation would be delegated to the 'base command', and the template engine itself might not be invoked at all for content processing.

Describe the solution you'd like.

I'd like a way to define a template.json that might do something like:

{
{
  "$schema": "http://json.schemastore.org/template",
  "author": "Microsoft",
  "classifications": [
    "Vue",
    "Javascript"
  ],
  "name": "Vue application",
  "description": "A project for creating a Vue JS application",
  "shortName": "vue",
  "tags": {
    "language": "JS",
    "type": "project"
  },
  "symbols": {
    "UseTypescript": {
      "type": "parameter",
      "description": "Default to using Typescript instead of Javascript",
      "defaultValue": "true",
      "displayName": "Use TypeScript"
    }
  }
 "baseCommand": "npm",
 "arguments": [
	"init",
    "--yes",
    "vue@latest",
    { "symbol": "name" },
    "--",
    "--eslint",
	{
		"condition": "UseTypeScript",
        "value": "--typescript"
	}
  ]
}

The idea being that we could define symbols and condition the include/exclude of arguments to the base command based on those symbols.

Additional context

No response

This capability (not necessarily the implementation) is requested by @danroth27 and the JS Project System team. It's hard to migrate/integrate a certain class of VS template to .NET SDK Templates without features like this.