A simple way to create and manage Aurelia CLI templates

This follows from this thread with @fkleuver concerning the problems around managing templates.

As always I will keep this as concise as possible.

Yesterday afternoon I had a few hours so I decided to look into the diff/patch approach to generating templates, enabling a command line (or any other app) to change templates that are created by any IDE (in my case Visual Studio 2017) and ‘add’ an Aurelia app to a template by modifying the code generated by the IDE. This has many benefits.

What I created was a basic app that compares 2 folders of code which I have called ‘source’ and ‘destination’ and take the diffs and generate a json patch file. See here for more info on diff/patch.

The ‘source’ folder contains the users newly generated project, generated by the IDE, to which they would like to add Aurelia.

The ‘destination’ folder contains all the files that have been added and modified to enable the Aurelia CLI project build and to run.

A third folder called ‘patch’ which contains a json document that is the serialised patch made from the diffs between the files in the ‘source’ and ‘destination’ folders, along with the filenames.
With this patch file we can alter any existing template of the same type and add Aurelia to it.

This means that it is minutes work to generate a patch file which can subsequently be used to decorate any template of that type with an Aurelia CLI project.

I have only tested this with a Visual Studio asp.net core 2.2.0 MVC app at the moment. But since we are dealing with text files, it should work with any IDE. I will be testing more later.

Essentially, I generated a Visual Studio dotnet core MVC project and added Aurelia to it by running a command that applied an earlier generated json patch file, reading in that patch, deserializing it, and patching/copying the files to modify the template. It worked fine.

Does anyone has a suggestion for a template (VS Code probably next)?

I have also created a basic .NET Core Global Tool as a complimentary to the CLI. I plan use this to add Aurelia to Visual Studio (or any other project types I generate patches for), via the command line, as such:

agt -add {some-template-identifier}

…meaning ‘aurelia global tools -add {some-template-identifier}’

Or, maybe even (for fun):

gta -add {some-template-identifier}

…meaning ‘global tools aurelia -add {some-template-identifier}’

So why all this?

  • Because the user can add the Aurelia goodness to their default IDE generated projects
  • The templates can be maintained easily
  • New templates added quickly
  • Users could create, publish their own templates that could be used by a command like:
    agt -add -net {some-github-repo}

Mostly, it could be used to more easily manage templated starting points for Aurelia projects.

For anyone interested, a patch entry looks like this:

                  "text":" {\r\n"
                  "text":"        /// <summary>\r\n        /// This is some text that I have added to test the patching for Aurelia!\r\n        /// </summary>\r\n        /// <returns></returns>\r\n"
                  "text":"    "

I have now a basic working global tool that upgrades Visual Studio and VS Code projects to Aurelia CLI projects using the command:

agt -add {some-template-identifier} {path-to-new-project}

I plan to add compatibility checks before attempting to patch, option to automatically install dependencies and maybe even build and run with --watch. This will then make getting up and running with Aurelia look like this.

  1. Create a new project in ide.
  2. Execute:
    agt -add {template-id} {project-path} -install -build -watch
  3. Press F5 and see it running in debug.
1 Like

This is very interesting and promising stuff. I would love to help you out with turning this into something more official but unfortunately I am swamped with vNext TODO’s for the coming while.
@huochunpeng could you check and see if this is something you can work with? @constructor seems to know his stuff when it comes to .NET, so perhaps something useful on the long term can come out of this. We definitely need something better. This might be a good opportunity.


I have no idea about dotnet and agt. But big portion of Aurelia user base are dotnet users, @EisenbergEffect definitely needs to assign someone to own the dotnet integration.

1 Like

@constructor We desperately need an Aurelia core team member who can focus on the Aurelia .NET story. We had some people working on this a little while back but they haven’t been active for some time. I’d love to talk more with you about whether this is something you’d love to do in a more official capacity for the Aurelia community. Please email me. You can find contact information in the Core Team section of our contributor guide here: https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md#core-team Looking forward to hearing from you soon.


Me me me… I am a .NET guru :wink: I will contact the team.


And honestly, we could probably devote more than one person on this since .NET devs are such a big part of our community. I know they’d love some more focus.


@brandonseydel Definitely email me :slight_smile:


I have emailed using designs digital email.

1 Like