Skip to content

Commit

Permalink
Changed structure of building folders
Browse files Browse the repository at this point in the history
  • Loading branch information
lindell committed May 18, 2016
1 parent 18870fd commit 853191e
Show file tree
Hide file tree
Showing 65 changed files with 58 additions and 36 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "JsBarcode",
"main": "bin/browser/JsBarcode.all.js",
"main": "dist/JsBarcode.all.min.js",
"version": "3.3.5",
"homepage": "https://github.com/lindell/JsBarcode",
"authors": [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title></title>
<script src="../bin/browser/JsBarcode.all.js"></script>
<script src="../dist/JsBarcode.all.js"></script>
<script>
Number.prototype.zeroPadding = function(){
var ret = "" + this.valueOf();
Expand Down
3 changes: 1 addition & 2 deletions example/toBase64.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<head>
<meta charset="UTF-8">
<title></title>
<script src="../JsBarcode.js"></script>
<script src="../barcodes/CODE39.js"></script>
<script src="../dist/JsBarcode.all.js"></script>
<script>
function textToBase64Barcode(text){
var canvas = document.createElement("canvas");
Expand Down
53 changes: 38 additions & 15 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ var clean = require('gulp-clean');
var gulpWebpack = require('webpack-stream');
var webpack = require('webpack');
var gzipSize = require('gzip-size');
var request = require('request');

var fs = require('fs');

gulp.task("clean", function(){
return gulp.src("bin/", {read: false})
return gulp.src(["bin/", "dist/"], {read: false})
.pipe(clean());
});

Expand All @@ -30,31 +31,31 @@ function babelFunc(){
presets: ['es2015'],
plugins: [["transform-es2015-classes", {loose: true}]]
}))
.pipe(gulp.dest("bin/node/"));
.pipe(gulp.dest("bin/"));
}

gulp.task("webpack", ["babel"], function () {
return webpackFunc();
});

function webpackFunc(){
return gulp.src('bin/node/JsBarcode.js')
return gulp.src('bin/JsBarcode.js')
.pipe(gulpWebpack(
{
output: {
filename: 'JsBarcode.all.js',
}
}
, webpack))
.pipe(gulp.dest("bin/browser/"));
.pipe(gulp.dest("dist/"));
}

gulp.task("webpack-min", ["babel"], function () {
return webpackMin('JsBarcode.all.min.js');
});

