Skip to content

Use custom native project templates #1514

@rosen-vladimirov

Description

@rosen-vladimirov

Currently the native project templates (iOS and android) are taken from runtimes.
We should allow using custom templates, as there are some cases when the current template should be changed/extended, so you have to modify the platforms dir and commit it to source control.

The idea is to have new option for platform add command, for example --platform-template that will specify from where to take the native project template. The path to template should be saved in package.json under nativescript key, for example:

{
    "nativescript": {
        "id": "org.nativescript.appNativeTemplates",
        "tns-android": {
            "version": "1.6.1",
            "template": "./myAndroidTemplateDir"
        },
        "tns-ios": {
            "version": "1.6.0",
            "template": "./myiOSTemplateDir"
        }
    },
    "dependencies": {
            "tns-core-modules": "1.6.0"
    }
}

CLI commands should work in the following way:

  • tns platform add android --platform-template ./myAndroidTemplateDir - adds latest android runtime and copies the native project template from myAndroidTemplateDir. The value of the template should be written in package.json.
  • tns platform add android:
    • when there's no tns-android entry in package.json - work as usual - latest runtime and get native template from it.
    • when there's tns-android entry in package.json and there's template define in it - use the specified runtime version and the native template from the value of template property.
  • When platform is not added, executing tns prepare <platform>, tns build <platform>, tns deploy <platform>, tns emulate <platform>, tns run <platform>, tns test <platform> should add the platform. In case --platform-template is passed to any of these commands, we should respect it and do the same as tns platform add.

Same is valid for iOS related commands.

The value for template could be anything that can be npm installed - local directory, npm package, github url, .tgz.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions