# Development

This module is a C++ wrapper around the Zint barcode library (opens 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.gyp (opens new window), along with src/binding/main.cpp (opens new window). The compiled .node module is then available for use by the JavaScript source, in src/index.js (opens 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.js (opens new window) and scripts/patches.js (opens new window) for more info.

# Utilization of Nan

This project utilizes Nan (opens new window) to make the project backwards-compatible and make bindings future-proof.

# Building the project

Builds are created using node-pre-gyp (opens 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 WSL (opens new window)), then you'll need to install windows-build-tools (opens 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 Jest (opens 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 Codecov (opens new window).

# e2e tests

e2e tests are specified in the test/e2e directory. They utilize jest-image-snapshot (opens 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-changelog (opens new window). This module utilizes commitizen (opens new window) as a devDependency to help developers write their commits, and commit messages are enforced using commitlint (opens new window).

# Versioning

This package abides by the semver standard (opens new window). standard-version (opens new window) will automatically update CHANGELOG.md (opens 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-github (opens 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 Guidelines (opens new window).