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

Rearrange src/commands directory following the new conventions #165

Merged
merged 25 commits into from
Nov 2, 2021

Conversation

tom-combet
Copy link
Contributor

Rearrange src/commands directory following the new conventions defined in issue #85.

@tom-combet tom-combet requested review from SebSept, a user, nenes25 and jf-viguier and removed request for a user September 22, 2021 13:00
@tom-combet
Copy link
Contributor Author

tom-combet commented Sep 22, 2021

Question: Should we add a convention that requires a verb for the action?
It looks quite messy when we have EmployeeList and ProductLatest at the same time. If we apply this convention, it becomes ProductListLatest.

The drawback I see is that the command names will be longer. Unless we apply this convention for class names only, but we would have a problem of consistency.

@ghost
Copy link

ghost commented Oct 7, 2021

I dont test all commands but a lot it's ok for me !

Can you rebase the PR for the conflicts

@tom-combet tom-combet requested a review from a user October 7, 2021 08:30
@SebSept SebSept marked this pull request as draft October 7, 2021 09:01
@SebSept
Copy link
Contributor

SebSept commented Oct 7, 2021

Converted to draft.
MUST NOT be merged now because it introduce breaking changes.
And we should also have a phpstan to ensure commands respect the schema.
@Kaudaj is currently working on a validator that could be used inside the phpstan rule I created. #96

There is (at least) 2 different ways to switch the command names :

  • raw : just change and let users change there scripts and habits
  • shadow current commands with a 'redirect' to the current name + a deprecation warning ( à la Symfony ) if possible. Then remove the shadows in the next major release.

@tom-combet
Copy link
Contributor Author

tom-combet commented Oct 7, 2021

* shadow current commands with a 'redirect' to the current name + a deprecation warning ( à la Symfony ) if possible. Then remove the shadows in the next major release.

It would be hard work but I can do it progressively. Are you referring to this documentation?

@SebSept
Copy link
Contributor

SebSept commented Oct 7, 2021

I don't think it will be hard.
I did not study this point.
I suppose that's not so difficult. Maybe I'm wrong, will see...

@tom-combet
Copy link
Contributor Author

I don't think it will be hard. I did not study this point. I suppose that's not so difficult. Maybe I'm wrong, will see...

Not so hard, but quite long. I'll have to retype every old command class name, name and service name to mark them as deprecated if I understand well. I'm gonna study it after validator step.

@tom-combet
Copy link
Contributor Author

tom-combet commented Oct 11, 2021

/!\ Need your opinion /!\

@SebSept @okom3pom @jf-viguier @nenes25

I moved the validator in a Validators folder. Is it adequate? Should it be more general like Tools for instance?

@SebSept
Copy link
Contributor

SebSept commented Oct 12, 2021

Too general names are subject to become a mess.
The fact that this validator is used for code quality, for checking must be clear.
This validator mustn't be in the same folder as the user code.

fyi, I worked on this subject with @Kaudaj , and this validator will be used via a phpstan rule.

@SebSept
Copy link
Contributor

SebSept commented Oct 12, 2021

Notice, you can have a "dev-autoload" section in composer.json

@tom-combet
Copy link
Contributor Author

Looks like PrestaShop put Validation classes in src folder, same for PrestaShop modules.
@SebSept Do you still think we should put it aside? I found no resources at all about this topic.

@SebSept
Copy link
Contributor

SebSept commented Oct 15, 2021

the src folder is currently perfectly clean, adding the validator doesn't look good to me.
Maybe another folder, not src, what does Symfony do for this purpose (testing tools) ?

@tom-combet
Copy link
Contributor Author

The most relevant documentation I found is about Validator component.
I can't find any folder recommandation. Symfony stores it in src/Component/Validator folder.

Or maybe I missunderstood, what do you mean exactly by testing tools?

@SebSept
Copy link
Contributor

SebSept commented Oct 18, 2021

The Validator in a class for the main Symfony code, not for testing Symfony, so it's normal to find it in src.

Here https://github.com/symfony/symfony/tree/5.4/src/Symfony/Component/Dotenv we can see a folder Tests, it looks like the tests folder are at the same of the components, in a src folder. (it will be src/Tests/Validator for us, because it's a generic test)
For prestashop, tests are at the root.

