cloud-mta-build-tool icon indicating copy to clipboard operation
cloud-mta-build-tool copied to clipboard

Improve Inclusion & Exclusion of Files & Folders

Open SchroederSteffen opened this issue 4 years ago • 4 comments

Hi,

We're using MBT to build MTA archives for NestJS services (Node modules that have been transpiled from TypeScript using a custom builder).

By default, the .mtar also contains the src & test folders and plenty of other project files like the tsconfig.json, its own Makefile (?) and more. image

We're looking into ignoring the unnecessary files with the ignore parameter as documented. However, this will be quite cumbersome and will blow up the mta.yaml.

We would like to request either

  • support for an .mtaignore file similar to .gitignore or .npmignore to achieve this in a cleaner fashion or
  • support for a new include parameter instead of just a single build-result folder or both. 🙂

Thanks and kind regards, Steffen

SchroederSteffen avatar Dec 17 '21 16:12 SchroederSteffen

Hi Steffen,

As you mentioned the tool already provides a way to exclude files/folders from the result MTA archive - the 'ignore' build parameter). If you do not want to maintain these configurations in the mta.yaml to keep it more readable, please consider transferring the corresponding settings into a mta extension file and passing it during the build.

Regards Natalia

katunin-ng avatar Dec 19 '21 11:12 katunin-ng

Hi Natalia, Thanks for the response.

I've tested it with an MTA extension file and got it working.

I created a file called .mtaignore with the following content:

_schema-version: 3.3.0

ID: app-name.ignore
extends: app-name

modules:
  - name: app-name
    build-parameters:
      ignore:
        - .*
        - "*.db"
        - "*.mta"
        - coverage
        - postman
        - src
        - test
        - Jenkinsfile
        - jest.config.json
        - mta.yaml
        - nest-cli.json
        - renovate.json
        - sonar-project.properties
        - stryker.conf.json
        - tsconfig*.json

The result is an MTA archive with the following content: image

While this works, it's far from perfect. We would have to update the .mtaignore file every time a new root folder or file is added.

I think the alternative of having an include parameter would look much nicer:

_schema-version: 3.3.0

ID: app-name.include
extends: app-name

modules:
  - name: app-name
    build-parameters:
      include:
        - dist
        - node_modules
        - package*.json

This has also security aspects by avoiding embedding of secret files into your MTA etc.

Kind regards, Steffen

SchroederSteffen avatar Dec 21 '21 14:12 SchroederSteffen

Hello, we ran into the same problem, ignore is not enough, include (and exclude for consistency) would be much nicer.

michga avatar Jul 12 '22 13:07 michga

+1 for include

ybbus avatar Nov 03 '22 09:11 ybbus