Merge pull request #7063 from timvandermeij/gulp
Migrate `clean` and `importl10n` target to gulp
This commit is contained in:
commit
b540d7d6dc
@ -107,7 +107,7 @@ $ cd pdf.js
|
|||||||
|
|
||||||
## Trying the Viewer
|
## Trying the Viewer
|
||||||
|
|
||||||
With the prebuilt or source version open `web/viewer.html` in a browser and the test pdf should load. Note: the worker is not enabled for file:// urls, so use a server. If you're using the source build and have node, you can run `node make server`.
|
With the prebuilt or source version open `web/viewer.html` in a browser and the test pdf should load. Note: the worker is not enabled for file:// urls, so use a server. If you're using the source build and have node, you can run `gulp server`.
|
||||||
|
|
||||||
## More Information
|
## More Information
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
|
if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
|
||||||
alert('Please build the library and components using\n' +
|
alert('Please build the library and components using\n' +
|
||||||
' `node make generic components`');
|
' `gulp generic components`');
|
||||||
}
|
}
|
||||||
|
|
||||||
// The workerSrc property shall be specified.
|
// The workerSrc property shall be specified.
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
|
if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
|
||||||
alert('Please build the library and components using\n' +
|
alert('Please build the library and components using\n' +
|
||||||
' `node make generic components`');
|
' `gulp generic components`');
|
||||||
}
|
}
|
||||||
|
|
||||||
// The workerSrc property shall be specified.
|
// The workerSrc property shall be specified.
|
||||||
|
@ -8,7 +8,7 @@ simple and human-readable PDF.
|
|||||||
|
|
||||||
Instead of simply opening `index.html` in a browser, you must serve the page
|
Instead of simply opening `index.html` in a browser, you must serve the page
|
||||||
using a web server. This can be done on your local machine without an internet
|
using a web server. This can be done on your local machine without an internet
|
||||||
connection. In the root directory of PDF.js, run `node make server` in a
|
connection. In the root directory of PDF.js, run `gulp server` in a
|
||||||
terminal. The example can then be viewed using the following URL:
|
terminal. The example can then be viewed using the following URL:
|
||||||
|
|
||||||
`http://localhost:8888/examples/helloworld/index.html`
|
`http://localhost:8888/examples/helloworld/index.html`
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
//
|
//
|
||||||
// Basic node example that prints document metadata and text content.
|
// Basic node example that prints document metadata and text content.
|
||||||
// Requires single file built version of PDF.js -- please run
|
// Requires single file built version of PDF.js -- please run
|
||||||
// `node make singlefile` before running the example.
|
// `gulp singlefile` before running the example.
|
||||||
//
|
//
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
@ -12,7 +12,7 @@ var fs = require('fs');
|
|||||||
// HACK adding DOMParser to read XMP metadata.
|
// HACK adding DOMParser to read XMP metadata.
|
||||||
global.DOMParser = require('./domparsermock.js').DOMParserMock;
|
global.DOMParser = require('./domparsermock.js').DOMParserMock;
|
||||||
|
|
||||||
// Run `node make dist` to generate 'pdfjs-dist' npm package files.
|
// Run `gulp dist` to generate 'pdfjs-dist' npm package files.
|
||||||
require('../../build/dist');
|
require('../../build/dist');
|
||||||
|
|
||||||
// Loading file from file system into typed array
|
// Loading file from file system into typed array
|
||||||
|
@ -10,7 +10,7 @@ var fs = require('fs');
|
|||||||
// HACK few hacks to let PDF.js be loaded not as a module in global space.
|
// HACK few hacks to let PDF.js be loaded not as a module in global space.
|
||||||
require('./domstubs.js');
|
require('./domstubs.js');
|
||||||
|
|
||||||
// Run `node make dist` to generate 'pdfjs-dist' npm package files.
|
// Run `gulp dist` to generate 'pdfjs-dist' npm package files.
|
||||||
require('../../build/dist');
|
require('../../build/dist');
|
||||||
|
|
||||||
// Loading file from file system into typed array
|
// Loading file from file system into typed array
|
||||||
|
@ -63,7 +63,7 @@ function pageLoaded() {
|
|||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
if (typeof PDFJS === 'undefined') {
|
if (typeof PDFJS === 'undefined') {
|
||||||
alert('Built version of PDF.js was not found.\n' +
|
alert('Built version of PDF.js was not found.\n' +
|
||||||
'Please run `node make generic`.');
|
'Please run `gulp generic`.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pageLoaded();
|
pageLoaded();
|
||||||
|
@ -6,7 +6,7 @@ Example to demonstrate PDF.js library usage with webpack.
|
|||||||
|
|
||||||
Build project and install the example dependencies:
|
Build project and install the example dependencies:
|
||||||
|
|
||||||
$ node make dist
|
$ gulp dist
|
||||||
$ cd examples/webpack
|
$ cd examples/webpack
|
||||||
$ npm install
|
$ npm install
|
||||||
|
|
||||||
|
10
external/importL10n/locales.js
vendored
10
external/importL10n/locales.js
vendored
@ -41,7 +41,7 @@ function normalizeText(s) {
|
|||||||
return s.replace(/\r\n?/g, '\n').replace(/\uFEFF/g, '');
|
return s.replace(/\r\n?/g, '\n').replace(/\uFEFF/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadLanguageFiles(langCode, callback) {
|
function downloadLanguageFiles(root, langCode, callback) {
|
||||||
console.log('Downloading ' + langCode + '...');
|
console.log('Downloading ' + langCode + '...');
|
||||||
|
|
||||||
// Constants for constructing the URLs. Translations are taken from the
|
// Constants for constructing the URLs. Translations are taken from the
|
||||||
@ -56,12 +56,12 @@ function downloadLanguageFiles(langCode, callback) {
|
|||||||
var downloadsLeft = files.length;
|
var downloadsLeft = files.length;
|
||||||
|
|
||||||
if (!fs.existsSync(langCode)) {
|
if (!fs.existsSync(langCode)) {
|
||||||
fs.mkdirSync(langCode);
|
fs.mkdirSync(path.join(root, langCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download the necessary files for this language.
|
// Download the necessary files for this language.
|
||||||
files.forEach(function(fileName) {
|
files.forEach(function(fileName) {
|
||||||
var outputPath = path.join(langCode, fileName);
|
var outputPath = path.join(root, langCode, fileName);
|
||||||
var url = MOZCENTRAL_ROOT + langCode + MOZCENTRAL_PDFJS_DIR +
|
var url = MOZCENTRAL_ROOT + langCode + MOZCENTRAL_PDFJS_DIR +
|
||||||
fileName + MOZCENTRAL_RAW_FLAG;
|
fileName + MOZCENTRAL_RAW_FLAG;
|
||||||
var request = http.get(url, function(response) {
|
var request = http.get(url, function(response) {
|
||||||
@ -81,13 +81,13 @@ function downloadLanguageFiles(langCode, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadL10n() {
|
function downloadL10n(root) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
(function next() {
|
(function next() {
|
||||||
if (i >= langCodes.length) {
|
if (i >= langCodes.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
downloadLanguageFiles(langCodes[i++], next);
|
downloadLanguageFiles(root, langCodes[i++], next);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
gulpfile.js
24
gulpfile.js
@ -17,10 +17,15 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
var gutil = require('gulp-util');
|
var gutil = require('gulp-util');
|
||||||
|
var rimraf = require('rimraf');
|
||||||
var stream = require('stream');
|
var stream = require('stream');
|
||||||
|
|
||||||
|
var BUILD_DIR = 'build/';
|
||||||
|
var L10N_DIR = 'l10n/';
|
||||||
|
|
||||||
require('./make.js');
|
require('./make.js');
|
||||||
|
|
||||||
function createStringSource(filename, content) {
|
function createStringSource(filename, content) {
|
||||||
@ -56,6 +61,13 @@ gulp.task('server', function () {
|
|||||||
server.start();
|
server.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('clean', function(callback) {
|
||||||
|
console.log();
|
||||||
|
console.log('### Cleaning up project builds');
|
||||||
|
|
||||||
|
rimraf(BUILD_DIR, callback);
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('makefile', function () {
|
gulp.task('makefile', function () {
|
||||||
var makefileContent = 'help:\n\tgulp\n\n';
|
var makefileContent = 'help:\n\tgulp\n\n';
|
||||||
var targetsNames = [];
|
var targetsNames = [];
|
||||||
@ -68,6 +80,18 @@ gulp.task('makefile', function () {
|
|||||||
.pipe(gulp.dest('.'));
|
.pipe(gulp.dest('.'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('importl10n', function() {
|
||||||
|
var locales = require('./external/importL10n/locales.js');
|
||||||
|
|
||||||
|
console.log();
|
||||||
|
console.log('### Importing translations from mozilla-aurora');
|
||||||
|
|
||||||
|
if (!fs.existsSync(L10N_DIR)) {
|
||||||
|
fs.mkdirSync(L10N_DIR);
|
||||||
|
}
|
||||||
|
locales.downloadL10n(L10N_DIR);
|
||||||
|
});
|
||||||
|
|
||||||
// Getting all shelljs registered tasks and register them with gulp
|
// Getting all shelljs registered tasks and register them with gulp
|
||||||
var gulpContext = false;
|
var gulpContext = false;
|
||||||
for (var taskName in global.target) {
|
for (var taskName in global.target) {
|
||||||
|
26
make.js
26
make.js
@ -1357,7 +1357,7 @@ target.mozcentralbaseline = function() {
|
|||||||
if (test('-d', 'build')) {
|
if (test('-d', 'build')) {
|
||||||
rm('-rf', 'build');
|
rm('-rf', 'build');
|
||||||
}
|
}
|
||||||
exec('node make mozcentral');
|
exec('gulp mozcentral');
|
||||||
|
|
||||||
cd(ROOT_DIR);
|
cd(ROOT_DIR);
|
||||||
mkdir(MOZCENTRAL_BASELINE_DIR);
|
mkdir(MOZCENTRAL_BASELINE_DIR);
|
||||||
@ -1391,7 +1391,7 @@ target.mozcentraldiff = function() {
|
|||||||
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
|
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
|
||||||
if (!test('-d', MOZCENTRAL_BASELINE_DIR)) {
|
if (!test('-d', MOZCENTRAL_BASELINE_DIR)) {
|
||||||
echo('mozcentral baseline was not found');
|
echo('mozcentral baseline was not found');
|
||||||
echo('Please build one using "node make mozcentralbaseline"');
|
echo('Please build one using "gulp mozcentralbaseline"');
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
cd(MOZCENTRAL_BASELINE_DIR);
|
cd(MOZCENTRAL_BASELINE_DIR);
|
||||||
@ -1432,7 +1432,7 @@ target.mozcentralcheck = function() {
|
|||||||
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
|
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
|
||||||
if (!test('-d', MOZCENTRAL_BASELINE_DIR)) {
|
if (!test('-d', MOZCENTRAL_BASELINE_DIR)) {
|
||||||
echo('mozcentral baseline was not found');
|
echo('mozcentral baseline was not found');
|
||||||
echo('Please build one using "node make mozcentralbaseline"');
|
echo('Please build one using "gulp mozcentralbaseline"');
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
cd(MOZCENTRAL_BASELINE_DIR);
|
cd(MOZCENTRAL_BASELINE_DIR);
|
||||||
@ -1512,11 +1512,7 @@ target.lint = function() {
|
|||||||
// make clean
|
// make clean
|
||||||
//
|
//
|
||||||
target.clean = function() {
|
target.clean = function() {
|
||||||
cd(ROOT_DIR);
|
exit(exec('gulp clean'));
|
||||||
echo();
|
|
||||||
echo('### Cleaning up project builds');
|
|
||||||
|
|
||||||
rm('-rf', BUILD_DIR);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1530,17 +1526,5 @@ target.makefile = function () {
|
|||||||
//make importl10n
|
//make importl10n
|
||||||
//
|
//
|
||||||
target.importl10n = function() {
|
target.importl10n = function() {
|
||||||
var locales = require('./external/importL10n/locales.js');
|
exit(exec('gulp importl10n'));
|
||||||
var LOCAL_L10N_DIR = 'l10n';
|
|
||||||
|
|
||||||
cd(ROOT_DIR);
|
|
||||||
echo();
|
|
||||||
echo('### Importing translations from mozilla-aurora');
|
|
||||||
|
|
||||||
if (!test('-d', LOCAL_L10N_DIR)) {
|
|
||||||
mkdir(LOCAL_L10N_DIR);
|
|
||||||
}
|
|
||||||
cd(LOCAL_L10N_DIR);
|
|
||||||
|
|
||||||
locales.downloadL10n();
|
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@ var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
|
|||||||
* recently opened files.
|
* recently opened files.
|
||||||
*
|
*
|
||||||
* The way that the view parameters are stored depends on how PDF.js is built,
|
* The way that the view parameters are stored depends on how PDF.js is built,
|
||||||
* for 'node make <flag>' the following cases exist:
|
* for 'gulp <flag>' the following cases exist:
|
||||||
* - FIREFOX or MOZCENTRAL - uses sessionStorage.
|
* - FIREFOX or MOZCENTRAL - uses sessionStorage.
|
||||||
* - GENERIC or CHROME - uses localStorage, if it is available.
|
* - GENERIC or CHROME - uses localStorage, if it is available.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user