qossmic / deptrac

Keep your architecture clean.
https://qossmic.github.io/deptrac
MIT License
2.61k stars 135 forks source link

Cache directory for Cache File not created automatically #1301

Closed alexander-schranz closed 9 months ago

alexander-schranz commented 9 months ago

For caching in the CI I move all tools cache directories into an own directory var/cache/tools every tool get its own directory, in case of deptrac it is:

vendor/bin/deptrac analyse --cache-file var/cache/tools/deptrac/.deptrac.cache

But it seems like deptrac will not create the target directory ouptputs so:

PHP Warning: touch(): Unable to create file /Users/staff/Documents/Projects/int3grate.localhost/var/cache/tools/deptrac/.deptrac.cache because No such file or directory in phar:///Users/alexanderschranz/Documents/Projects/int3grate.localhost/vendor/qossmic/deptrac-shim/deptrac/src/Supportive/DependencyInjection/ServiceContainerBuilder.php on line 86

PS: there is no way to configure the cache dir via the configuration file?

gennadigennadigennadi commented 9 months ago

https://github.com/qossmic/deptrac/issues/1078 There is an issue already for „cache-file“ via config, but to implement it correctly it requires some refactoring, see the open draft PR.

Deptrac will not create the target directory, that’s correct. I would add a before_script section in the CI and do „mkdir -p path“.

You could also open a PR and implement it, the baseline directory will be created for example.

alexander-schranz commented 9 months ago

Thx for the fast reponse.

I would add a before_script section in the CI and do „mkdir -p path“.

That works only for the CI, developers running it locally will still get the error, so we would require to configure a before_script then in the deptrac.yaml else devs would run into problems. Think it would be easier then todo mkdir in PHP if the dir does not yet exists.

You could also open a PR and implement it, the baseline directory will be created for example.

If you are fine with it I would add there similar logic as for the baseline:

https://github.com/qossmic/deptrac/blob/20c23c1299db2f6efd7d35c0a28b376b55bf56a6/src/Supportive/OutputFormatter/BaselineOutputFormatter.php#L45

https://github.com/qossmic/deptrac/issues/1078 There is an issue already for „cache-file“ via config, but to implement it correctly it requires some refactoring, see the open draft PR.

Thx for linking the issue 👍