Skip to content

Commit

Permalink
fix(version): adds missing C file ref, version mgmt (#37)
Browse files Browse the repository at this point in the history
Adds missing gb18030.c file to binding.gyp. Implements basic system to
track and maintain versions of the zint library.
  • Loading branch information
jshor committed Jun 3, 2020
1 parent 8194f71 commit 0903303
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 45 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ after_success:

env:
matrix:
# - NODE_VERSION="9"
- NODE_VERSION="10"
- NODE_VERSION="11"
- NODE_VERSION="12"
- NODE_VERSION="13"

global:
secure: aVq1cD7QjvlWFnliM4kWAPc+9Fnc9vVDVSX37e4Ojnbx9m+fcLcIM9HsDUJei+vJecF0812Hcb7lKoIkCz2daqZu8QycAmxeZYdcX2SQ1O2z39pSWa4eNiy8FcfuhVlV9VDWqcxOAO3+AHvFbt34shfD7oJAZW7laVrVrowZDEznqBzxCfROwqzpPdwjVkWzdepbV+xxZNXHdlBCTqNZYeivnM4+P7RYoNsZKjZPan0NgNNH+jhGebjMGYj8KNWidsNLRCaHpRWIJqzHD0+cWNiS/4Q4Ta2VpFOLzL0Ih6Q4P/q8+4fwH4QrN3QHRMfUOjIl+ctOr99y3xrW5qvNjgv4WAzgI1an+iCAUSuaewDX/a18mtyb7SbUqmO8nXqoQVTdvRiFtxFPi4SA5MwSeG4JPsr3444LIlKaQDSCnFtpiOy5Q6u0JQQNnopZDGTRqceqWKNySHw1tLVSQivJ7WbA7avms51x7psxZ16XJ0GN3sj3HExdZUKWENuX0ijFCY28GG9hPxEpZJhAag8eaz0l2sT5lb5/Crx6oaMmzi+OW7gQeg4qfihNF/zWN/d3xGAvJKzq4JWS4RF17Npi6ctgBPv+VCTxdYozJGLnz80Rrgabqya21AeFrnSn9INHkIZGDN5BRiZB4LXvAekhmbTdU4T5LwtI3Wvd7XrwvzA=
secure: aVq1cD7QjvlWFnliM4kWAPc+9Fnc9vVDVSX37e4Ojnbx9m+fcLcIM9HsDUJei+vJecF0812Hcb7lKoIkCz2daqZu8QycAmxeZYdcX2SQ1O2z39pSWa4eNiy8FcfuhVlV9VDWqcxOAO3+AHvFbt34shfD7oJAZW7laVrVrowZDEznqBzxCfROwqzpPdwjVkWzdepbV+xxZNXHdlBCTqNZYeivnM4+P7RYoNsZKjZPan0NgNNH+jhGebjMGYj8KNWidsNLRCaHpRWIJqzHD0+cWNiS/4Q4Ta2VpFOLzL0Ih6Q4P/q8+4fwH4QrN3QHRMfUOjIl+ctOr99y3xrW5qvNjgv4WAzgI1an+iCAUSuaewDX/a18mtyb7SbUqmO8nXqoQVTdvRiFtxFPi4SA5MwSeG4JPsr3444LIlKaQDSCnFtpiOy5Q6u0JQQNnopZDGTRqceqWKNySHw1tLVSQivJ7WbA7avms51x7psxZ16XJ0GN3sj3HExdZUKWENuX0ijFCY28GG9hPxEpZJhAag8eaz0l2sT5lb5/Crx6oaMmzi+OW7gQeg4qfihNF/zWN/d3xGAvJKzq4JWS4RF17Npi6ctgBPv+VCTxdYozJGLnz80Rrgabqya21AeFrnSn9INHkIZGDN5BRiZB4LXvAekhmbTdU4T5LwtI3Wvd7XrwvzA=
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ yarn add symbology
### Code 11 Example

```js
const symbology = require('symbology')

symbology
.createStream({
symbology: symbology.Barcode.CODE128
Expand Down
6 changes: 2 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ install:
- git config --global user.email "Josh Shor"
- git config --global user.name "jpshor@gmail.com"
- ps: Install-Product node $env:NODE_VERSION $env:platform
- yarn global add windows-build-tools
- yarn

test_script:
Expand All @@ -27,17 +26,16 @@ on_success:
echo "Skipping publishing stage. Branch '$env:APPVEYOR_REPO_BRANCH' -- PR '$env:APPVEYOR_PULL_REQUEST_NUMBER'"
}
platform:
platform:
- x86
- x64

environment:
matrix:
# - NODE_VERSION: '9'
- NODE_VERSION: '10'
- NODE_VERSION: '11'
- NODE_VERSION: '12'
- NODE_VERSION: '13'

access_token:
secure: 9Fo9YJd8087d6fYC63Jt2Ozl1xfbPiIlAvnDC022cG56Tu0tIPBVrcCL5PoYQkey
secure: 9Fo9YJd8087d6fYC63Jt2Ozl1xfbPiIlAvnDC022cG56Tu0tIPBVrcCL5PoYQkey
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
".zint/backend/eci.c",
".zint/backend/emf.c",
".zint/backend/gb2312.c",
".zint/backend/gb18030.c",
".zint/backend/general_field.c",
".zint/backend/gif.c",
".zint/backend/hanxin.c",
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/development.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Development

This module is a C++ wrapper around the [Zint barcode library](https://github.com/zint/zint).
This module is a C++ wrapper around the [Zint barcode library](https://github.com/zint/zint). 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

Expand Down Expand Up @@ -76,4 +76,4 @@ The package version is automatically updated. **Do not change any version refere

## Contributing

All constructive feedback and pull request changes are welcome. For more information on contributing to this project, please see the [Contributing Guidelines](https://github.com/jshor/symbology/blob/master/CONTRIBUTING.md).
All constructive feedback and pull request changes are welcome. For more information on contributing to this project, please see the [Contributing Guidelines](https://github.com/jshor/symbology/blob/master/CONTRIBUTING.md).
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
},
"zintVersion": "e86d9d1"
}
22 changes: 14 additions & 8 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@ const replace = require('replace-in-file')
const rimraf = require('rimraf')
const path = require('path')
const patches = require('./patches')
const { zintVersion } = require('../package.json')

const checkout = zintVersion || 'master'

// test commit
console.log('Removing any existing .zint directory...')

rimraf(path.join(__dirname, '../.zint'), () => {
console.log('Cloning zint...', path.join(__dirname, '.zint'))
console.log(`Cloning zint at '${checkout}' in`, path.join(__dirname, '../.zint'))

clone(`https://github.com/woo-j/zint.git`, './.zint', { checkout }, (err) => {
if (err) {
console.error(err)
} else {
console.log('Successfully cloned. Applying code patches...')

patches.forEach(patch => replace.sync(patch))

clone('https://github.com/woo-j/zint.git', '.zint', () => {
console.log('Successfully cloned. Applying code patches...')

patches.forEach(patch => replace.sync(patch))

console.log('Done.')
console.log('Done.')
}
})
})

