Development

This module is a C++ wrapper around the Zint barcode libraryopen in new window. The version of zint that will be used will be determined by the git reference stored in the zintVersion field of package.json.

Source code management

Upon installation of dependencies (yarn install), a copy of the Zint source repo will be cloned in the Git-ignored .zint directory, and its relevant C source files are referenced in binding.gypopen in new window, along with src/binding/main.cppopen in new window. The compiled .node module is then available for use by the JavaScript source, in src/index.jsopen in new window.

Once .zint is created, the same install script will then apply a small number of patches to some Zint source files to adapt it to the following needs:

  • Add rendered_data as a char array to be populated with raw string output.
  • Update svg.c and ps.c to write to the rendered_data buffer instead of stdout.
  • Replace malloc.h references with stdlib.h for cross-compatibility.

See scripts/install.jsopen in new window and scripts/patches.jsopen in new window for more info.

Utilization of Nan

This project utilizes Nanopen in new window to make the project backwards-compatible and make bindings future-proof.

Building the project

Builds are created using node-pre-gypopen in new window.

Upon installation of dependencies, node-pre-gyp build will be run, which will compile the project from source.

Building on Windows

If you're using Windows (excluding WSLopen in new window), then you'll need to install windows-build-toolsopen in new window to compile the native Node module.

npm install --global --production windows-build-tools --vs2017
npm config set msvs_version 2017 –global

This install takes a while, but once it's complete, you can move on to Creating a build below.

Creating a build

To create a packaged build, run:

yarn package:binary

Running tests

Tests are written as *.test.js and utilize Jestopen in new window.

Both unit and e2e tests are written for this project. To run all tests:

yarn test

Unit tests

Unit tests are specified in the __tests__ subdirectories under src.

To run unit tests:

yarn test:unit

Test coverage results are sent to Codecovopen in new window.

e2e tests

e2e tests are specified in the test/e2e directory. They utilize jest-image-snapshotopen in new window for comparisons of barcode images in tandem with the helper test method, createImageFile.

To run e2e tests:

yarn test:e2e

Committing

Commit message standards abide by standard-changelogopen in new window. This module utilizes commitizenopen in new window as a devDependency to help developers write their commits, and commit messages are enforced using commitlintopen in new window.

Versioning

This package abides by the semver standardopen in new window. standard-versionopen in new window will automatically update CHANGELOG.mdopen in new window and bump the version.

Automated builds and CI

GitHub Actions will automatically build and test pull requests. At least one admin PR approval and all status checks are required to merge a PR.

The following status checks are implemented:

  • Successful Windows builds (AppVeyor)
  • Successful Linux and macOS builds (Travis)
  • Sufficient code coverage (threshold >90%)

Upon the successful merge of a PR, CI will create an automated release of the binaries on GitHub (via node-pre-gyp-githubopen in new window), publish to npm, and push the updated changelog and version bump changes to GitHub.

Important

The package version is automatically updated. Do not change any version references in this project.

Contributing

All constructive feedback and pull request changes are welcome. For more information on contributing to this project, please see the Contributing Guidelinesopen in new window.