Skip to content

Commit 22e70d1

Browse files
authored
New build system (by gulp) without Fetch (329) (#166)
* add lint (fixed all error, warnings) add gulp add babel Need to test speed * checking * added cross-platform set Node variable * add watch fixed uglify * add to ignore sublime generated files * - add connect task - remove old dependencies * - Updated CONTRIBUTING.md (contributors may make a pull request only) - Remove grunt - Updated gulp - Added cross env variable * cleanup * updated packages scripts
1 parent f211ae9 commit 22e70d1

28 files changed

+458
-418
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["babel-preset-es2015"]
3+
}

.github/CONTRIBUTING.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@ Please follow all rules from our [code style guidelines](https://github.com/Quic
88

99
## Modify and build the library
1010

11-
The quickblox.js library is build from a number of **CommonJS modules** contained in the `js` folder. For example the `js/modules/qbUsers.js` module contains the code that deals with the [Users API](http://quickblox.com/developers/Users).
11+
The quickblox.js library is build from a number of **CommonJS modules** contained in the `src` folder. For example the `src/modules/qbUsers.js` module contains the code that deals with the [Users API](http://quickblox.com/developers/Users).
1212

13-
These modules are combined through [browserify](http://browserify.org/) into a single `quickblox.js` file in the root and so this is the only file that needs to be included in a `<script>` tag OR in a RequireJS application OR in Node.js environment (everywhere). To build the library, use the [Grunt](http://gruntjs.com/) task runner.
13+
These modules are combined through [browserify](http://browserify.org/) into a single `quickblox.js` file in the root and so this is the only file that needs to be included in a `<script>` tag OR in a RequireJS application OR in Node.js environment (everywhere).
14+
To build the library, uses [gulp](http://gulpjs.com/) task runner.
1415

1516
* You need to have the dependencies listed in the package.json available, use `npm install` to load them;
16-
* Install **grunt-cli** `npm install -g grunt-cli`;
17-
* Also you need install **jasmine** global `npm i -g jasmine` for tests;
17+
* Install [gulp](https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md#getting-started) globally;
18+
* Install [jasmine](https://github.com/jasmine/jasmine#installation) globally. Uses for tests;
1819
* Change the 'version' properties in next files:
19-
* https://github.com/QuickBlox/quickblox-javascript-sdk/blob/gh-pages/js/qbConfig.js;
20-
* https://github.com/QuickBlox/quickblox-javascript-sdk/blob/gh-pages/bower.json;
21-
* https://github.com/QuickBlox/quickblox-javascript-sdk/blob/gh-pages/package.json;
22-
* Rebuild SDK: `grunt`;
23-
* Update README.md;
24-
* Commit your changes to git repository and create a new "git tag" for new version. This action updates SDK for GIT and also for bower package manager;
25-
* `npm publish`. This action updates SDK for node package manager, but maybe you will be needed some author credentials for it (you should be in owner list);
26-
* Update QuickBlox developers section.
20+
* ./bower.json;
21+
* ./package.json;
22+
* ./src/qbConfig.js;
23+
* Rebuild SDK: `npm run build`, check tests in node / browser env.
24+
* Update ./README.md;
25+
* Make a pull request into gh-pages;

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ npm-debug.log
88
.idea/*
99
.idea/workspace.xml
1010

11+
# *Sublime
12+
*.sublime-*
13+
1114
# Use command grunt for create quickblox.js
1215
quickblox.js
1316

.jshintrc

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"strict" : false,
3-
"devel" : true,
4-
"browser" : true,
5-
"browserify" : true,
6-
"jasmine" : true,
7-
"jquery" : true,
8-
"esnext" : true,
9-
"globals" : [
2+
"strict": true,
3+
"devel": true,
4+
"esversion": 6,
5+
"browser": true,
6+
"node": true,
7+
"browserify": true,
8+
"jasmine": true,
9+
"jquery": true,
10+
"globals": [
1011
"jasmine",
1112
"describe",
1213
"xdescribe",

Gruntfile.js

-89
This file was deleted.

gulpfile.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
3+
var gulp = require('gulp');
4+
5+
var babelify = require('babelify');
6+
var browserify = require('browserify');
7+
8+
var source = require('vinyl-source-stream');
9+
10+
var jshint = require('gulp-jshint');
11+
var uglify = require('gulp-uglify');
12+
var rename = require('gulp-rename');
13+
14+
var connect = require('gulp-connect');
15+
16+
gulp.task('transform', function () {
17+
var isDevelopment = process.env.NODE_ENV === 'develop',
18+
browserifyOpts = {
19+
debug: isDevelopment,
20+
standalone: 'QB'
21+
};
22+
23+
return browserify('./src/qbMain.js', browserifyOpts)
24+
.transform(babelify, { presets: ['es2015'] })
25+
.bundle()
26+
.pipe(source('quickblox.js'))
27+
.pipe(gulp.dest('./'));
28+
});
29+
30+
gulp.task('uglify', function () {
31+
gulp.src('quickblox.js')
32+
.pipe(uglify())
33+
.pipe(rename('quickblox.min.js'))
34+
.pipe(gulp.dest('./'));
35+
});
36+
37+
gulp.task('connect', function() {
38+
connect.server({
39+
port: 8080,
40+
https: true
41+
});
42+
});
43+
44+
gulp.task('watch', function () {
45+
gulp.watch(['./src/**/*.js'], ['transform', 'uglify']);
46+
});
47+
48+
gulp.task('default', ['transform', 'uglify', 'connect', 'watch']);

package.json

+18-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "2.3.2",
55
"homepage": "https://quickblox.com/developers/Javascript",
66
"main": "src/qbMain.js",
7-
"license" : "(Apache-2.0)",
7+
"license": "(Apache-2.0)",
88
"keywords": [
99
"quickblox",
1010
"javascript",
@@ -46,16 +46,20 @@
4646
"xml2js": "^0.4.13"
4747
},
4848
"devDependencies": {
49+
"babel-preset-es2015": "^6.16.0",
50+
"babelify": "^7.3.0",
51+
"browserify": "^13.1.0",
52+
"cross-env": "^3.1.2",
4953
"ghooks": "^1.3.2",
50-
"grunt": "^0.4.5",
51-
"grunt-browserify": "^3.2.1",
52-
"grunt-contrib-connect": "^0.9.0",
53-
"grunt-contrib-uglify": "^0.6.0",
54-
"grunt-contrib-watch": "^0.6.1",
55-
"grunt-notify": "^0.4.1",
56-
"grunt-parallel": "^0.4.1",
54+
"gulp": "^3.9.1",
55+
"gulp-connect": "^5.0.0",
56+
"gulp-jshint": "^2.0.1",
57+
"gulp-rename": "^1.2.2",
58+
"gulp-uglify": "^2.0.0",
5759
"jasmine": "^2.4.1",
58-
"load-grunt-tasks": "^1.0.0"
60+
"jshint": "^2.9.3",
61+
"jshint-stylish": "^2.2.1",
62+
"vinyl-source-stream": "^1.1.0"
5963
},
6064
"autoupdate": {
6165
"source": "git",
@@ -72,8 +76,10 @@
7276
}
7377
},
7478
"scripts": {
75-
"setDependencies": "npm i && npm install -g grunt-cli && npm install -g jasmine",
76-
"build": "grunt",
77-
"test": "jasmine"
79+
"setDependencies": "npm i && npm install -g gulp-cli && npm install -g jasmine",
80+
"lint": "jshint src --reporter=node_modules/jshint-stylish",
81+
"build": "npm run lint && gulp transform && gulp uglify",
82+
"develop": "cross-env NODE_ENV=develop gulp",
83+
"server": "gulp connect"
7884
}
7985
}

quickblox.min.js

+40-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/modules/qbAuth.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
/*
2-
* QuickBlox JavaScript SDK
3-
*
4-
* Authentication Module
5-
*
6-
*/
1+
'use strict';
72

83
var config = require('../qbConfig'),
94
Utils = require('../qbUtils'),

src/modules/qbChat.js

+8-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/*
2-
* QuickBlox JavaScript SDK
3-
* Chat Module
4-
*/
1+
'use strict';
2+
3+
/** JSHint inline rules */
4+
/* globals Strophe, $pres, $msg, $iq */
5+
56
var chatUtils = require('./qbChatHelpers'),
67
config = require('../qbConfig'),
78
Utils = require('../qbUtils');
@@ -191,7 +192,7 @@ function ChatProxy(service, webrtcModule, conn) {
191192
* if you make 'leave' from dialog
192193
* stanza will be contains type="unavailable"
193194
*/
194-
var type = stanza.attrs.type;
195+
type = stanza.attrs.type;
195196

196197
/** LEAVE from dialog */
197198
if(type && type === 'unavailable' && nodeStanzasCallbacks['muc:leave']) {
@@ -1205,7 +1206,7 @@ PrivacyListProxy.prototype = {
12051206
return iq;
12061207
}
12071208

1208-
for (var index = 0, i = 0, len = listUserId.length; index < len; index++, i=i+2) {
1209+
for (let index = 0, i = 0, len = listUserId.length; index < len; index++, i = i + 2) {
12091210
userId = listUserId[index];
12101211
mutualBlock = listPrivacy[userId].mutualBlock;
12111212

@@ -1369,7 +1370,7 @@ PrivacyListProxy.prototype = {
13691370
};
13701371

13711372
if(Utils.getEnv().browser){
1372-
var iq = $iq(stanzaParams).c('query', {
1373+
iq = $iq(stanzaParams).c('query', {
13731374
xmlns: Strophe.NS.PRIVACY_LIST
13741375
});
13751376

@@ -1767,18 +1768,6 @@ Helpers.prototype = {
17671768
return null;
17681769
}
17691770
return arrayElements[arrayElements.length-1];
1770-
},
1771-
getUniqueId: function(suffix) {
1772-
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
1773-
var r = Math.random() * 16 | 0,
1774-
v = c == 'x' ? r : r & 0x3 | 0x8;
1775-
return v.toString(16);
1776-
});
1777-
if (typeof(suffix) == 'string' || typeof(suffix) == 'number') {
1778-
return uuid + ':' + suffix;
1779-
} else {
1780-
return uuid + '';
1781-
}
17821771
}
17831772
};
17841773

0 commit comments

Comments
 (0)