Added rollup config.

This commit is contained in:
SamTV12345 2023-07-04 21:57:11 +02:00
parent 8926677a66
commit 8ddac2db45
72 changed files with 6079 additions and 15747 deletions

0
src/bin/buildDebian.sh Executable file → Normal file
View file

0
src/bin/buildForWindows.sh Executable file → Normal file
View file

0
src/bin/cleanRun.sh Executable file → Normal file
View file

0
src/bin/createRelease.sh Executable file → Normal file
View file

0
src/bin/deb-src/DEBIAN/postinst Executable file → Normal file
View file

0
src/bin/deb-src/DEBIAN/preinst Executable file → Normal file
View file

0
src/bin/deb-src/DEBIAN/prerm Executable file → Normal file
View file

0
src/bin/debugRun.sh Executable file → Normal file
View file

0
src/bin/etherpad-healthcheck Executable file → Normal file
View file

0
src/bin/fastRun.sh Executable file → Normal file
View file

0
src/bin/installDeps.sh Executable file → Normal file
View file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 0 B

Before After
Before After

0
src/bin/plugins/README.md Executable file → Normal file
View file

0
src/bin/plugins/checkPlugin.js Executable file → Normal file
View file

0
src/bin/plugins/getCorePlugins.sh Executable file → Normal file
View file

0
src/bin/plugins/lib/README.md Executable file → Normal file
View file

0
src/bin/plugins/lib/gitignore Executable file → Normal file
View file

0
src/bin/plugins/listOfficialPlugins Executable file → Normal file
View file

0
src/bin/plugins/reTestAllPlugins.sh Executable file → Normal file
View file

0
src/bin/plugins/updateAllPluginsScript.sh Executable file → Normal file
View file

0
src/bin/plugins/updateCorePlugins.sh Executable file → Normal file
View file

0
src/bin/run.sh Executable file → Normal file
View file

0
src/bin/safeRun.sh Executable file → Normal file
View file

0
src/bin/updatePlugins.sh Executable file → Normal file
View file

View file

