boilr icon indicating copy to clipboard operation
boilr copied to clipboard

File existence control

Open Aluriak opened this issue 9 years ago • 4 comments

Some files could possibly be useless in some cases, like a requirement file when user always choose the options that lead to no requirements.

I can't find anything about that.

Aluriak avatar Aug 22 '16 22:08 Aluriak

Follows some API propositions.

For the template API, the following could be possible:

{{ if not UseThirdPartyLibrary }}
    {{ ignore file }}
{{ end }}

Another way could be to enrich the project.json file itself:

{
    "UseThirdPartyLibrary": [true, false],
    "path/to/requirements": { "KeepIf": "{{UseThirdPartyLibrary}}" }
}

The latter could be a good start to a more modular project.json:

{
    "Variables:" {
        "Name": "License Template",
        "Description": "Template to create licences for projects very easily",
        "Author": "Tamer Tas",
        "Year": "2015",
        "License": [
            "Apache Software License 2.0",
            "MIT", 
            "GNU GPL v3.0",
            "No license please"
        ]
    },
    "Prompt:" {
        "Name": "Project name",
        "Description": "Short description",
        "Author": "Your name",
        "License": "Pick a license"
    },
    "Files": {
        "LICENSE": "ignore if eq License \"No license please\""
    },
    "Hooks": {
        "OnStart": "script_start.sh",
        "OnFinish": "script_end.sh"
    }
}

Which is readable as:

{
    "Variables:" {
        "VariableName1AsUsedInTemplate": "default value",
        "VariableName2AsUsedInTemplate": ["acceptable", "values"]
    },
    "Prompt:" {
        "VariableName1AsUsedInTemplate": "message displayed in prompt before waiting for the variable"
    },
    "Files": {
        "path/to/file": "command allowing keep/ignore file on some variable values"
    },
    "Hooks": {
        "event name": "path/to/script/to/execute",
    }
}

Aluriak avatar Aug 22 '16 22:08 Aluriak

@Aluriak currently empty files are ignored by default

Thanks for the modular structure suggestion, my plan is to use a similar structure for boilr with multiple files such as project.json, hooks.json, and so on

tmrts avatar Jan 07 '17 15:01 tmrts

IMHO you should consider allowing both solutions : single file and multiple files. Single files are much simpler to share and manage. Multiple files are useful for large projects.

Aluriak avatar Feb 27 '17 17:02 Aluriak

@Aluriak my main focus is not to bloat the features and increase the learning curve unless its not doable in a sane manner with the current feature set. Anybody familiar with json should be able to create a template in a matter minutes. Adding multiple options to do the same thing would increase maintenance burden and the learning curve

But, like I said, if a use case is not possible without hacks, we need to provide a better solution. Hope it makes a bit more sense now

tmrts avatar Feb 28 '17 16:02 tmrts