Introduce PDF reader and note editor

This commit is contained in:
Martynas Bagdonas 2019-03-28 20:52:22 +02:00 committed by Dan Stillman
parent c3ff6eb66e
commit 2543a695e8
36 changed files with 2512 additions and 419 deletions

View file

@ -5,6 +5,9 @@ const getCopy = require('./copy');
const getJS = require('./js');
const getSass = require('./sass');
const getSymlinks = require('./symlinks');
const getPDFReader = require('./pdf-reader');
const getPDFWorker = require('./pdf-worker');
const getZoteroNoteEditor = require('./zotero-note-editor');
const { formatDirsForMatcher, getSignatures, writeSignatures, cleanUp, onSuccess, onError} = require('./utils');
const { dirs, symlinkDirs, copyDirs, symlinkFiles, jsFiles, scssFiles, ignoreMask } = require('./config');
@ -27,7 +30,10 @@ if (require.main === module) {
getSass(scssFiles, { ignore: ignoreMask }, signatures),
getSymlinks(symlinks, { nodir: true, ignore: ignoreMask }, signatures),
getSymlinks(symlinkDirs, { ignore: ignoreMask }, signatures),
cleanUp(signatures)
cleanUp(signatures),
getPDFReader(signatures),
getPDFWorker(signatures),
getZoteroNoteEditor(signatures)
]);
await writeSignatures(signatures);

View file

@ -17,6 +17,9 @@ if (require.main === module) {
try {
await getClean(path.join(ROOT, 'build'));
await getClean(path.join(ROOT, '.signatures.json'));
await getClean(path.join(ROOT, 'pdf-reader/build'));
await getClean(path.join(ROOT, 'pdf-worker/build'));
await getClean(path.join(ROOT, 'zotero-note-editor/build'));
} catch (err) {
process.exitCode = 1;
global.isError = true;

61
scripts/pdf-reader.js Normal file
View file

@ -0,0 +1,61 @@
'use strict';
const fs = require('fs-extra');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const { getSignatures, writeSignatures, onSuccess, onError } = require('./utils');
async function getPDFReader(signatures) {
const t1 = Date.now();
var { stdout } = await exec('git rev-parse HEAD', { cwd: './pdf-reader/pdf.js' });
const PDFJSHash = stdout.trim();
var { stdout } = await exec('git rev-parse HEAD', { cwd: './pdf-reader' });
const PDFReaderHash = stdout.trim();
let updated = false;
let name = 'pdf-reader/pdf.js';
if (!(name in signatures) || signatures[name].hash !== PDFJSHash) {
await exec('npm run build:pdf.js', { cwd: './pdf-reader' });
signatures[name] = { hash: PDFJSHash };
updated = true;
}
name = 'pdf-reader';
if (!(name in signatures) || signatures[name].hash !== PDFReaderHash) {
await exec('npm ci;npm run build:reader', { cwd: './pdf-reader' });
signatures[name] = { hash: PDFReaderHash };
updated = true;
}
if (updated) {
await fs.copy('./pdf-reader/build/zotero', './build/resource/pdf.js');
}
const t2 = Date.now();
return {
action: 'pdf-reader',
count: 1,
totalCount: 1,
processingTime: t2 - t1
};
}
module.exports = getPDFReader;
if (require.main === module) {
(async () => {
try {
const signatures = await getSignatures();
onSuccess(await getPDFReader(signatures));
await writeSignatures(signatures);
}
catch (err) {
process.exitCode = 1;
global.isError = true;
onError(err);
}
})();
}

61
scripts/pdf-worker.js Normal file
View file

@ -0,0 +1,61 @@
'use strict';
const fs = require('fs-extra');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const { getSignatures, writeSignatures, onSuccess, onError } = require('./utils');
async function getPDFWorker(signatures) {
const t1 = Date.now();
var { stdout } = await exec('git rev-parse HEAD', { cwd: './pdf-worker/pdf.js' });
const PDFJSHash = stdout.trim();
var { stdout } = await exec('git rev-parse HEAD', { cwd: './pdf-worker' });
const PDFWorkerHash = stdout.trim();
let updated = false;
let name = 'pdf-worker/pdf.js';
if (!(name in signatures) || signatures[name].hash !== PDFJSHash) {
await exec('npm run build:pdf.js', { cwd: './pdf-worker' });
signatures[name] = { hash: PDFJSHash };
updated = true;
}
name = 'pdf-worker';
if (!(name in signatures) || signatures[name].hash !== PDFWorkerHash) {
await exec('npm ci;npm run build:worker', { cwd: './pdf-worker' });
signatures[name] = { hash: PDFWorkerHash };
updated = true;
}
if (updated) {
await fs.copy('./pdf-worker/build/pdf-worker.js', './build/chrome/content/zotero/xpcom/pdfWorker/worker.js');
}
const t2 = Date.now();
return {
action: 'pdf-worker',
count: 1,
totalCount: 1,
processingTime: t2 - t1
};
}
module.exports = getPDFWorker;
if (require.main === module) {
(async () => {
try {
const signatures = await getSignatures();
onSuccess(await getPDFWorker(signatures));
await writeSignatures(signatures);
}
catch (err) {
process.exitCode = 1;
global.isError = true;
onError(err);
}
})();
}

View file

@ -0,0 +1,50 @@
'use strict';
const fs = require('fs-extra');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const { getSignatures, writeSignatures, onSuccess, onError } = require('./utils');
async function getZoteroNoteEditor(signatures) {
const t1 = Date.now();
var { stdout } = await exec('git rev-parse HEAD', { cwd: './zotero-note-editor' });
const zoteroNoteEditorHash = stdout.trim();
let updated = false;
let name = 'zotero-note-editor';
if (!(name in signatures) || signatures[name].hash !== zoteroNoteEditorHash) {
await exec('npm ci;npm run build', { cwd: './zotero-note-editor' });
signatures[name] = { hash: zoteroNoteEditorHash };
updated = true;
}
if (updated) {
await fs.copy('./zotero-note-editor/build/zotero', './build/resource/zotero-note-editor');
}
const t2 = Date.now();
return {
action: 'zotero-note-editor',
count: 1,
totalCount: 1,
processingTime: t2 - t1
};
}
module.exports = getZoteroNoteEditor;
if (require.main === module) {
(async () => {
try {
const signatures = await getSignatures();
onSuccess(await getZoteroNoteEditor(signatures));
await writeSignatures(signatures);
}
catch (err) {
process.exitCode = 1;
global.isError = true;
onError(err);
}
})();
}