Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom native project templates #1514

Closed
rosen-vladimirov opened this issue Feb 19, 2016 · 4 comments
Closed

Use custom native project templates #1514

rosen-vladimirov opened this issue Feb 19, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@rosen-vladimirov
Copy link
Contributor

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.

@fealebenpae
Copy link
Contributor

I wholeheartedly approve - so much so that I want to very strongly advocate for permanently splitting the current Xcode and Gradle templates away from the runtime packages. Right now a minor fix in the templates requires releasing a whole new version of the runtimes and it is extremely cumbersome to support new build configurations such as iOS App Extensions or new platforms such as tvOS.

@rosen-vladimirov
Copy link
Contributor Author

@fealebenpae
Really good point. Once we have this feature, we can publish the XCode and Gradle templates in separate npm packages and CLI will install them when user does not specify --platform-template

@FriOne
Copy link

FriOne commented Oct 4, 2017

@rosen-vladimirov Hi! Is there some documentation for this or an example? And where default template is stored?

@dtopuzov
Copy link
Contributor

dtopuzov commented Jan 18, 2018

Hi @FriOne

If you need help for some tns command you can run tns <command> -h.
In this case tns create -h.

For general help about {N} CLI commands you can run tns help and it will open a browser with html help for each CLI command.

We also have a list with popular templates at Tempaltes section of https://market.nativescript.org/

You can create app from custom templates like this:

tns create my-app-name --template tns-template-master-detail-ng (this will search in npm)
tns create my-app-name --template https://github.com/NativeScript/template-master-detail-ng (this will create app from template in github)

Notes:

  • Applications are not templates, you cna not create app with template and point GitHub repo with application, it should be template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants