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

[FEATURE] Introduce target file support for processed source files #54

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

eliashaeussler
Copy link
Member

Feature description:

This PR introduces a new schema configuration "target" for file conditions within step configuration for processed source files and processed shared source files. It allows to override the default path determination behavior, e.g. when multiple files exist as source files, while they should have the same target name, depending on a given file condition.

Example:

  • Two source files LICENSE.GPL-2.0.txt and LICENSE.GPL-3.0.txt exist.
  • Both files must be named LICENSE.txt in the resulting project.
  • The file processing itself depends on given conditions:
    • If the user selects "GPL 2.0" as license, LICENSE.GPL-2.0.txt will be processed
    • If "GPL 3.0" is selected, LICENSE.GPL-3.0.txt will be processed

Example configuration:

steps:
  - type: processSourceFiles
    fileConditions:
      - path: 'LICENSE.GPL-2.0.txt'
        if: 'project["license"] == "GPL-2.0"'
        target: 'LICENSE.txt'
      - path: 'LICENSE.GPL-3.0.txt'
        if: 'project["license"] == "GPL-3.0"'
        target: 'LICENSE.txt'

properties:
  - identifier: project
    name: Project
    properties:
      - identifier: license
        name: License
        type: select
        options:
          - value: GPL-2.0
          - value: GPL-3.0

@eliashaeussler eliashaeussler added the enhancement New feature or request label Dec 7, 2022
@eliashaeussler eliashaeussler self-assigned this Dec 7, 2022
@codeclimate
Copy link

codeclimate bot commented Dec 7, 2022

Code Climate has analyzed commit a4aabed and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 83.4% (0.1% change).

View more on Code Climate.

@codecov
Copy link

codecov bot commented Dec 7, 2022

Codecov Report

Merging #54 (a4aabed) into develop (1672296) will increase coverage by 0.08%.
The diff coverage is 100.00%.

@@              Coverage Diff              @@
##             develop      #54      +/-   ##
=============================================
+ Coverage      83.34%   83.43%   +0.08%     
- Complexity       563      567       +4     
=============================================
  Files             84       84              
  Lines           1519     1527       +8     
=============================================
+ Hits            1266     1274       +8     
  Misses           253      253              
Impacted Files Coverage Δ
src/Builder/Config/ValueObject/FileCondition.php 100.00% <100.00%> (ø)
...er/Generator/Step/ProcessSharedSourceFilesStep.php 100.00% <100.00%> (ø)
.../Builder/Generator/Step/ProcessSourceFilesStep.php 100.00% <100.00%> (ø)
...rc/Builder/Generator/Step/ProcessingFilesTrait.php 100.00% <100.00%> (ø)
src/Builder/Writer/GenericFileWriter.php 100.00% <100.00%> (ø)
src/Builder/Writer/TemplateWriter.php 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

This commit introduces a new schema configuration "target" for file
conditions within step configuration for processed source files and
processed shared source files. It allows to override the default
path determination behavior, e.g. when multiple files exist as
source files, while they should have the same target name, depending
on a given file condition.

Example:

Two source files `LICENSE.GPL-2.0.txt` and `LICENSE.GPL-3.0.txt` exist.
Both files must be named `LICENSE.txt` in the resulting project.
The file processing itself depends on given conditions: If the user
selects "GPL 2.0" as license, `LICENSE.GPL-2.0.txt` will be processed,
if "GPL 3.0" is selected, `LICENSE.GPL-3.0.txt` will be processed.

Example configuration:

steps:
  - type: processSourceFiles
    fileConditions:
      - path: 'LICENSE.GPL-2.0.txt'
        if: 'license == "GPL-2.0"'
        target: 'LICENSE.txt'
      - path: 'LICENSE.GPL-3.0.txt'
        if: 'license == "GPL-3.0"'
        target: 'LICENSE.txt'
Copy link
Collaborator

@mteu mteu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM 👍 🚀

@mteu mteu merged commit bf75d0e into develop Dec 14, 2022
@mteu mteu deleted the feature/target-file branch December 14, 2022 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants