Description
Currently when a project is created the content of the template is placed inside the app
directory of the newly created project.
This leads to some issues when you want to support more complex scenarios, for example it is difficult to add configuration file (like nsconfig.json
or webpack.config.js
) in the root of the project.
The suggested solution to allow templates to be the full application is to check the template from which the application is created. In case the template contains the following information:
{
"name": "new-template-name",
"version": "4.0.0",
"nativescript": {
"templateVersion": "v2"
}
}
Read the templateVersion property (if it is not set or there's no nativescript key, the default value is v1
) and execute the following action based on its value:
- In case it is v1, use the old way, i.e. place the content of the template in the app directory of the created project.
- In case it is v2 place the content of the template at the root of the application.
- In case it is anything else - throw an error.
- In case it is missing, use v1 as default.
The solution ensures backwards compatiblity with existing templates and allows creating new types of templates.