DEV Community

Michael Z
Michael Z

Posted on

CI/CD Workflows for open source NPM packages

My Workflow

I've created two workflows to manage an open source NPM package of mine.

CI

This workflow runs tests and creates a test coverage report when pushing code or creating/updating pull requests.

CD

This workflow publishes a package to NPM for you. The cool thing is that all you have to do is create a release on GitHub.

It updates the version in package.json for you automatically. The workflow also let's you publish multiple versions (Say your project is on version 2 but you still want the possibility to publish patches to version 1).

Submission Category:

DIY Deployments

Yaml File or Link to Code

GitHub logo MZanggl / flooent

Fluent interface to provide an expressive syntax for common manipulations.

flooent

npm bundle size latest version Coverage Status

Fluent interface to provide an expressive syntax for common manipulations Rather than enforcing a different paradigm, flooent builds upon and extends the native capabilities of various JavaScript objects.

Given you have logical, procedural, "hard to visualize" code like this:

// given we have const path = 'App/Controllers/user.js'
const filename = path.substring(path.lastIndexOf('/') + 1)
let name = filename.substring(0, filename.lastIndexOf('.'))
if (!name.endsWith('Controller')) name+= 'Controller'
return name.substring(0, 1).toUpperCase() + name.substring(1)
Enter fullscreen mode Exit fullscreen mode

refactor it into plain English

// given we have const path = 'App/Controllers/user.js'
given.string(path)
  .afterLast('/')
  .beforeLast('.')
  .endWith('Controller')
  .capitalize(
…
Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

I've posted three articles describing the set up and what I learned along the way:

Top comments (0)