jwikman / nab-al-tools

The code repository for NAB AL Tools, an AL tool for VS Code
https://marketplace.visualstudio.com/items?itemName=nabsolutions.nab-al-tools
MIT License
19 stars 8 forks source link

Create AL Project from Template - Improvements #275

Open jwikman opened 2 years ago

jwikman commented 2 years ago
fvet commented 2 years ago

Would it be possible to provide some templates / samples on how to configure the mappings for the new 'Create AL Project from Template' command?

I'm looking forward to this a lot and would like to know how to configure e.g. following scenarios and run some tests with it.


"CRS.ObjectNamePrefix": "ESC",  << needs to receive a new prefix
"alVarHelper.ignoreALPrefix": "ESC",  << needs to receive a new prefix

"id": "00000001-0000-0000-0000-000000000000",         << needs to receive a random GUID
"name": "Dynavision Template",  << needs to receive a new name
"idRanges": [
    {
      "from": 1,  << needs to receive a new from range
      "to": 1      << needs to receive a new to range
    }

"mandatoryPrefix": "ESC" << needs to receive a new prefix


{    
    "folders": [        
        {
            "path": "../ESC 365 Core/App",
            "name": "Core"
        },        
        {
            "path": "./App",
            "name": "New App Name"   << needs to receive a new name
        }
    ]
}
jwikman commented 2 years ago

Hi @fvet,

Yeah, I'm aware that a sample could be needed to understand how to use this. The template project we use internally has too much internal stuff in it so I cannot publish that template, and I just haven't had the time to mock up another template sample.

If you zip a template project and attach here, I can configure an al.template.json file for that. Maybe that could be used as a starting point of a sample, possibly published on a wiki page in this repo, if you're fine with that?

jwikman commented 2 years ago

@fvet, I forgot to mention: All above should be possible to do with this command.

fvet commented 2 years ago

Hi, enclosed a template I'm currently creating. Template.zip

Some additional things that need to be added:

The above will be covered by maintaining an 'All-In' project and let the user remove unwanted features (e.g. test app)

Based on your instructions / feedback above topics, I'll update the sample.

fvet commented 2 years ago

Update template with some (dummy) objects containing some boilerplate code. Template.zip

jwikman commented 2 years ago

@fvet I updated your (first) template files with a sample al.template.json: fvet_Template_sample.zip

With that sample, you might be able to continue to improve that template yourself?

I'll have to leave computer now, I will look at your new template later.

A lot of interesting ideas you have with improvements of the template feature, I'll look into them later as well. 👍

Just let me know if my sample wasn't enough!

fvet commented 2 years ago

@jwikman Thanks for your input, I was able to update my template. First results look promising ! Latest version : Template.zip

Some additional feedback:

image

image

"CRS.ObjectNamePrefix": "[APP_PREFIX]",
"alVarHelper.ignoreALPrefix": "[APP_PREFIX]",
theschitz commented 2 years ago

@jwikman I can't remember where we landed on this this topic but I think we pretty much agreed on that having a template-app in the repo would be nice. May I suggest that @fvet submits the template app as PR with the template when you two deem it "good enough"?

Suggested location: ./template-app

jwikman commented 2 years ago

@fvet I'm glad you could move forward on this.

  • [ ] Maybe a Visible or Editable property could be added to a mapping entity. This would prevent a user from seeing / changing the app id's. (These 'technical' mappings are of less importance for the user creating a new project)

Very good idea, I added this to the initial comment in this issue.

  • [ ] For some unknown reason, the [APP_PREFIX] is not applied on my settings.json file?

Hmm... This was strange. I can see that I have a repro on this, let me investigate some more...

  • [ ] (Nice to Have) Run some tasks after the app has been created. Would be good if we can run the 'CRS : Rename - All Files' at the end.

I see that @theschitz picked this idea directly! Let's see what he comes up with on this topic. 🙂 I understand that it needs some effort to accomplish this with the use of several renameFiles settings in al.template.json, but it should be possible as well, don't you think?

jwikman commented 2 years ago

@jwikman I can't remember where we landed on this this topic but I think we pretty much agreed on that having a template-app in the repo would be nice. May I suggest that @fvet submits the template app as PR with the template when you two deem it "good enough"?

Suggested location: ./template-app

@theschitz, I think it's a very good idea. That would be easier to pick up on, compared to a wiki page. What do you say about that @fvet?

jwikman commented 2 years ago

@fvet, this thread might already be hard to follow, but I'll try to address each of your suggestions here anyway

  • [ ] If the (main) app receive a new app id, this should be added in the dependencies of the test app (if test app is required)
  • [ ] If the test app receive a new app id, this should be added in the internalsVisibleTo of the main app (if test app is required)
  • [ ] Test app will not always be added. (especially for PTE apps) This should result in the above steps to be conditional. (and maybe delete the \Test folder)

We do not have any support for conditions (yet?). In our company, we currently solve this by:

  1. Using different templates for PTEs and AppSource apps (having Test app in both 😉)
  2. Both above templates are as 'complete" as possible (including internalsVisibleTo etc). If there are something that is, for some reason, not needed for a particular app we just remove that from the app after converted from template.
  • [x] Add default (installer / internal module framework) codeunits with some boilerplate code. These will be named "Codeunit 50000 ESCX Installer" and should be renamed (prefix) + renumbered upon by the command.
  • [x] Add default enum with a new module value. This will be named "Enum 50000 ESCX Module" and should be renamed (prefix) + receive an enum value (from range) and enum name (short app name / module name) upon by the command.

It seems as you're happy with these already. 👍

  • [ ] (Later) Add default pipeline (yaml). This will contain a reference to an external yaml template (separate repo) that will contain a dedicated pipeline for this repo (including any specific dependencies)

We include a yaml template file in our template, with settings replaced as any other placeholderSubstitutions.

  • [ ] (Nice to Have) Run some tasks after the app has been created. E.g. Authorize app with AL Object ID Ninja, Synchronize objects (after they have been renamed) with AL Object ID Ninja, ...

Tracked in #302

fvet commented 2 years ago

@jwikman If I've any new suggestions, I'll open separate new issues to ease tracking ;)

For the template, I'll await the fix for the settings file and will duplicate my project and anonymize the settings (or add 'NAB' as publisher instead).

jwikman commented 2 years ago

@jwikman If I've any new suggestions, I'll open separate new issues to ease tracking ;)

Might be a good idea! 😅

For the template, I'll await the fix for the settings file and will duplicate my project and anonymize the settings (or add 'NAB' as publisher instead).

Super!

The settings fix should be available by now, does it not turn up for you if you select the "Install another Pre-Release version"? image image

And a hidden property is soon available in a new pre-release 🙂