17 changes: 8 additions & 9 deletions scripts/patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ module.exports = [
},
{
files: '.zint/**/{svg,ps}.{c,h}',
from: /int ([a-z]+)_plot([^\n]+)/g,
from: /INTERNAL int ([a-z]+)_plot([^\n]+)/g,
to: `
int pipe(int fd[2]);
int close(int fildes);
int read(int fildes, void *buf, unsigned nbytes);
int $1_plot$2
char *buf = malloc(sizeof(symbol->rendered_data));
int p[2];`
int pipe(int fd[2]);
int close(int fildes);
int read(int fildes, void *buf, unsigned nbytes);
INTERNAL int $1_plot$2
char *buf = malloc(sizeof(symbol->rendered_data));
int p[2];`
},
{
files: '.zint/**/{svg,ps}.{c,h}',
Expand All @@ -62,4 +62,3 @@ module.exports = [
`
}
]

4 changes: 2 additions & 2 deletions src/__tests__/fixtures.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('the symbology library', function() {
beforeEach(function() {
sandbox.stub(symbology, 'createStream').callsFake(createSymbology);
});

it('should return a status code and a message', function() {
return library
.createFile(getSymbol({fileName: filePath}), '54321')
Expand Down
13 changes: 0 additions & 13 deletions src/binding/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,7 @@ namespace symbology {
}

if(strcmp("svg", fileExt) == 0 || strcmp("eps", fileExt) == 0) {
// char buff[10000];

// close(symbol->file_pointer[1]);
// read(symbol->file_pointer[0], buff, 10000);

// strcpy(symbol->rendered_data, buff);

// strcpy(symbol->rendered_data, buff);
// parse the result as a normal string and store it in `encodedData`
// obj->Set(String::NewFromUtf8(isolate, "encodedData"), String::NewFromUtf8(isolate, symbol->rendered_data));
// printf("ENCODED: %s", symbol->rendered_data);
// printf("THE RESULT -- %s --END", symbol->rendered_data);
Nan::Set(obj, Nan::New<String>("encodedData").ToLocalChecked(), Nan::New<String>(symbol->rendered_data).ToLocalChecked());
// Nan::Set(obj, Nan::New<String>("encodedData").ToLocalChecked(), Nan::New<String>(symbol->encoded_data).ToLocalChecked());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/enums/barcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ module.exports = {
CODEONE: 141,
GRIDMATRIX: 142,
UPNQR: 143
};
}
2 changes: 1 addition & 1 deletion src/enums/errorCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ module.exports = {
ZERROR_ENCODING_PROBLEM: 9,
ZERROR_FILE_ACCESS: 10,
ZERROR_MEMORY: 11
};
}
2 changes: 1 addition & 1 deletion src/enums/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ module.exports = {
CMYK_COLOUR: 128,
BARCODE_DOTTY_MODE: 256,
GS1_GS_SEPARATOR: 512
};
}

0 comments on commit 0903303

Please sign in to comment.