SAP / open-ux-tools

Enable community collaboration to jointly promote and facilitate best in class tooling capabilities
Apache License 2.0
83 stars 35 forks source link

FEATURE - switch archive command to use a deny list and include dot files #713

Closed cfg74 closed 1 year ago

cfg74 commented 1 year ago

As a developer, I want to be able to zip/download all files of a project in BAS including configurations in dot files, so that I can upload and run it in a different devspace

Description

Currently the archive command excludes node modules, git configurations and .env files but also excludes all dot files. In some cases vital configurations are stored in dot files, and losing them on transfer makes the project not work at the destination, e.g. the .cdsrc.json file in CAP projects roots

Proposal is to include all dot files into the archive, but exclude specifically the ones mentioned above.

Technical Design

Requires update of module @sap-ux/environment-check to include dot files.

Acceptance Criteria

GivenWhenThen format (https://martinfowler.com/bliki/GivenWhenThen.html)

Given I have a zip archive created from a project with dot file configurations when I execute the "Archive Project" command then the project copy is fully functional in the target

Notes

Tasks

cfg74 commented 1 year ago

@Klaus-Keller fyi.

Klaus-Keller commented 1 year ago

The code to archive a project is in module @sap-ux/environment-check. The glob that controls what is included and excluded is here:

https://github.com/SAP/open-ux-tools/blob/fdd0d0c3ef5650ba62908a4e565160cc701fb77f/packages/environment-check/src/output/zip.ts#L90-L95

The globOptions can be enhanced by dot: true to include hidden files starting with ., see https://www.archiverjs.com/docs/archiver#glob -> https://github.com/yqnn/node-readdir-glob#options. However, all hidden files would be included then and it is likely, that we would archive files that contain secrets. We exclude already .env, but there might be more files that we are not aware of.

Proposal: if we find a .gitignore file, read it and apply the glob rules from it to exclude folders and files from the archive. If we do not find .gitignore, fall back to a deny list to exclude known files, like currently .env.

cfg74 commented 1 year ago

@tobiasqueck @Klaus-Keller any update on this topic?

Klaus-Keller commented 1 year ago

@cfg74 I think this is ready to be assigned, technical proposal for this feature was discussed and seems to be agreed on:

Klaus-Keller commented 1 year ago

PR https://github.com/SAP/open-ux-tools/pull/878 has been merged and will be consumed in Application Modeler extension. Closing this issue.