0

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"

tk421
  • 5,775
  • 6
  • 23
  • 34
Hans Roerdinkholder
  • 3,000
  • 1
  • 20
  • 30
  • Just adding the dist-folder to .gitignore would've had no effect on Git's tracking of the dist-folder and any **pre-existing** files within it, because they were previously being tracked. .gitignore only works if the files/folders to be ignored **don't already exist**. However, any future-added files/subfolders within dist-folder (added after modifying .gitignore) would be ignored. Modified files would not be ignored. If the entire dist-folder no longer exists in the repository, someone must've "git rm" or "git rm --cached" the folder. – goofology Sep 14 '19 at 17:32
  • if the dist-folder has in fact been "flagged for ignoration" (ha) from source control with .gitignore, and subsequently purged with "git rm" or "git rm --cached" and a commit, then any subsequent pushes to Gemfury would **delete** the dist-folder from Gemfury – goofology Sep 14 '19 at 17:36

1 Answers1

2

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

goofology
  • 914
  • 2
  • 10
  • 21
  • I was looking for a solution where I wouldn't have to add the folder to git, because I don't want every PR to include loads of changes to compiled files. But until proven otherwise I'll accept this answer as the only possibility. I am hoping for a solution where the dist-folder can be built remotely on Gemfury. – Hans Roerdinkholder Sep 16 '19 at 07:51
  • 1
    Apologies. Should’ve realized that specific requirement. Modified my answer. – goofology Sep 16 '19 at 13:29
  • modified git add command to include dist directory (and subdirectories), not just files in dist folder – goofology Oct 01 '19 at 19:52