Having a test folder at the level looks good but is not the PrestaShop way.

So it's possible to :

  • create a tests folder : require additionnal autoload config. | easy to remove the tests for the release
  • create tests folder at the component level : no additonnal autoload | more complicated/risky to remove for release.

...

@tom-combet
Copy link
Contributor Author

tom-combet commented Oct 18, 2021

Ok so if I follow you, we put it in tests/Validator folder?
Tests autoload configuration is already set in composer.json btw.

@SebSept
Copy link
Contributor

SebSept commented Oct 18, 2021

Yep, looks good to me.
WDYT @nenes25 ?

@nenes25
Copy link
Member

nenes25 commented Oct 18, 2021

@SebSept yes i agree with your point of view.
With this way we can clean the release of all tests easily 😄

@tom-combet
Copy link
Contributor Author

@SebSept @nenes25 Validator has been relocated.
Could we merge this PR in priority? It was very annoying to rebase, I wish I didn't have to do it again... 😅

@SebSept
Copy link
Contributor

SebSept commented Oct 22, 2021

I let others do the job as I'm on holiday 😎

@ghost
Copy link

ghost commented Oct 23, 2021

The status is draft ?

@SebSept
Copy link
Contributor

SebSept commented Oct 23, 2021

Command name's will change, right ?

@tom-combet
Copy link
Contributor Author

Command name's will change, right ?

What do you mean exactly?

@SebSept
Copy link
Contributor

SebSept commented Oct 23, 2021

'fop:debug-mode' is not available anymore. It's replaced by 'fop: environment:debug-mode'
So scripts calling this commnad will break.
That's a breaking change, unless there is backward compatibility.
It's easy to achieve with $this->setAlias().

@tom-combet
Copy link
Contributor Author

'fop:debug-mode' is not available anymore. It's replaced by 'fop: environment:debug-mode' So scripts calling this commnad will break. That's a breaking change, unless there is backward compatibility. It's easy to achieve with $this->setAlias().

Ah yea ok, I forgot that! Thought you wanted to change command names again.
Commands aliases are set up. Also, service name will change. Is it a BC break too? I don't think we can set aliases for this.

@SebSept
Copy link
Contributor

SebSept commented Oct 24, 2021

I guess, there is no need to set alias for services, this is not really services but just commands declarations.

@SebSept
Copy link
Contributor

SebSept commented Oct 24, 2021

The next step will be to emit deprecation warnings but that could be done in another PR.

@tom-combet
Copy link
Contributor Author

tom-combet commented Oct 24, 2021

The next step will be to emit deprecation warnings but that could be done in another PR.

Do you mean in the code with PHPDoc deprecated keyword? I don't really see how to warn user in console output...

@SebSept
Copy link
Contributor

SebSept commented Oct 24, 2021

I mean in console output.
We'll fond a way to do it probably.

@tom-combet
Copy link
Contributor Author

@SebSept I have added a deprecated warning, please check when you can.

@SebSept
Copy link
Contributor

SebSept commented Oct 25, 2021

Good 👍
Maybe you can write in "version 2" instead of "soon"

@SebSept SebSept marked this pull request as ready for review October 25, 2021 09:02
@ghost ghost self-requested a review October 25, 2021 11:10
@SebSept
Copy link
Contributor

SebSept commented Oct 25, 2021

I updated the issue, not a draft anymore, since there is no breaking change.

@SebSept SebSept linked an issue Oct 30, 2021 that may be closed by this pull request
Copy link
Contributor

@SebSept SebSept left a comment

Choose a reason for hiding this comment

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

Great job !
I can see backward compatibility is ok.
You've made some tests 🎉 👍🏼
I've just tested a few commands, look good to me :)

Copy link
Member

@nenes25 nenes25 left a comment

Choose a reason for hiding this comment

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

Good Job !
It's fine to me too 🎆
I've discovered when testing that if you use the command bin/console list fop alias are listed too. 😄

@SebSept SebSept merged commit e033a3c into friends-of-presta:dev Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emit deprecation warnings for renamed commands.
3 participants