Barcode Generation
This commit is contained in:
37
node_modules/jsbarcode/automation/barcode-building.json
generated
vendored
Normal file
37
node_modules/jsbarcode/automation/barcode-building.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
"name": "code39",
|
||||
"names": "CODE39",
|
||||
"barcodeFile": "./CODE39"
|
||||
},
|
||||
{
|
||||
"name": "code128",
|
||||
"names": ["CODE128, CODE128A, CODE128B, CODE128C"],
|
||||
"barcodeFile": "./CODE128"
|
||||
},
|
||||
{
|
||||
"name": "ean-upc",
|
||||
"names": "EAN13, EAN8, EAN5, EAN2, UPC",
|
||||
"barcodeFile": "./EAN_UPC"
|
||||
},
|
||||
{
|
||||
"name": "itf",
|
||||
"names": "ITF, ITF14",
|
||||
"barcodeFile": "./ITF"
|
||||
},
|
||||
{
|
||||
"name": "msi",
|
||||
"names": "MSI, MSI10, MSI11, MSI1010, MSI1110",
|
||||
"barcodeFile": "./MSI"
|
||||
},
|
||||
{
|
||||
"name": "pharmacode",
|
||||
"names": "pharmacode",
|
||||
"barcodeFile": "./pharmacode"
|
||||
},
|
||||
{
|
||||
"name": "codabar",
|
||||
"names": "codabar",
|
||||
"barcodeFile": "./codabar"
|
||||
}
|
||||
]
|
||||
132
node_modules/jsbarcode/automation/building.js
generated
vendored
Normal file
132
node_modules/jsbarcode/automation/building.js
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
var gulp = require('gulp');
|
||||
var header = require('gulp-header');
|
||||
var clean = require('gulp-clean');
|
||||
var gulpWebpack = require('webpack-stream');
|
||||
var webpack = require('webpack');
|
||||
var babel = require("gulp-babel");
|
||||
var runSequence = require('gulp4-run-sequence');
|
||||
var fs = require('fs');
|
||||
|
||||
var settings = require('./settings.json');
|
||||
var shared = require('./shared.js');
|
||||
|
||||
gulp.task("clean", gulp.series(function () {
|
||||
return gulp.src(["bin/", "dist/"], { read: false })
|
||||
.pipe(clean());
|
||||
}));
|
||||
|
||||
|
||||
gulp.task("babel", gulp.series(function () {
|
||||
return babelFunc();
|
||||
}));
|
||||
|
||||
|
||||
function babelFunc() {
|
||||
return gulp.src("src/**/*")
|
||||
.pipe(babel({
|
||||
presets: ['es2015', 'stage-3']
|
||||
}))
|
||||
.pipe(gulp.dest("bin/"));
|
||||
}
|
||||
|
||||
|
||||
gulp.task("webpack", gulp.series(["babel"], function () {
|
||||
return webpackFunc();
|
||||
}));
|
||||
|
||||
|
||||
function webpackFunc() {
|
||||
return gulp.src('bin/JsBarcode.js')
|
||||
.pipe(gulpWebpack(
|
||||
{
|
||||
mode: "none",
|
||||
output: {
|
||||
filename: 'JsBarcode.all.js'
|
||||
}
|
||||
}
|
||||
, webpack))
|
||||
.pipe(gulp.dest("dist/"));
|
||||
}
|
||||
|
||||
|
||||
gulp.task("webpack-min", gulp.series(["babel"], function () {
|
||||
return webpackMin('all');
|
||||
}));
|
||||
|
||||
|
||||
function webpackMin(name, dest) {
|
||||
dest = dest || './';
|
||||
return gulp.src('bin/JsBarcode.js')
|
||||
.pipe(gulpWebpack(
|
||||
{
|
||||
mode: "production",
|
||||
output: {
|
||||
filename: shared.minifiedFilename(name)
|
||||
},
|
||||
}
|
||||
, webpack))
|
||||
.pipe(header(settings.banner, require(settings.baseDir + 'package.json')))
|
||||
.pipe(gulp.dest("dist/" + dest));
|
||||
}
|
||||
|
||||
|
||||
gulp.task("webpack-all", gulp.series(function (cb) {
|
||||
var barcodes = require('./barcode-building.json');
|
||||
|
||||
// Move the real barcodes/index.js out of the way while compiling the individual barcodes
|
||||
fs.renameSync("src/barcodes/index.js", "src/barcodes/index.tmp.js");
|
||||
|
||||
// Take a barcode from the barcodes array, call the functions to compile that
|
||||
// format and have a callback when it has finished.
|
||||
function loopBarcode(i) {
|
||||
if (i < barcodes.length) {
|
||||
createBarcodeInclude(barcodes[i], function () {
|
||||
loopBarcode(i + 1);
|
||||
});
|
||||
}
|
||||
else {
|
||||
fs.renameSync("src/barcodes/index.tmp.js", "src/barcodes/index.js");
|
||||
cb(); // Done
|
||||
}
|
||||
}
|
||||
|
||||
loopBarcode(0);
|
||||
}));
|
||||
|
||||
|
||||
// Takes information about a barcode formatSize
|
||||
// Modifies the barcodes/index.js file to only import the specified format
|
||||
// and then does a recompilation and minifies everything with webpack
|
||||
function createBarcodeInclude(barcode, callback) {
|
||||
var toFile = "";
|
||||
toFile += "import {" + barcode.names + "} from '" + barcode.barcodeFile + "'";
|
||||
toFile += "\n";
|
||||
toFile += "export default {" + barcode.names + "}";
|
||||
|
||||
// Write a new barcodes/index file that only includes the specified barcode
|
||||
fs.writeFile("src/barcodes/index.js", toFile, function () {
|
||||
// Remove the compiled barcodes/index file (if it exist)
|
||||
if (fs.existsSync("bin/barcodes/index.js")) {
|
||||
fs.unlinkSync("bin/barcodes/index.js");
|
||||
}
|
||||
// Re-compile with babel and webpack everything
|
||||
babelFunc().on('end', function () {
|
||||
webpackMin(barcode.name, 'barcodes/').on('end', callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
gulp.task('compress', gulp.series(function (cb) {
|
||||
runSequence(
|
||||
"clean",
|
||||
"webpack-all",
|
||||
"webpack",
|
||||
"webpack-min",
|
||||
cb
|
||||
);
|
||||
}));
|
||||
|
||||
gulp.task('compile', gulp.series(['babel']));
|
||||
|
||||
gulp.task('compile-web', gulp.series(['webpack']));
|
||||
9
node_modules/jsbarcode/automation/linting.js
generated
vendored
Normal file
9
node_modules/jsbarcode/automation/linting.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var gulp = require('gulp');
|
||||
var eslint = require('gulp-eslint');
|
||||
|
||||
gulp.task("lint", function () {
|
||||
return gulp.src(['src/**/*.js'])
|
||||
.pipe(eslint())
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError());
|
||||
});
|
||||
30
node_modules/jsbarcode/automation/misc.js
generated
vendored
Normal file
30
node_modules/jsbarcode/automation/misc.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/*eslint no-console: 0 */
|
||||
|
||||
var gulp = require('gulp');
|
||||
var request = require('request');
|
||||
var fs = require('fs');
|
||||
|
||||
gulp.task('jsdelivr', function(callback){
|
||||
console.log("Making request...");
|
||||
request({
|
||||
url: "https://api.jsdelivr.com/v1/jsdelivr/libraries?name=jsbarcode",
|
||||
json: true
|
||||
}, function (error, response, body) {
|
||||
if (!error && response.statusCode === 200) {
|
||||
var readme = fs.readFileSync('README.md', "utf-8");
|
||||
var version = body[0].lastversion;
|
||||
|
||||
readme = readme.replace(/https:\/\/cdn\.jsdelivr\.net\/jsbarcode\/[0-9]+\.[0-9]+\.[0-9]+\//g,
|
||||
"https://cdn.jsdelivr.net/jsbarcode/" + version + "/");
|
||||
|
||||
fs.writeFileSync('README.md', readme, 'utf8');
|
||||
|
||||
console.log("New version: " + version);
|
||||
callback();
|
||||
}
|
||||
else{
|
||||
console.error("Failed to make jsdelivr api request");
|
||||
callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
163
node_modules/jsbarcode/automation/releasing.js
generated
vendored
Normal file
163
node_modules/jsbarcode/automation/releasing.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
/*eslint
|
||||
no-console: 0
|
||||
*/
|
||||
|
||||
var gulp = require('gulp');
|
||||
var bump = require('gulp-bump');
|
||||
var git = require('gulp-git');
|
||||
var publishRelease = require('publish-release');
|
||||
var gzipSize = require('gzip-size');
|
||||
var runSequence = require('gulp4-run-sequence');
|
||||
var fs = require('fs');
|
||||
|
||||
var settings = require('./settings.json');
|
||||
var shared = require('./shared.js');
|
||||
|
||||
|
||||
gulp.task('git-release', gulp.series(['compress'], function (cb) {
|
||||
var pkg = require(settings.baseDir + 'package.json');
|
||||
var v = 'v' + pkg.version;
|
||||
var message = ':package: Release ' + v;
|
||||
|
||||
updateReadmeFileSizes();
|
||||
|
||||
gulp.src(['./package.json', './bower.json', './README.md', './bin/', './dist'])
|
||||
.pipe(git.add({ args: '--all --force' }))
|
||||
.pipe(git.commit(message));
|
||||
|
||||
git.push('origin', 'master', function () {
|
||||
git.tag(v, message, function () {
|
||||
git.push('origin', 'master', { args: '--tags' }, cb);
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
// Bump (increase) the version number
|
||||
gulp.task('bump-patch', function () {
|
||||
return gulp.src(['./package.json', './bower.json'])
|
||||
.pipe(bump({ type: 'patch' }))
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('bump-minor', function () {
|
||||
return gulp.src(['./package.json', './bower.json'])
|
||||
.pipe(bump({ type: 'minor' }))
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('bump-major', function () {
|
||||
return gulp.src(['./package.json', './bower.json'])
|
||||
.pipe(bump({ type: 'major' }))
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('npm', function (done) {
|
||||
require('child_process').spawn('npm', ['publish'], { stdio: 'inherit' })
|
||||
.on('close', done);
|
||||
});
|
||||
|
||||
|
||||
gulp.task('github-release', function (done) {
|
||||
var pkg = require(settings.baseDir + './package.json');
|
||||
var v = 'v' + pkg.version;
|
||||
var name = "JsBarcode " + v;
|
||||
|
||||
publishRelease({
|
||||
token: process.env.GITHUB_TOKEN,
|
||||
owner: "lindell",
|
||||
repo: "JsBarcode",
|
||||
tag: v,
|
||||
name: name,
|
||||
assets: [__dirname + "/" + settings.baseDir + "/dist/JsBarcode.all.min.js", __dirname + "/" + settings.baseDir + "/dist/JsBarcode.all.js"]
|
||||
}, done);
|
||||
});
|
||||
|
||||
|
||||
|
||||
gulp.task('release', gulp.series(function (callback) {
|
||||
runSequence(
|
||||
'git-release',
|
||||
'github-release',
|
||||
'npm',
|
||||
callback
|
||||
);
|
||||
}));
|
||||
|
||||
|
||||
gulp.task('patch', function () {
|
||||
runSequence(
|
||||
'bump-patch',
|
||||
'release',
|
||||
releaseDone
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
gulp.task('minor', function () {
|
||||
runSequence(
|
||||
'bump-minor',
|
||||
'release',
|
||||
releaseDone
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
gulp.task('major', function () {
|
||||
runSequence(
|
||||
'bump-major',
|
||||
'release',
|
||||
releaseDone
|
||||
);
|
||||
});
|
||||
|
||||
function releaseDone(error) {
|
||||
if (error) {
|
||||
console.log(error.message);
|
||||
}
|
||||
else {
|
||||
console.log('Successful!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateReadmeFileSizes() {
|
||||
var files = require('./barcode-building.json');
|
||||
var readme = fs.readFileSync('README.md', "utf-8");
|
||||
|
||||
// Update .all files
|
||||
var allData = fs.readFileSync('dist/JsBarcode.all.min.js');
|
||||
var allFilesize = gzipSize.sync(allData);
|
||||
|
||||
var allRegexp = new RegExp('\\|[^\\|]*\\|([ \\t\\*]*\\[JsBarcode\\.all\\.min\\.js\\])');
|
||||
readme = readme.replace(allRegexp, "| *" + formatSize(allFilesize) + "* |$1");
|
||||
|
||||
// Update all barcodes files
|
||||
for (var i in files) {
|
||||
var filename = shared.minifiedFilename(files[i].name);
|
||||
|
||||
var fileData = fs.readFileSync('dist/barcodes/' + filename);
|
||||
var fileFilesize = gzipSize.sync(fileData);
|
||||
|
||||
var fileRegexp = new RegExp('\\|[^\\|]*\\|([ \\t]*\\[' + RegExp.escape(filename) + '\\])');
|
||||
|
||||
readme = readme.replace(fileRegexp, "| " + formatSize(fileFilesize) + " |$1");
|
||||
}
|
||||
|
||||
fs.writeFileSync('README.md', readme, 'utf8');
|
||||
}
|
||||
|
||||
|
||||
// Util functions
|
||||
RegExp.escape = function (s) {
|
||||
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
};
|
||||
|
||||
function formatSize(bytes) {
|
||||
var kilobytes = Math.round(bytes / 1024 * 10) / 10;
|
||||
|
||||
return kilobytes + " kB";
|
||||
}
|
||||
6
node_modules/jsbarcode/automation/settings.json
generated
vendored
Normal file
6
node_modules/jsbarcode/automation/settings.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"baseDir": "../",
|
||||
"distDir": "./dist/",
|
||||
"binDir": "./bin/",
|
||||
"banner": "/*! JsBarcode v<%= version %> | (c) <%= author %> | <%= license %> license */\n"
|
||||
}
|
||||
5
node_modules/jsbarcode/automation/shared.js
generated
vendored
Normal file
5
node_modules/jsbarcode/automation/shared.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {};
|
||||
|
||||
module.exports.minifiedFilename = function(name){
|
||||
return "JsBarcode." + name + ".min.js";
|
||||
};
|
||||
Reference in New Issue
Block a user