alirezanet / Husky.Net

Git hooks made easy with Husky.Net internal task runner! 🐶 It brings the dev-dependency concept to the .NET world!
https://alirezanet.github.io/Husky.Net/
MIT License
684 stars 31 forks source link

feat: compile scripts #37

Closed acesyde closed 2 years ago

acesyde commented 2 years ago

Description

Fixes # (issue)

28

Type of change

Checklist

acesyde commented 2 years ago

Todo :

alirezanet commented 2 years ago

Awesome! very good draft. It might need a little bit of refactoring and code splitting but generally, it looks good.

few suggestions:

I think we should consider a few things where we save the cache files:

1- The compiled CSX files should have an extension like SomeNameOrHash.sdll (feel free to suggest a better extension I'm not sure there is a standard for this or not) 2- To visually relate the compiled files to CSX files we can use the actual script file name with our custom extension and save the hash value to an attribute on that file. this way later on we could have an auto cleanup process. e.g linter.sdll <- linter.csx. (we can find the compiled DLLs using their name and validate them using the attribute)

These changes open the possibility to directly support compiled scripts later.

well done. 💐

acesyde commented 2 years ago

1- The compiled CSX files should have an extension like SomeNameOrHash.sdll (feel free to suggest a better extension I'm not sure there is a standard for this or not)

Hmm sdll is like snupkg, the s prefix means source in my brain and it's not the case here, why not just .csx.dll ?

2- To visually relate the compiled files to CSX files we can use the actual script file name with our custom extension and save the hash value to an attribute on that file. this way later on we could have an auto cleanup process. e.g linter.sdll <- linter.csx. (we can find the compiled DLLs using their name and validate them using the attribute)

Nice idea ❤️

Yes I'll split the compiler from the executor

alirezanet commented 2 years ago

Hmm sdll is like snupkg, the s prefix means source in my brain and it's not the case here, why not just .csx.dll ?

I suggested sdll as an example to get more ideas ... but the problem with something like .csx.dll is, windows don't see the first part and categorize this as a normal DLL, in other words, the .csx section is not part of the extension, its a file name suffix. hdll for example could be another option that stands for Husky DLL. Naming things is hard :)

acesyde commented 2 years ago

You're right 😄 , I suck at naming things, for the moment i'll use .sdll but before merging this PR we have time to find another extension or not

acesyde commented 2 years ago

@alirezanet I found an usefull compiler can be integrated without any modifications dotnet-script with caching engine 😲

{
         "name": "doc-generator",
         "group":"pre-commit",
         "command": "dotnet",
         "args": [
            "dotnet-script",
            ".husky/csx/doc-generator.csx"
         ]
      }

I think we can use this one instead of the embedded what do you think ?

alirezanet commented 2 years ago

@alirezanet I found an usefull compiler can be integrated without any modifications dotnet-script with caching engine 😲

{
         "name": "doc-generator",
         "group":"pre-commit",
         "command": "dotnet",
         "args": [
            "dotnet-script",
            ".husky/csx/doc-generator.csx"
         ]
      }

True, it exists but I've tried to support this feature internally because first, not everyone are familiar with these tools and second it is easier for users to use internal husky features without downloading and installing extra dependencies.

also, I don't think it has a good caching mechanism, It will cache the scripts temporarily for the second call but it doesn't keep cache files properly. (I didn't check it recently but in the past I had a lot of problems with its cache system)

I think we can use this one instead of the embedded what do you think?

We can't. simply because we don't have enough permissions to install other tools for the end-user and we should be independent to external tools.