Skip to content

Working solution to regenerate missing styleguideKit index.html in the public directory #15

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

Merged
merged 3 commits into from
Sep 3, 2017

Conversation

sghoweri
Copy link
Collaborator

Solves #14 if we are ok with this only getting triggered if the index.html file is missing in our public directory (vs check if every single styleguidekit asset is in it's proper place).

I'm also not a huge fan of having to hard-code the dist folder to guess which specific files need to get copied over but the baked in mechanism getting used in PL to normally handle this is so incredibly tied in with the composer install events, this was the simplest solution I could come up with without trying to impersonate composer (or something even crazier) @_@

To test locally, update your composer.json file to point at this feature branch, remove your vendor folder + composer.lock file and go through the steps from the original ticket.

"require": {
	"php": ">=5.4",
	"pattern-lab/core": "dev-feature/resilient-public-dir as 2.0.0",
	"pattern-lab/patternengine-twig": "^2.0.0",
	"pattern-lab/styleguidekit-assets-default": "^3.0.0",
	"pattern-lab/styleguidekit-twig-default": "^3.0.0"
},

Should now work as expected!

Author's note: OMG TABS & WHITESPACE AHHHHH

… Default files in the public dir if entire directory gets wiped. Solves #14
@sghoweri sghoweri requested review from EvanLovely and aleksip August 26, 2017 17:09
@sghoweri sghoweri changed the title Working solution to regenerate missing StyleguideKit Index.html in the Public Directory Working solution to regenerate missing StyleguideKit index.html in the Public Directory Aug 26, 2017
@sghoweri sghoweri changed the title Working solution to regenerate missing StyleguideKit index.html in the Public Directory Working solution to regenerate missing styleguideKit index.html in the public directory Aug 26, 2017
@EvanLovely
Copy link

@sghoweri Nice work! I can confirm it works, but I bet we can get paths in a more resilient way. I just added commit 0eace9e to this that adds a $kit_path var that is an absolute path to the styleguide kit folder in the vendor directory, so we should be able to reduce some lines. Can we get it so we don't need that $base var? Would be nice to not have to rely on the brittleness of /../../../.

@sghoweri
Copy link
Collaborator Author

sghoweri commented Sep 2, 2017

@EvanLovely can you take another look at this when you get a chance?

Unfortunately the $kit_path variable you added actually points to the /vendor/pattern-lab/styleguidekit-twig-default package instead of the OTHER styleguideKit we actually need here (styleguidekit-assets-default, or whatever is currently installed).

I consolidated that little bit of logic to now use the baseDir config option instead which should hopefully be a little less prone to breaking. Lemme know what you think!

Copy link

@EvanLovely EvanLovely left a comment

Choose a reason for hiding this comment

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

Nice work! Everything works!

@EvanLovely EvanLovely merged commit ed89147 into master Sep 3, 2017
@EvanLovely EvanLovely deleted the feature/resilient-public-dir branch September 3, 2017 18:21
@EvanLovely
Copy link

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.

3 participants