harp icon indicating copy to clipboard operation
harp copied to clipboard

Compile doesn’t ignore www/

Open kennethormandy opened this issue 11 years ago • 12 comments

Root-style apps with a compile www/ directory will have the www/ compiled within it then next time, until Harp finally throws an error. Eventually, you can end up with www/www until you get:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: ENOENT, open '/Users/Kenneth/Sites/kennethormandy/eventuell/www/.git/HEAD'

kennethormandy avatar Jul 03 '14 01:07 kennethormandy

Is the idea that harp is not meant to be used as a "root-style" app? I notice that when I run harp compile that the .git folder ends up in www. I was hoping to be able to have a workflow of harp compile + aws s3 sync www s3://bucket, but I don't want to be serving my git config to the public.

Is the only way to avoid this to keep my harp app nested one folder deep within my project?

howardroark avatar Mar 08 '15 00:03 howardroark

I am also irked that my .git folder is ending up in www. There are a lot of ways in which the "root style" is more natural :elephant:, but root style apps at the top level of a git or mercurial repo are broken.

I appreciate the strong convention over configuration stance, but it really seems like an ignore key is needed in _harp.json for root-style apps.

:elephant:

  • Github resolves absolute paths like "/media/rickroll.gif" relative to the repo root
  • prose.io does the same.

edrex avatar Mar 12 '15 17:03 edrex

If .git files are being copied its a bug.

sintaxi avatar Mar 12 '15 18:03 sintaxi

Here is the line that is happening. https://github.com/sintaxi/harp/blob/7a09952fb461b75188450629113333f794d70b26/lib/helpers.js#L315

There is really no reason to compile that regex for every file.

silentrob avatar Mar 12 '15 18:03 silentrob

Added failing tests for omitting .git and www in #427. Thanks for providing awesome support all around guys.

edrex avatar Mar 17 '15 18:03 edrex

Thanks @edrex! Very helpful.

sintaxi avatar Mar 17 '15 22:03 sintaxi

I can take a crack at fixing. Is processing www/confirmed as incorrect behavior?

edrex avatar Mar 18 '15 18:03 edrex

Seems like adding the .git pattern to terraform.helpers.shouldIgnore would work.

For the output dir, harp should be smart enough to ignore a user-specified output dir if it is in the project dir.

edrex avatar Mar 18 '15 18:03 edrex

@silentrob I think that check is about preserving a .git dir in the output path. Probably to support github pages deployment?

edrex avatar Mar 18 '15 18:03 edrex

Is there any need for "dot files" to ever end up in the compiled output? I guess .htaccess could be one.

howardroark avatar Mar 18 '15 19:03 howardroark

also .well-known. people might get annoyed if harp switched to a whitelisting approach and they needed one that wasn't on the list.

edrex avatar Mar 18 '15 20:03 edrex

Ok so I pushed some harp tests that more specifically target the problem behavior.

When outputPath is in projectPath and outputPath contains a .git dir, the .git dir is copied because:

  1. helpers.prime skips deleting it.
  2. terraform.helpers.shouldIgnore doesn't ignore it.

2 is a bug, fixed in sintaxi/terraform#84

Also included a test that .git in the project dir isn't copied, failing because of 2.

Possibly, harp should add a check to see if a target file is under outputPath before acting on it, but generally helpers.prime ensures that outputPath is empty except for .git dirs.

Ready for review.

edrex avatar Mar 18 '15 20:03 edrex