Search code examples
npmgitignoreyarnpkggem-fury

Gemfury omits folder from package when it is in .gitignore


The company I work for hosts packages on Gemfury. I've recently joined development on a JavaScript repository. Everything seems pretty standard, but I noticed quickly the build artifacts were being checked into source control. So without thinking twice, I added the dist-folder to .gitignore.

However, since then, the package hosted on Gemfury no longer contain this folder when we do a release. I've encountered this problem before with NPM packages, and was always able to solve it by adding an .npmignore file where the dist folder is not mentioned. This however doesn't help in this case, and neither does adding a "files" area in package.json (all files mentioned there show up in the package, except the dist folder).

I'm not entirely sure how Gemfury creates the package. The way use Gemfury is to push source to it (add Gemfury as remote, and git push fury master), and Gemfury supposedly picks up that it needs to do a build, and claims to be successful in this task:

Initializing build: done.
-----> Building package...
       npm package build detected
       Packing my-project-1.0.0.tgz
-----> Pushing to "my-company" account
       my-project-1.0.0.tgz ... ok
-----> Done!

That's all I've been able to find out, and I have no idea how I can make the dist-folder reappear. Adding it back to source control is not something I want to do, for obvious reasons.

The repository uses yarn and contains the following build script in package.json:

"build": "babel src -d dist -D"


Solution

  • If the method of transferring files to Gemfury is git push, and if Gemfury needs to see the dist folder, then git must know about the the dist folder.

    To keep dist folder .gitignored from source control, create a temporary branch that includes the dist folder at build time and push this branch.

    #create new branch
    git checkout -b Gemfury
    
    #force tracking of dist folder even though it is .gitignored
    git add -f dist
    git commit -m "included dist folder for Gemfury"
    

    *I'm not familiar with Gemfury