_schema-version: "3.2"
ID: <%= appid %>
version: 0.0.1

modules:

- name: webapp_destination_content
  type: com.sap.application.content
  requires:
  - name: uaa_service 
    parameters:
      service-key:
        name: <%= appid %>_uaa-key
  - name: html_repo_host
    parameters:
      service-key:
        name: <%= appid %>_html_repo_host-key
  - name: uaa_to_host_destination
    parameters:
      content-target: true
  parameters:
    content:
      subaccount:
        destinations:
        - Name: <%= appid %>_htmlrepohost
          ServiceInstanceName:  <%= appid %>-html5-app-host-service
          ServiceKeyName:  <%= appid %>_html_repo_host-key
          sap.cloud.service: <%= appid %>
        - Name: <%= appid %>_tokenexchange
          Authentication: OAuth2UserTokenExchange
          ServiceInstanceName: <%= appid %>-xsuaa-service
          ServiceKeyName: <%= appid %>_uaa-key
          sap.cloud.service: <%= appid %>
        existing_destinations_policy: update
  build-parameters:
    no-source: true

- name: webapp_deployer
  type: com.sap.application.content
  path: .
  requires:
  - name: html_repo_host
    parameters:
      content-target: true
  build-parameters:
    build-result: mta_resources
    requires:
    - name: webapp
      artifacts:
      - webapp-content.zip
      target-path: mta_resources/
      
- name: webapp
  type: html5
  path: app/<%= appname %>app
  build-parameters:
    builder: custom
    commands:
        - npm run build
        - npm run zip
    build-result: build  
    supported-platforms: []


resources:

- name: uaa_to_host_destination
  type: org.cloudfoundry.managed-service
  parameters:
    service: destination
    service-name: <%= appid %>-destination-service
    service-plan: lite
- name: html_repo_host
  type: org.cloudfoundry.managed-service
  parameters:
    service: html5-apps-repo
    service-name: <%= appid %>-html5-app-host-service
    service-plan: app-host
- name: uaa_service
  type: org.cloudfoundry.managed-service
  parameters:
    path: ./xs-security.json
    service: xsuaa
    service-name: <%= appid %>-xsuaa-service
    service-plan: application