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

Cache combined puli.json files of all installed packages #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

msojda
Copy link

@msojda msojda commented Jan 10, 2016

use Puli\Manager\Api\Package\PackageFile;
use Puli\Manager\Assert\Assert;

class CacheFile
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can add a small description about the class (and a author tag for you if you want :) ). In other classes as well.

@webmozart
Copy link
Member

This is a good start already! :) Let's extract an interface PackageProvider out of PackageManager that contains all the methods related to fetching or querying packages. We can let CacheManager extend PackageProvider.

@webmozart
Copy link
Member

Hi @msojda :) I refactored the JSON conversion a bit which should make it easier for you to implement this. Basically, you can implement JsonConverter in your own custom CacheFileConverter class and accept the JsonConverter for converting individual package files in the constructor (where we are going to inject the PackageFileConverter in Puli). This way, this should be fairly easy to solve.


foreach ($cacheFile->getModuleFiles() as $moduleFile) {
$jsonData->modules[] = $this->moduleFileConverter->toJson($moduleFile, array(
'targetVersion' => $moduleFile->getVersion(),
Copy link
Member

Choose a reason for hiding this comment

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

targetVersion is not supported here, since this is not a MigratingConverter. You can simply store it in the latest version.

@webmozart
Copy link
Member

This looks good already :) With some more work we should be able to finish this.

@msojda msojda force-pushed the json-cache branch 4 times, most recently from fba432f to 0ec12b1 Compare February 9, 2016 12:24
@msojda msojda changed the title [WIP] Cache combined puli.json files of all installed packages Cache combined puli.json files of all installed packages Feb 9, 2016
@msojda
Copy link
Author

msojda commented Apr 15, 2016

Ping @tgalopin @webmozart :)

PS. If this is good and we can progress with it I remember there was other issue we were talking about and it was related to this one.

@webmozart
Copy link
Member

Hey @msojda! What's the current status and what is needed to finish this? This PR looks good and I'd like to merge it soon.

@msojda msojda force-pushed the json-cache branch 2 times, most recently from b94e615 to d3dab6e Compare August 9, 2016 12:44
@msojda
Copy link
Author

msojda commented Aug 9, 2016

Hi @webmozart. Just updated it with the latest repository changes. Ready to go for me! 😄

@@ -625,7 +638,7 @@ public function getFactoryManager()
/**
* Returns the configuration file manager.
*
* @return ConfigFileManager The configuration file manager.
Copy link
Member

Choose a reason for hiding this comment

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

Apparently you changed all the doc blocks to remove the dots. On purpose?

While we can do this, I wouldn't do it in this PR.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I just did that cause StyleCI was failing 😞

@webmozart
Copy link
Member

That was fast! :) Thanks for the quick update. Apart from my remarks, the cached modules should actually be used in the Container class. I think they should be used wherever we now call ->getModuleManager->get*(). That means, one needs to explicitly query the module manager in order to work with the fresh modules, which should be fine.

@msojda
Copy link
Author

msojda commented Aug 9, 2016

I'll update the PR tonight. Shall I update the Container class as well or that's the thing for another PR?

PS. Will you be available on Gitter? We could prioritise next tasks then 😄

@msojda
Copy link
Author

msojda commented Aug 9, 2016

@webmozart I've done the refactoring regarding caching module list in CacheManagerImpl.

@webmozart
Copy link
Member

Cool thanks :) Yes I think it would be good if you could update the Container class as well.

@@ -1,3 +1,4 @@
{
"name": "vendor/module1",
Copy link
Author

Choose a reason for hiding this comment

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

@webmozart Added this along with tests/Api/Fixtures/root/module2/puli.json:2 cause cache file serialization was failing because of missing names. Is that the behaviour what we want? Will we have any cases where names are missing? Should we handle it another way?

Copy link
Member

Choose a reason for hiding this comment

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

Looks ok to me

@msojda
Copy link
Author

msojda commented Aug 10, 2016

Updated the PR @webmozart 😄

*/
public function getModuleFile($moduleName)
{
Assert::ModuleName($moduleName);
Copy link
Member

Choose a reason for hiding this comment

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

Typo?

Copy link
Author

Choose a reason for hiding this comment

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

Hey @webmozart - can't see any typo here..

Copy link
Member

Choose a reason for hiding this comment

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

I'm talking about the capital "M". I got the feeling you did a search-replace for "Package" → "Module" without checking the "case sensitive" checkbox ;)

@webmozart
Copy link
Member

ping @msojda

Copy link
Member

@webmozart webmozart left a comment

Choose a reason for hiding this comment

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

Looks good to me now apart from a minor issues!

*/
public function getModuleFile($moduleName)
{
Assert::ModuleName($moduleName);
Copy link
Member

Choose a reason for hiding this comment

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

case typo here, should be moduleName(

$path = $this->getContext()->getConfig()->get(Config::CACHE_FILE);
$path = Path::makeAbsolute($path, $this->rootDir);

if ($this->storage->fileExists($path) && false === $this->isRootModuleFileModified()) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer if you used ! over false === (also in line 133)

@msojda
Copy link
Author

msojda commented Jan 13, 2017

Hey @webmozart - requested changes have been done 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants