Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EZP-21963: create separate "promise-based" build #32

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 31 additions & 13 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
module.exports = function(grunt) {

var qPath = {
"q": "../node_modules/q/q"
},
testPaths = {
"q": "../node_modules/q/q",
var testPaths = {
"jasmineCAPIMatchers": "../test/jasmine/CAPIMatchers"
},
coveragePaths = {
"q": "../node_modules/q/q",
"jasmineCAPIMatchers": "../../../test/jasmine/CAPIMatchers"
};

Expand All @@ -17,44 +12,67 @@ module.exports = function(grunt) {
dist: {
options: {
almond: true,
name : 'PromiseCAPI',
name : 'CAPI',
optimize: "none",
baseUrl: "src/",
paths: qPath,
out: "dist/CAPI.js",
wrap: {
startFile: 'wrap/wrap.start.js',
endFile: 'wrap/wrap.end.js'
}
}
},
distmin: {
distMin: {
options: {
almond: true,
name : 'PromiseCAPI',
name : 'CAPI',
optimize: "uglify",
baseUrl: "src/",
paths: qPath,
out: "dist/CAPI-min.js",
wrap: {
startFile: 'wrap/wrap.start.js',
endFile: 'wrap/wrap.end.js'
}
}
},
testBundle: {
distPromise: {
options: {
almond: true,
name : 'PromiseCAPI',
optimize: "none",
baseUrl: "src/",
paths: qPath,
out: "dist/PromiseCAPI.js",
wrap: {
startFile: 'wrap/wrap.start.js',
endFile: 'wrap/wrap.promise.end.js'
}
}
},
testBundle: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a build of the minified promise version is missing

options: {
almond: true,
name : 'CAPI',
optimize: "none",
baseUrl: "src/",
out: "test/manual/jsRestClientBundle/Resources/public/js/CAPI.js",
wrap: {
startFile: 'wrap/wrap.start.js',
endFile: 'wrap/wrap.end.js'
}
}
},
testBundlePromise: {
options: {
almond: true,
name : 'PromiseCAPI',
optimize: "none",
baseUrl: "src/",
out: "test/manual/jsRestClientBundle/Resources/public/js/PromiseCAPI.js",
wrap: {
startFile: 'wrap/wrap.start.js',
endFile: 'wrap/wrap.promise.end.js'
}
}
}
},
jshint: {
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,17 @@ The library can be built with:
$ grunt build
```

This command will (re)generate the files `dist/CAPI.js` and `dist/CAPI-min.js`.
This command will (re)generate the files `dist/CAPI.js`, `dist/CAPI-min.js` and `dist/PromiseCAPI.js`.
First 2 files are full and minified versions of the regular client library wich doesn't have any dependencies and
is intended for general use.

The `PromiseCAPI.js` is a promise-based version of the library
which has a dependency on the Q library. While using this version a developer himself is responsible for inclusion of Q library into the project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to ease reviews (and reading of the raw markdown file), can you please configure your editor to limit the line length at less than 80 characters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this comment also meant that you need to cut those lines, I'm sure you editor has a magic shortcut for that)

It can be done by using preferred dependency management system or by simply downloading and including Q library file into scripts.
For example see the source file from manual testing bundle: `test/manual/jsRestClientBundle/Resources/views/promise.test.html.twig`.

More info on Q and promises: https://github.com/kriskowal/q.


### Tests

Expand Down Expand Up @@ -114,4 +124,8 @@ using following instruction:
After these steps you may access `/js-rest-client-test/` path where you will find
testing html page. Most of requests can be configured a little bit before
executing them by changing input values. See details of tests implementation in
Resources/public/js/cookbook-*.js files.
`Resources/public/js/cookbook-*.js` files.

To test promise-based version of the CAPI you can use `/js-rest-client-promise-test/` path.
This setup includes Q library as a downloaded file. See details of (rather basic) tests implementation
in `Resources/public/js/cookbook-PromiseCAPI.js`.
29 changes: 1 addition & 28 deletions dist/CAPI-min.js

Large diffs are not rendered by default.