function webpackMin(filename){
return gulp.src('bin/node/JsBarcode.js')
return gulp.src('bin/JsBarcode.js')
.pipe(gulpWebpack(
{
output: {
Expand All @@ -63,7 +64,7 @@ function webpackMin(filename){
plugins: [new webpack.optimize.UglifyJsPlugin()],
}
, webpack))
.pipe(gulp.dest("bin/browser/"));
.pipe(gulp.dest("dist/"));
}

gulp.task("webpack-all", function (cb) {
Expand All @@ -78,8 +79,8 @@ gulp.task("webpack-all", function (cb) {
toFile += "export default {" + barcode.names + "}";

fs.writeFile("src/barcodes/index.js", toFile, function(){
if(fs.existsSync("bin/node/barcodes/index.js")){
fs.unlinkSync("bin/node/barcodes/index.js");
if(fs.existsSync("bin/barcodes/index.js")){
fs.unlinkSync("bin/barcodes/index.js");
}
babelFunc().on('end', function(){
webpackMin("barcodes/" + barcode.filename).on('end', callback);
Expand Down Expand Up @@ -126,7 +127,9 @@ gulp.task('git-release', ['compress'], function(cb){
var v = 'v' + pkg.version;
var message = 'Release ' + v;

gulp.src(['./package.json', './bower.json', './bin/'])
updateReadmeFileSizes();

gulp.src(['./package.json', './bower.json', './README.md', './bin/', './dist'])
.pipe(git.add({args: '--all'}))
.pipe(git.commit(message));

Expand Down Expand Up @@ -172,16 +175,37 @@ gulp.task('github-release', function(done) {
repo: "JsBarcode",
tag: v,
name: name,
assets: [__dirname + "/bin/browser/JsBarcode.all.min.js", __dirname + "/bin/browser/JsBarcode.all.js"]
assets: [__dirname + "/dist/JsBarcode.all.min.js", __dirname + "/dist/JsBarcode.all.js"]
}, done);
});

gulp.task('update-readme-sizes', function(){
gulp.task('jsdelivr', function(){
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);
}
})
});

gulp.task("update-readme-sizes", updateReadmeFileSizes);

function updateReadmeFileSizes(){
var files = require('./barcode-building.json');
var readme = fs.readFileSync('README.md', "utf-8");

// Update .all files
var data = fs.readFileSync('bin/browser/JsBarcode.all.min.js');
var data = fs.readFileSync('dist/JsBarcode.all.min.js');
var filesize = gzipSize.sync(data);

var regexp = new RegExp('\\|[^\\|]*\\|([ \\t\\*]*\\[JsBarcode\\.all\\.min\\.js\\])');
Expand All @@ -191,7 +215,7 @@ gulp.task('update-readme-sizes', function(){
for(var i in files){
var filename = files[i].filename;

var data = fs.readFileSync('bin/browser/barcodes/' + filename);
var data = fs.readFileSync('dist/barcodes/' + filename);
var filesize = gzipSize.sync(data);

var regexp = new RegExp('\\|[^\\|]*\\|([ \\t]*\\[' + RegExp.escape(filename) + '\\])');
Expand All @@ -200,7 +224,7 @@ gulp.task('update-readme-sizes', function(){
}

fs.writeFileSync('README.md', readme, 'utf8');
});
}

function formatSize(bytes){
var kilobytes = Math.round(bytes/1024*10)/10;
Expand Down Expand Up @@ -233,7 +257,6 @@ gulp.task('compile-web', ['webpack'], function(done){

gulp.task('release', function(callback){
runSequence(
'update-readme-sizes',
'git-release',
'wait',
'github-release',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jsbarcode",
"version": "3.3.5",
"description": "JsBarcode is a simple and powerfull way to create different types of 1d barcodes.",
"main": "./bin/node/JsBarcode.js",
"main": "./bin/JsBarcode.js",
"directories": {
"example": "example",
"test": "test",
Expand Down Expand Up @@ -35,8 +35,8 @@
"url": "https://github.com/lindell/JsBarcode/issues"
},
"bin": {
"JsBarcode": "./bin/node/cli.js",
"jsbarcode": "./bin/node/cli.js"
"JsBarcode": "./bin/cli.js",
"jsbarcode": "./bin/cli.js"
},
"homepage": "https://github.com/lindell/JsBarcode#readme",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion test/browser/canvasTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Test minified version</title>
<script src="../../bin/browser/JsBarcode.all.js"></script>
<script src="../../dist/JsBarcode.all.js"></script>

<script src="tests.js"></script>
<script src="canvasTest.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/browser/initTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<title>Test minified version</title>
<script src="help/jquery-2.2.3.js"></script>
<script src="../../bin/browser/JsBarcode.all.js"></script>
<script src="../../dist/JsBarcode.all.js"></script>
<style>
@font-face {
font-family: "OCRB";
Expand Down
2 changes: 1 addition & 1 deletion test/browser/jQueryTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Test minified version</title>
<script src="help/jquery-2.2.3.js"></script>

<script src="../../bin/browser/JsBarcode.all.js"></script>
<script src="../../dist/JsBarcode.all.js"></script>

<script src="tests.js"></script>
<script src="jQueryTest.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/browser/svgTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Test minified version</title>
<script src="../../bin/browser/JsBarcode.all.js"></script>
<script src="../../dist/JsBarcode.all.js"></script>

<script src="tests.js"></script>
<script src="svgTest.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions test/browser/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ function createTests(newTest){
newTest("This has a \nnewline", {width: 1});
newTest("\tHi\nHI", {width: 1});
newTest("A little test!", {format: "CODE128", width: 1});
newTest("A LITTLE TEST", {format: "CODE39", width: 1});
newTest("ABCDEFG", {format: "CODE39", width: 1, mod43: true});
newTest("A little test", {format: "CODE39", width: 1});
newTest("12345", {format: "EAN5", width: 1});
newTest("52", {format: "EAN2", width: 1});
newTest("423514346455", {format: "UPC", width: 2, textMargin: 0});
newTest("5901234123457", {format: "EAN13", fontSize: 20, textMargin: 0});
newTest("5901234123457", {format: "EAN13", fontSize: 20, textMargin: 0, lastChar: ">"});
newTest("590123412345", {format: "EAN13", width: 2, fontSize: 16});
newTest("590123412345", {format: "EAN13", width: 3});
newTest("96385074", {format: "EAN8", width: 1});
Expand Down
2 changes: 1 addition & 1 deletion test/node/CODE128.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('assert');
var JsBarcode = require('../../bin/node/JsBarcode.js');
var JsBarcode = require('../../bin/JsBarcode.js');
var Canvas = require("canvas");


Expand Down
2 changes: 1 addition & 1 deletion test/node/CODE39.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('assert');
var JsBarcode = require('../../bin/node/JsBarcode.js');
var JsBarcode = require('../../bin/JsBarcode.js');
var Canvas = require("canvas");


Expand Down
2 changes: 1 addition & 1 deletion test/node/EAN-UPC.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('assert');
var JsBarcode = require('../../bin/node/JsBarcode.js');
var JsBarcode = require('../../bin/JsBarcode.js');
var Canvas = require("canvas");
var help = require("./help/help");

Expand Down
2 changes: 1 addition & 1 deletion test/node/ITF-14.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('assert');
var JsBarcode = require('../../bin/node/JsBarcode.js');
var JsBarcode = require('../../bin/JsBarcode.js');
var Canvas = require("canvas");


Expand Down
2 changes: 1 addition & 1 deletion test/node/ITF.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('assert');
var JsBarcode = require('../../bin/node/JsBarcode.js');
var JsBarcode = require('../../bin/JsBarcode.js');
var Canvas = require("canvas");


Expand Down
2 changes: 1 addition & 1 deletion test/node/JsBarcode.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('assert');
var JsBarcode = require('../../bin/node/JsBarcode.js');
var JsBarcode = require('../../bin/JsBarcode.js');
var Canvas = require("canvas");

describe('Encoders', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/node/MSI.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('assert');
var JsBarcode = require('../../bin/node/JsBarcode.js');
var JsBarcode = require('../../bin/JsBarcode.js');
var Canvas = require("canvas");


Expand Down
2 changes: 1 addition & 1 deletion test/node/pharmacode.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var assert = require('assert');
var JsBarcode = require('../../bin/node/JsBarcode.js');
var JsBarcode = require('../../bin/JsBarcode.js');
var Canvas = require("canvas");

describe('Pharmacode', function() {
Expand Down

0 comments on commit 853191e

Please sign in to comment.