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

Detect octane availability in composer.json, flavors through binaries… #29

Merged
merged 6 commits into from
Apr 2, 2024

Conversation

KTanAug21
Copy link
Contributor

…, include build

What:
Detect whether to configure octane or not! Include flavor detection as well. Set --octane= flag

Why:
Octane usage can be detected through composer.json, and flavor can be detected by flavor binaries included in the project.
SO why not? If it's configured locally in the project. We can include it in the Dockerfile.

@KTanAug21
Copy link
Contributor Author

Need to add test!

Copy link

@Johannes-Werbrouck Johannes-Werbrouck left a comment

Choose a reason for hiding this comment

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

It should work, just had some minor suggestions. This is starting to look really good!


public function composerJsonContent( $directory )
{
$path = $directory.'/composer.json';

Choose a reason for hiding this comment

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

It's not a big difference, but I don't really see why you don't add this in the octaneFlavor function? If you add it there, if you can't find the file you can stop the octaneFlavor function right there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So some notes on why I separated reading the composer content into it's own function:

  1. Re-usability

Aside from the octaneFlavor(), the GenerateCommandTest also makes use of the same snippet for reading composer content that I extracted to the function above. In the future, there might be other features that would read the composerjson's content. Soo, we can reuse this function for those as well with a simple call to the composerJsonContent function

  1. Logic Isolation

If you would notice, the code snippet in octaneFlavor() function only focuses on octane detection. Even though it relies on the composer.json's contents to do it's detection, there's no detailing on how to read the composer file--because it's already determined by calling the composerContentJson() function! I find this neat, as the octaneFlavor() function can just focus on showing its main feature, which is octane+flavor detection, while it can call helper functions like the composerContentJson to do other related, reusable dependencies extraction/calculation/processing.

Note on stopping the detection:
I think it's beneficial that the octaneFlavor() function shows the reason for stopping the detection, which is yknow, after reading that there's no octane in the composer content it retrieved.

*/
public function octaneFlavor( array $options )
{
// TODO: OCTANE which laravel versions are actually compatible? 11

Choose a reason for hiding this comment

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

Should we even check if the laravel and octane versions are compatible? The user has installed them so why would we not follow their setup?

Copy link
Contributor Author

@KTanAug21 KTanAug21 Apr 1, 2024

Choose a reason for hiding this comment

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

Yuup you've got a point there! I was deliberating whether it's a necessary evil or not.
Since Octane is only available for later Laravel versions starting from 8, other previous versions might not work with octane at all. Since we already detect the Laravel version of a project, it seemed that including octane detection for those other versions did not make sense. Octane might not even be configured, and in the up chance there's a binary in there, or a laravel/octane in composer, would the Dockerfile created with octane snippets even work, like, will there be dependencies not available in previous Laravel versions required by the Octane setup, causing errors in building the dockerfile when it comes to that point?

What you think?

Kathryn Anne S Tan added 5 commits April 1, 2024 20:32
…rtant in detecting options that rely on existence of file i.e octane flavors; Create test folders for 10 and 11 octane flavors; Include octane-flavor-files(used in detecting the flavors) in the list of files to ignore for matching during test
…iles only when successful, since file generated will help as reference when a test fails
@KTanAug21 KTanAug21 merged commit 92207a3 into main Apr 2, 2024
2 checks passed
@KTanAug21 KTanAug21 linked an issue Apr 2, 2024 that may be closed by this pull request
@KTanAug21 KTanAug21 mentioned this pull request Apr 2, 2024
@KTanAug21 KTanAug21 deleted the detect_octane branch April 25, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect Octane Flavor
2 participants