hornta
hornta

Reputation: 165

Installing a package from a GitHub repository

My problem is that when I try to install a package of mine with the version set to a certain git branch my build is breaking because the repository doesn't house the dist folder which my npm package does.

Here is how I want to install the package. @me/myPkg": "github:me/myPkg#myBranch

So should my repository include the dist folder or what's the best practice in this case? I don't want to publish my dist package onto github because then I would have weird merge conflicts because the dist folder is containg all of my type declaration and minified javascript files, but maybe this the preferred way?

Another thought I had was to have a postinstall script in my package.json which built the source files but then I would have to have the devDependencies installed as well and npm install doesn't install them for dependencies.

Upvotes: 2

Views: 1212

Answers (1)

Steve -Cutter- Blades
Steve -Cutter- Blades

Reputation: 5422

How are you publishing your package? For instance, I have a GitHub Actions setup on my repositories that, when commits are made to master, will automatically perform several steps

  • Run an npm install Setup Git Credential variables (for later process)

  • Run npm test (and fail whole process if tests fail)

  • Run npm run release (I use standard-version for auto version incrementing and Changelog creation, and do this prior to build so the version can be reflected in the built code)

  • Run npm run build

  • Run npm run publish to push to npm

  • Commit my version update as a tag to Git

My GitHub Action does all of this in a temp container it spins up for the build process. Once it is done, the whole container is tossed. I use an .npmignore file to tell publish what I don't want in the final package (note files, build tools, etc).

Upvotes: 1

Related Questions