drupal-pattern-lab / patternlab-php-core

This repository provides the core functionality for Pattern Lab. It is meant to be used from within an Edition with a PatternEngine and StarterKit.
http://patternlab.io/
MIT License
2 stars 1 forks source link

Allow publicDir to be deleted and next compile recreates it #14

Closed EvanLovely closed 6 years ago

EvanLovely commented 7 years ago

Steps to recreate

composer create-project drupal-pattern-lab/edition-twig-standard ~/Desktop/test --no-interaction
cd ~/Desktop/test
# Now we have a working install
php core/console --generate
# Compile runs fine.

That sets everything up fine. Next:

rm -rf public
php core/console --generate

We get this output:

configuring pattern lab...
i can't seem to find the directory ./public...
i created ./public just in case. you can edit this in ./config/config.yml by editing publicDir...
./public/index.html is missing. grab a copy from your StyleguideKit...

This is the bug I want fixed. It should just see that stuff is missing and do what needs to be done. Here's a few more details on this: All this does is create an empty directory ./public. It wants us to grabs a new copy of our styleguidkit. When one tries to fix this, typically this is attempted:

composer install

That doesn't work either; you actually have to run:

rm -rf vendor
composer install
php core/console --generate
# Now it compiles fine

So basically if someone deletes ./public, they also need to delete ./vendor and run composer install again: which is counter-intuitive and a little time consuming.

Why I want this is so all compiled files (CSS, JS, PL, etc) can live in a single folder that can be deleted. This would not only allow a reliable clean and recompile step to be done, but allow the public folder to be placed into many other locations.

Background

These are the folders inside a working publicDir after a compile:

That patterns folder is what gets deleted and re-compiled when cleanPublic is true - not the whole publicDir folder. The rest is things like PL chrome (the StyleguideKit), so it doesn't make sense to copy it over on each compile; however, if it's missing I want it to fix it when a compile is ran.

Thoughts on this @drupal-pattern-lab/core ?

sghoweri commented 7 years ago

@EvanLovely yep, this has been one of those annoying PL thorns that's been bugging me for the longest time.

Lemme take a crack at patching this up one and for all. Seems like we might just need to call this function again after the PL config init initially runs (when anything regenerates)

FileUtil::checkPathFromConfig(self::$options["publicDir"], self::$userConfigPath, "publicDir");
sghoweri commented 6 years ago

Closing this out since @EvanLovely and I have a working solution via #15