@ -21,7 +21,7 @@
* limitations under the License. * limitations under the License.
*/ */
import ueberDB from 'ueberdb2'; import {Database} from 'ueberdb2';
import {dbSettings, dbType} from '../utils/Settings'; import {dbSettings, dbType} from '../utils/Settings';
import log4js from 'log4js'; import log4js from 'log4js';
import {shutdown as statsShutdown,createCollection} from '../stats'; import {shutdown as statsShutdown,createCollection} from '../stats';
@ -37,7 +37,7 @@ let db = null;
* Initializes the database with the settings provided by the settings module * Initializes the database with the settings provided by the settings module
*/ */
const init = async () => { const init = async () => {
db = new ueberDB.Database(dbType, dbSettings, null, logger); db = new Database(dbType, dbSettings, null, logger);
await db.init(); await db.init();
if (db.metrics != null) { if (db.metrics != null) {
for (const [metric, value] of Object.entries(db.metrics)) { for (const [metric, value] of Object.entries(db.metrics)) {

View file

@ -34,6 +34,12 @@ import {checkDeprecationStatus, enforceMinNodeVersion} from './utils/NodeVersion
import {Gate} from './utils/promises'; import {Gate} from './utils/promises';
import * as UpdateCheck from "./utils/UpdateCheck"; import * as UpdateCheck from "./utils/UpdateCheck";
import {Plugin} from "./models/Plugin"; import {Plugin} from "./models/Plugin";
import {db} from './db/DB'
import {createServer, server} from './hooks/express';
import {aCallAll} from '../static/js/pluginfw/hooks'
import * as pluginDefs from '../static/js/pluginfw/plugin_defs'
import * as plugins from "../static/js/pluginfw/plugins";
import {createCollection} from "./stats";
let wtfnode; let wtfnode;
if (settings.dumpOnUncleanExit) { if (settings.dumpOnUncleanExit) {
@ -45,13 +51,6 @@ if (settings.dumpOnUncleanExit) {
enforceMinNodeVersion('12.17.0'); enforceMinNodeVersion('12.17.0');
checkDeprecationStatus('12.17.0', '1.9.0'); checkDeprecationStatus('12.17.0', '1.9.0');
import db = require('./db/DB');
import {} from './db/DB'
import {createServer, server} from './hooks/express';
import hooks = require('../static/js/pluginfw/hooks');
import pluginDefs = require('../static/js/pluginfw/plugin_defs');
import plugins = require('../static/js/pluginfw/plugins');
import {createCollection} from "./stats";
const logger = log4js.getLogger('server'); const logger = log4js.getLogger('server');
console.log = logger.info.bind(logger); // do the same for others - console.debug, etc. console.log = logger.info.bind(logger); // do the same for others - console.debug, etc.
@ -149,8 +148,8 @@ export const start = async () => {
logger.info(`Installed plugins: ${installedPlugins}`); logger.info(`Installed plugins: ${installedPlugins}`);
logger.debug(`Installed parts:\n${plugins.formatParts()}`); logger.debug(`Installed parts:\n${plugins.formatParts()}`);
logger.debug(`Installed server-side hooks:\n${plugins.formatHooks('hooks', false)}`); logger.debug(`Installed server-side hooks:\n${plugins.formatHooks('hooks', false)}`);
await hooks.aCallAll('loadSettings', {settings}); await aCallAll('loadSettings', {settings});
await hooks.aCallAll(createServer()); await aCallAll(createServer());
} catch (err) { } catch (err) {
logger.error('Error occurred while starting Etherpad'); logger.error('Error occurred while starting Etherpad');
state = State.STATE_TRANSITION_FAILED; state = State.STATE_TRANSITION_FAILED;
@ -191,7 +190,7 @@ export const stop = async () => {
try { try {
let timeout = null; let timeout = null;
await Promise.race([ await Promise.race([
hooks.aCallAll('shutdown'), aCallAll('shutdown'),
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
timeout = setTimeout(() => reject(new Error('Timed out waiting for shutdown tasks')), 3000); timeout = setTimeout(() => reject(new Error('Timed out waiting for shutdown tasks')), 3000);
}), }),

View file

@ -30,7 +30,7 @@
import exp from "constants"; import exp from "constants";
// FIXME Is there a better way to enter dynamic package.json path // FIXME Is there a better way to enter dynamic package.json path
// @ts-ignore // @ts-ignore
import packageJSON from '../../../package.json' import packageJSON from '../../package.json'
import {findEtherpadRoot, makeAbsolute, isSubdir} from './AbsolutePaths'; import {findEtherpadRoot, makeAbsolute, isSubdir} from './AbsolutePaths';
import deepEqual from 'fast-deep-equal/es6'; import deepEqual from 'fast-deep-equal/es6';
import fs from 'fs'; import fs from 'fs';

View file

@ -145,7 +145,9 @@ const run_cmd = (args, opts:RunOpts = {
let px; let px;
const p = new Promise<string>((resolve, reject) => { px = {resolve, reject}; }); const p = new Promise<string>((resolve, reject) => { px = {resolve, reject}; });
// @ts-ignore
[, p.stdout, p.stderr] = streams; [, p.stdout, p.stderr] = streams;
// @ts-ignore
p.child = proc; p.child = proc;
const stdioStringPromises = [undefined, Promise.resolve(), Promise.resolve()]; const stdioStringPromises = [undefined, Promise.resolve(), Promise.resolve()];

21460
src/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,7 @@
} }
], ],
"dependencies": { "dependencies": {
"@rollup/plugin-json": "^6.0.0",
"async": "^3.2.2", "async": "^3.2.2",
"cjstoesm": "^2.1.2", "cjstoesm": "^2.1.2",
"clean-css": "^5.3.2", "clean-css": "^5.3.2",
@ -104,7 +105,9 @@
"sinon": "^13.0.2", "sinon": "^13.0.2",
"split-grid": "^1.0.11", "split-grid": "^1.0.11",
"supertest": "^6.3.3", "supertest": "^6.3.3",
"typescript": "^4.9.5" "typescript": "^4.9.5",
"rollup-plugin-typescript2": "^0.35.0",
"rollup-plugin-copy": "^3.4.0"
}, },
"engines": { "engines": {
"node": ">=14.15.0", "node": ">=14.15.0",
@ -118,7 +121,8 @@
"lint": "eslint .", "lint": "eslint .",
"test": "mocha --require @babel/register --timeout 120000 --recursive tests/backend/specs ../node_modules/ep_*/static/tests/backend/specs", "test": "mocha --require @babel/register --timeout 120000 --recursive tests/backend/specs ../node_modules/ep_*/static/tests/backend/specs",
"test-container": "mocha --timeout 5000 tests/container/specs/api", "test-container": "mocha --timeout 5000 tests/container/specs/api",
"dev": "concurrently \"npx tsc --watch\" \"nodemon -q dist/server.js\"" "dev": "concurrently \"npx tsc --watch\" \"nodemon -q dist/server.js\"",
"build": "npx rollup -c rollup.config.js"
}, },
"version": "1.9.0", "version": "1.9.0",
"license": "Apache-2.0" "license": "Apache-2.0"

28
src/rollup.config.js Normal file
View file

@ -0,0 +1,28 @@
const typescript = require('rollup-plugin-typescript2');
const copy = require('rollup-plugin-copy');
const glob = require('glob');
const json = require('@rollup/plugin-json')
module.exports = {
input: glob.sync('./node/**/*.ts'), // Matches all TypeScript files in the 'src' directory and its subdirectories
output: {
preserveModules: true,
dir: './dist',
format: 'cjs',
},
plugins: [
json(),
typescript({
tsconfig: 'tsconfig.json',
}),
copy({
targets: [
{src:'./package.json', dest:'./dist'},
{ src: './LICENSE', dest: './dist' },
{ src: './src/locales/*', dest: './dist/locales' },
{ src: './src/static/css/*', dest: './dist/static/css' },
{ src: './src/templates', dest: './dist/templates' },
{src:'./ep.json', dest:'./dist'},
]
})
],
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 B

After

Width:  |  Height:  |  Size: 0 B

Before After
Before After

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
src/static/img/brand.svg Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Before After
Before After

View file

@ -1,139 +1,139 @@
// Autosize 1.13 - jQuery plugin for textareas // Autosize 1.13 - jQuery plugin for textareas
// (c) 2012 Jack Moore - jacklmoore.com // (c) 2012 Jack Moore - jacklmoore.com
// license: www.opensource.org/licenses/mit-license.php // license: www.opensource.org/licenses/mit-license.php
(function ($) { (function ($) {
var defaults = { var defaults = {
className: 'autosizejs', className: 'autosizejs',
append: "", append: "",
callback: false callback: false
}, hidden = 'hidden', borderBox = 'border-box', lineHeight = 'lineHeight', copy = '<textarea tabindex="-1" style="position:absolute; top:-9999px; left:-9999px; right:auto; bottom:auto; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden;"/>', }, hidden = 'hidden', borderBox = 'border-box', lineHeight = 'lineHeight', copy = '<textarea tabindex="-1" style="position:absolute; top:-9999px; left:-9999px; right:auto; bottom:auto; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden;"/>',
// line-height is omitted because IE7/IE8 doesn't return the correct value. // line-height is omitted because IE7/IE8 doesn't return the correct value.
copyStyle = [ copyStyle = [
'fontFamily', 'fontFamily',
'fontSize', 'fontSize',
'fontWeight', 'fontWeight',
'fontStyle', 'fontStyle',
'letterSpacing', 'letterSpacing',
'textTransform', 'textTransform',
'wordSpacing', 'wordSpacing',
'textIndent' 'textIndent'
], oninput = 'oninput', onpropertychange = 'onpropertychange', test = $(copy)[0]; ], oninput = 'oninput', onpropertychange = 'onpropertychange', test = $(copy)[0];
// For testing support in old FireFox // For testing support in old FireFox
test.setAttribute(oninput, "return"); test.setAttribute(oninput, "return");
if ($.isFunction(test[oninput]) || onpropertychange in test) { if ($.isFunction(test[oninput]) || onpropertychange in test) {
// test that line-height can be accurately copied to avoid // test that line-height can be accurately copied to avoid
// incorrect value reporting in old IE and old Opera // incorrect value reporting in old IE and old Opera
$(test).css(lineHeight, '99px'); $(test).css(lineHeight, '99px');
if ($(test).css(lineHeight) === '99px') { if ($(test).css(lineHeight) === '99px') {
copyStyle.push(lineHeight); copyStyle.push(lineHeight);
} }
$.fn.autosize = function (options) { $.fn.autosize = function (options) {
options = $.extend({}, defaults, options || {}); options = $.extend({}, defaults, options || {});
return this.each(function () { return this.each(function () {
var ta = this, $ta = $(ta), mirror, minHeight = $ta.height(), maxHeight = parseInt($ta.css('maxHeight'), 10), active, i = copyStyle.length, resize, boxOffset = 0, value = ta.value, callback = $.isFunction(options.callback); var ta = this, $ta = $(ta), mirror, minHeight = $ta.height(), maxHeight = parseInt($ta.css('maxHeight'), 10), active, i = copyStyle.length, resize, boxOffset = 0, value = ta.value, callback = $.isFunction(options.callback);
if ($ta.css('box-sizing') === borderBox || $ta.css('-moz-box-sizing') === borderBox || $ta.css('-webkit-box-sizing') === borderBox) { if ($ta.css('box-sizing') === borderBox || $ta.css('-moz-box-sizing') === borderBox || $ta.css('-webkit-box-sizing') === borderBox) {
boxOffset = $ta.outerHeight() - $ta.height(); boxOffset = $ta.outerHeight() - $ta.height();
} }
if ($ta.data('mirror') || $ta.data('ismirror')) { if ($ta.data('mirror') || $ta.data('ismirror')) {
// if autosize has already been applied, exit. // if autosize has already been applied, exit.
// if autosize is being applied to a mirror element, exit. // if autosize is being applied to a mirror element, exit.
return; return;
} }
else { else {
mirror = $(copy).data('ismirror', true).addClass(options.className)[0]; mirror = $(copy).data('ismirror', true).addClass(options.className)[0];
resize = $ta.css('resize') === 'none' ? 'none' : 'horizontal'; resize = $ta.css('resize') === 'none' ? 'none' : 'horizontal';
$ta.data('mirror', $(mirror)).css({ $ta.data('mirror', $(mirror)).css({
overflow: hidden, overflow: hidden,
overflowY: hidden, overflowY: hidden,
wordWrap: 'break-word', wordWrap: 'break-word',
resize: resize resize: resize
}); });
} }
// Opera returns '-1px' when max-height is set to 'none'. // Opera returns '-1px' when max-height is set to 'none'.
maxHeight = maxHeight && maxHeight > 0 ? maxHeight : 9e4; maxHeight = maxHeight && maxHeight > 0 ? maxHeight : 9e4;
// Using mainly bare JS in this function because it is going // Using mainly bare JS in this function because it is going
// to fire very often while typing, and needs to very efficient. // to fire very often while typing, and needs to very efficient.
function adjust() { function adjust() {
var height, overflow, original; var height, overflow, original;
// the active flag keeps IE from tripping all over itself. Otherwise // the active flag keeps IE from tripping all over itself. Otherwise
// actions in the adjust function will cause IE to call adjust again. // actions in the adjust function will cause IE to call adjust again.
if (!active) { if (!active) {
active = true; active = true;
mirror.value = ta.value + options.append; mirror.value = ta.value + options.append;
mirror.style.overflowY = ta.style.overflowY; mirror.style.overflowY = ta.style.overflowY;
original = parseInt(ta.style.height, 10); original = parseInt(ta.style.height, 10);
// Update the width in case the original textarea width has changed // Update the width in case the original textarea width has changed
mirror.style.width = $ta.css('width'); mirror.style.width = $ta.css('width');
// Needed for IE to reliably return the correct scrollHeight // Needed for IE to reliably return the correct scrollHeight
mirror.scrollTop = 0; mirror.scrollTop = 0;
// Set a very high value for scrollTop to be sure the // Set a very high value for scrollTop to be sure the
// mirror is scrolled all the way to the bottom. // mirror is scrolled all the way to the bottom.
mirror.scrollTop = 9e4; mirror.scrollTop = 9e4;
height = mirror.scrollTop; height = mirror.scrollTop;
overflow = hidden; overflow = hidden;
if (height > maxHeight) { if (height > maxHeight) {
height = maxHeight; height = maxHeight;
overflow = 'scroll'; overflow = 'scroll';
} }
else if (height < minHeight) { else if (height < minHeight) {
height = minHeight; height = minHeight;
} }
height += boxOffset; height += boxOffset;
ta.style.overflowY = overflow; ta.style.overflowY = overflow;
if (original !== height) { if (original !== height) {
ta.style.height = height + 'px'; ta.style.height = height + 'px';
if (callback) { if (callback) {
options.callback.call(ta); options.callback.call(ta);
} }
} }
// This small timeout gives IE a chance to draw it's scrollbar // This small timeout gives IE a chance to draw it's scrollbar
// before adjust can be run again (prevents an infinite loop). // before adjust can be run again (prevents an infinite loop).
setTimeout(function () { setTimeout(function () {
active = false; active = false;
}, 1); }, 1);
} }
} }
// mirror is a duplicate textarea located off-screen that // mirror is a duplicate textarea located off-screen that
// is automatically updated to contain the same text as the // is automatically updated to contain the same text as the
// original textarea. mirror always has a height of 0. // original textarea. mirror always has a height of 0.
// This gives a cross-browser supported way getting the actual // This gives a cross-browser supported way getting the actual
// height of the text, through the scrollTop property. // height of the text, through the scrollTop property.
while (i--) { while (i--) {
mirror.style[copyStyle[i]] = $ta.css(copyStyle[i]); mirror.style[copyStyle[i]] = $ta.css(copyStyle[i]);
} }
$('body').append(mirror); $('body').append(mirror);
if (onpropertychange in ta) { if (onpropertychange in ta) {
if (oninput in ta) { if (oninput in ta) {
// Detects IE9. IE9 does not fire onpropertychange or oninput for deletions, // Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
// so binding to onkeyup to catch most of those occassions. There is no way that I // so binding to onkeyup to catch most of those occassions. There is no way that I
// know of to detect something like 'cut' in IE9. // know of to detect something like 'cut' in IE9.
ta[oninput] = ta.onkeyup = adjust; ta[oninput] = ta.onkeyup = adjust;
} }
else { else {
// IE7 / IE8 // IE7 / IE8
ta[onpropertychange] = adjust; ta[onpropertychange] = adjust;
} }
} }
else { else {
// Modern Browsers // Modern Browsers
ta[oninput] = adjust; ta[oninput] = adjust;
// The textarea overflow is now hidden. But Chrome doesn't reflow the text after the scrollbars are removed. // The textarea overflow is now hidden. But Chrome doesn't reflow the text after the scrollbars are removed.
// This is a hack to get Chrome to reflow it's text. // This is a hack to get Chrome to reflow it's text.
ta.value = ''; ta.value = '';
ta.value = value; ta.value = value;
} }
$(window).resize(adjust); $(window).resize(adjust);
// Allow for manual triggering if needed. // Allow for manual triggering if needed.
$ta.bind('autosize', adjust); $ta.bind('autosize', adjust);
// Call adjust in case the textarea already contains text. // Call adjust in case the textarea already contains text.
adjust(); adjust();
}); });
}; };
} }
else { else {
// Makes no changes for older browsers (FireFox3- and Safari4-) // Makes no changes for older browsers (FireFox3- and Safari4-)
$.fn.autosize = function (callback) { $.fn.autosize = function (callback) {
return this; return this;
}; };
} }
}(jQuery)); }(jQuery));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 KiB

After

Width:  |  Height:  |  Size: 0 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 0 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 355 KiB

After

Width:  |  Height:  |  Size: 0 B

Before After
Before After

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 635 B

After

Width:  |  Height:  |  Size: 0 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 B

After

Width:  |  Height:  |  Size: 0 B

Before After
Before After

0
src/tests/frontend/specs/admintroubleshooting.js Executable file → Normal file
View file

0
src/tests/frontend/specs/adminupdateplugins.js Executable file → Normal file
View file

View file

0
src/tests/frontend/specs/scrollTo.js Executable file → Normal file
View file

0
src/tests/frontend/travis/adminrunner.sh Executable file → Normal file
View file

0
src/tests/frontend/travis/runner.sh Executable file → Normal file
View file

0
src/tests/frontend/travis/runnerBackend.sh Executable file → Normal file
View file

0
src/tests/frontend/travis/runnerLoadTest.sh Executable file → Normal file
View file

0
src/tests/ratelimit/testlimits.sh Executable file → Normal file
View file

View file

@ -4,12 +4,13 @@
"allowJs": true, "allowJs": true,
"typeRoots": ["node_modules/@types"], "typeRoots": ["node_modules/@types"],
"types": ["node", "jquery"], "types": ["node", "jquery"],
"module": "commonjs", "module": "esnext",
"esModuleInterop": true, "esModuleInterop": true,
"moduleResolution": "node", "moduleResolution": "node",
"sourceMap": true, "sourceMap": true,
"target": "ES2015", "target": "ES2015",
"outDir": "dist" "outDir": "dist"
}, },
"exclude": ["node_modules"],
"lib": ["es2015"] "lib": ["es2015"]
} }

View file

@ -1,11 +1,11 @@
@echo off @echo off
REM Windows and symlinks do not get along with each other, so on Windows REM Windows and symlinks do not get along with each other, so on Windows
REM `node_modules\ep_etherpad-lite` is sometimes a full copy of `src` not a REM `node_modules\ep_etherpad-lite` is sometimes a full copy of `src` not a
REM symlink to `src`. If it is a copy, Node.js sees `src\foo.js` and REM symlink to `src`. If it is a copy, Node.js sees `src\foo.js` and
REM `node_modules\ep_etherpad-lite\foo.js` as two independent modules with REM `node_modules\ep_etherpad-lite\foo.js` as two independent modules with
REM independent state, when they should be treated as the same file. To work REM independent state, when they should be treated as the same file. To work
REM around this, everything must consistently use either `src` or REM around this, everything must consistently use either `src` or
REM `node_modules\ep_etherpad-lite` on Windows. Because some plugins access REM `node_modules\ep_etherpad-lite` on Windows. Because some plugins access
REM Etherpad internals via `require('ep_etherpad-lite/foo')`, REM Etherpad internals via `require('ep_etherpad-lite/foo')`,
REM `node_modules\ep_etherpad-lite` is used here. REM `node_modules\ep_etherpad-lite` is used here.
node node_modules\ep_etherpad-lite\node\server.js node node_modules\ep_etherpad-lite\node\server.js