mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-07-20 16:54:17 +00:00
chore: migrated settings to esm6 (#7062)
* chore: migrated settings to esm6 * chore: fixed frontends * chore: fixed missing usage of specialpages * chore: fixed last errors for settings * chore: fixed favicon test
This commit is contained in:
parent
920308a627
commit
8588d99f12
57 changed files with 698 additions and 562 deletions
|
|
@ -21,8 +21,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Database} from 'ueberdb2';
|
||||
const settings = require('../utils/Settings');
|
||||
import {Database, DatabaseType} from 'ueberdb2';
|
||||
import settings from '../utils/Settings';
|
||||
import log4js from 'log4js';
|
||||
const stats = require('../stats')
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ exports.db = null;
|
|||
* Initializes the database with the settings provided by the settings module
|
||||
*/
|
||||
exports.init = async () => {
|
||||
exports.db = new Database(settings.dbType, settings.dbSettings, null, logger);
|
||||
exports.db = new Database(settings.dbType as DatabaseType, settings.dbSettings, null, logger);
|
||||
await exports.db.init();
|
||||
if (exports.db.metrics != null) {
|
||||
for (const [metric, value] of Object.entries(exports.db.metrics)) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import AttributePool from '../../static/js/AttributePool';
|
|||
const Stream = require('../utils/Stream');
|
||||
const assert = require('assert').strict;
|
||||
const db = require('./DB');
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
const authorManager = require('./AuthorManager');
|
||||
const padManager = require('./PadManager');
|
||||
const padMessageHandler = require('../handler/PadMessageHandler');
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import {PadType} from "../types/PadType";
|
|||
const CustomError = require('../utils/customError');
|
||||
const Pad = require('../db/Pad');
|
||||
const db = require('./DB');
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
|
||||
/**
|
||||
* A cache of all loaded Pads.
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ const hooks = require('../../static/js/pluginfw/hooks');
|
|||
const padManager = require('./PadManager');
|
||||
import readOnlyManager from './ReadOnlyManager';
|
||||
const sessionManager = require('./SessionManager');
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
const webaccess = require('../hooks/express/webaccess');
|
||||
const log4js = require('log4js');
|
||||
const authLogger = log4js.getLogger('auth');
|
||||
|
|
|
|||
|
|
@ -20,12 +20,13 @@
|
|||
* require("./index").require("./path/to/template.ejs")
|
||||
*/
|
||||
|
||||
const ejs = require('ejs');
|
||||
const fs = require('fs');
|
||||
import ejs from 'ejs';
|
||||
import fs from 'fs';
|
||||
const hooks = require('../../static/js/pluginfw/hooks');
|
||||
const path = require('path');
|
||||
const resolve = require('resolve');
|
||||
const settings = require('../utils/Settings');
|
||||
import path from 'node:path';
|
||||
// @ts-ignore
|
||||
import resolve from 'resolve';
|
||||
import settings from '../utils/Settings';
|
||||
import {pluginInstallPath} from '../../static/js/pluginfw/installer'
|
||||
|
||||
const templateCache = new Map();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import {MapArrayType} from "../types/MapType";
|
|||
import { jwtDecode } from "jwt-decode";
|
||||
const api = require('../db/API');
|
||||
const padManager = require('../db/PadManager');
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
import createHTTPError from 'http-errors';
|
||||
import {Http2ServerRequest} from "node:http2";
|
||||
import {publicKeyExported} from "../security/OAuth2Provider";
|
||||
|
|
@ -183,7 +183,7 @@ exports.handle = async function (apiVersion: string, functionName: string, field
|
|||
throw new createHTTPError.Unauthorized('no or wrong API Key');
|
||||
}
|
||||
try {
|
||||
const clientIds: string[] = settings.sso.clients?.map((client: {client_id: string}) => client.client_id);
|
||||
const clientIds: string[] = settings.sso.clients?.map((client: {client_id: string}) => client.client_id) ?? [];
|
||||
const jwtToCheck = req.headers.authorization.replace("Bearer ", "")
|
||||
const payload = jwtDecode(jwtToCheck)
|
||||
// client_credentials
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
const absolutePaths = require('../utils/AbsolutePaths');
|
||||
import * as absolutePaths from '../utils/AbsolutePaths';
|
||||
import fs from 'fs';
|
||||
import log4js from 'log4js';
|
||||
import randomString from '../utils/randomstring';
|
||||
const argv = require('../utils/Cli').argv;
|
||||
const settings = require('../utils/Settings');
|
||||
import {argv} from '../utils/Cli'
|
||||
import settings from '../utils/Settings';
|
||||
|
||||
const apiHandlerLogger = log4js.getLogger('APIHandler');
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ const exporthtml = require('../utils/ExportHtml');
|
|||
const exporttxt = require('../utils/ExportTxt');
|
||||
const exportEtherpad = require('../utils/ExportEtherpad');
|
||||
import fs from 'fs';
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
import os from 'os';
|
||||
const hooks = require('../../static/js/pluginfw/hooks');
|
||||
import util from 'util';
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ const padManager = require('../db/PadManager');
|
|||
const padMessageHandler = require('./PadMessageHandler');
|
||||
import {promises as fs} from 'fs';
|
||||
import path from 'path';
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
const {Formidable} = require('formidable');
|
||||
import os from 'os';
|
||||
const importHtml = require('../utils/ImportHtml');
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ const AttributeManager = require('../../static/js/AttributeManager');
|
|||
const authorManager = require('../db/AuthorManager');
|
||||
import padutils from '../../static/js/pad_utils';
|
||||
import readOnlyManager from '../db/ReadOnlyManager';
|
||||
const settings = require('../utils/Settings');
|
||||
import settings, {
|
||||
exportAvailable,
|
||||
abiwordAvailable,
|
||||
sofficeAvailable
|
||||
} from '../utils/Settings';
|
||||
const securityManager = require('../db/SecurityManager');
|
||||
const plugins = require('../../static/js/pluginfw/plugin_defs');
|
||||
import log4js from 'log4js';
|
||||
|
|
@ -1021,9 +1025,9 @@ const handleClientReady = async (socket:any, message: ClientReadyMessage) => {
|
|||
serverTimestamp: Date.now(),
|
||||
sessionRefreshInterval: settings.cookie.sessionRefreshInterval,
|
||||
userId: sessionInfo.author,
|
||||
abiwordAvailable: settings.abiwordAvailable(),
|
||||
sofficeAvailable: settings.sofficeAvailable(),
|
||||
exportAvailable: settings.exportAvailable(),
|
||||
abiwordAvailable: abiwordAvailable(),
|
||||
sofficeAvailable: sofficeAvailable(),
|
||||
exportAvailable: exportAvailable(),
|
||||
plugins: {
|
||||
plugins: plugins.plugins,
|
||||
parts: plugins.parts,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const apiHandler = require('./APIHandler')
|
|||
import {serve, setup} from 'swagger-ui-express'
|
||||
import express from "express";
|
||||
|
||||
const settings = require('../utils/Settings')
|
||||
import settings from '../utils/Settings';
|
||||
|
||||
|
||||
type RestAPIMapping = {
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
import {MapArrayType} from "../types/MapType";
|
||||
import {SocketModule} from "../types/SocketModule";
|
||||
const log4js = require('log4js');
|
||||
const settings = require('../utils/Settings');
|
||||
import log4js from 'log4js';
|
||||
import settings from '../utils/Settings';
|
||||
const stats = require('../../node/stats')
|
||||
|
||||
const logger = log4js.getLogger('socket.io');
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import fs from 'fs';
|
|||
const hooks = require('../../static/js/pluginfw/hooks');
|
||||
import log4js from 'log4js';
|
||||
const SessionStore = require('../db/SessionStore');
|
||||
const settings = require('../utils/Settings');
|
||||
import settings, {getEpVersion, getGitCommit} from '../utils/Settings';
|
||||
const stats = require('../stats')
|
||||
import util from 'util';
|
||||
const webaccess = require('./express/webaccess');
|
||||
|
|
@ -67,9 +67,9 @@ const closeServer = async () => {
|
|||
exports.createServer = async () => {
|
||||
console.log('Report bugs at https://github.com/ether/etherpad-lite/issues');
|
||||
|
||||
serverName = `Etherpad ${settings.getGitCommit()} (https://etherpad.org)`;
|
||||
serverName = `Etherpad ${getGitCommit()} (https://etherpad.org)`;
|
||||
|
||||
console.log(`Your Etherpad version is ${settings.getEpVersion()} (${settings.getGitCommit()})`);
|
||||
console.log(`Your Etherpad version is ${getEpVersion()} (${getGitCommit()})`);
|
||||
|
||||
await exports.restartServer();
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ exports.restartServer = async () => {
|
|||
// starts listening to requests as reported in issue #158. Not installing the log4js connect
|
||||
// logger when the log level has a higher severity than INFO since it would not log at that level
|
||||
// anyway.
|
||||
if (!(settings.loglevel === 'WARN' && settings.loglevel === 'ERROR')) {
|
||||
if (!(settings.loglevel === 'WARN' || settings.loglevel === 'ERROR')) {
|
||||
app.use(log4js.connectLogger(logger, {
|
||||
level: log4js.levels.DEBUG.levelStr,
|
||||
format: ':status, :method :url',
|
||||
|
|
@ -189,7 +189,12 @@ exports.restartServer = async () => {
|
|||
secretRotator = new SecretRotator(
|
||||
'expressSessionSecrets', keyRotationInterval, sessionLifetime, settings.sessionKey);
|
||||
await secretRotator.start();
|
||||
secret = secretRotator.secrets;
|
||||
const secrets = secretRotator.secrets;
|
||||
if (Array.isArray(secrets)) {
|
||||
secret = secrets[0];
|
||||
} else {
|
||||
secret = secretRotator.secrets as unknown as string;
|
||||
}
|
||||
}
|
||||
if (!secret) throw new Error('missing cookie signing secret');
|
||||
|
||||
|
|
@ -206,7 +211,7 @@ exports.restartServer = async () => {
|
|||
// cleaner :)
|
||||
name: 'express_sid',
|
||||
cookie: {
|
||||
maxAge: sessionLifetime || null, // Convert 0 to null.
|
||||
maxAge: sessionLifetime || undefined, // Convert 0 to null.
|
||||
sameSite: settings.cookie.sameSite,
|
||||
|
||||
// The automatic express-session mechanism for determining if the application is being served
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import * as url from "node:url";
|
||||
import {MapArrayType} from "../../types/MapType";
|
||||
|
||||
const settings = require('ep_etherpad-lite/node/utils/Settings');
|
||||
import settings from 'ep_etherpad-lite/node/utils/Settings';
|
||||
|
||||
const ADMIN_PATH = path.join(settings.root, 'src', 'templates');
|
||||
const PROXY_HEADER = "x-proxy-path"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import log4js from 'log4js';
|
|||
const fsp = require('fs').promises;
|
||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||
const plugins = require('../../../static/js/pluginfw/plugins');
|
||||
const settings = require('../../utils/Settings');
|
||||
import settings, {getEpVersion, getGitCommit, reloadSettings} from '../../utils/Settings';
|
||||
import {getLatestVersion} from '../../utils/UpdateCheck';
|
||||
const padManager = require('../../db/PadManager');
|
||||
const api = require('../../db/API');
|
||||
|
|
@ -73,8 +73,8 @@ exports.socketio = (hookName: string, {io}: any) => {
|
|||
|
||||
|
||||
socket.on('help', () => {
|
||||
const gitCommit = settings.getGitCommit();
|
||||
const epVersion = settings.getEpVersion();
|
||||
const gitCommit = getGitCommit();
|
||||
const epVersion = getEpVersion();
|
||||
|
||||
const hooks: Map<string, Map<string, string>> = plugins.getHooks('hooks', false);
|
||||
const clientHooks: Map<string, Map<string, string>> = plugins.getHooks('client_hooks', false);
|
||||
|
|
@ -287,7 +287,7 @@ exports.socketio = (hookName: string, {io}: any) => {
|
|||
|
||||
socket.on('restartServer', async () => {
|
||||
logger.info('Admin request to restart server through a socket on /admin/settings');
|
||||
settings.reloadSettings();
|
||||
reloadSettings();
|
||||
await plugins.update();
|
||||
await hooks.aCallAll('loadSettings', {settings});
|
||||
await hooks.aCallAll('restartServer');
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
||||
|
||||
const hasPadAccess = require('../../padaccess');
|
||||
const settings = require('../../utils/Settings');
|
||||
import settings, {exportAvailable} from '../../utils/Settings';
|
||||
const exportHandler = require('../../handler/ExportHandler');
|
||||
const importHandler = require('../../handler/ImportHandler');
|
||||
const padManager = require('../../db/PadManager');
|
||||
|
|
@ -35,7 +35,7 @@ exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Functio
|
|||
}
|
||||
|
||||
// if abiword is disabled, and this is a format we only support with abiword, output a message
|
||||
if (settings.exportAvailable() === 'no' &&
|
||||
if (exportAvailable() === 'no' &&
|
||||
['odt', 'pdf', 'doc'].indexOf(req.params.type) !== -1) {
|
||||
console.error(`Impossible to export pad "${req.params.pad}" in ${req.params.type} format.` +
|
||||
' There is no converter configured');
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ const cloneDeep = require('lodash.clonedeep');
|
|||
const createHTTPError = require('http-errors');
|
||||
|
||||
const apiHandler = require('../../handler/APIHandler');
|
||||
const settings = require('../../utils/Settings');
|
||||
import settings from '../../utils/Settings';
|
||||
|
||||
const log4js = require('log4js');
|
||||
import log4js from 'log4js';
|
||||
const logger = log4js.getLogger('API');
|
||||
|
||||
// https://github.com/OAI/OpenAPI-Specification/tree/master/schemas/v3.0
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
||||
const settings = require('../../utils/Settings');
|
||||
import settings from '../../utils/Settings';
|
||||
|
||||
const pwa = {
|
||||
name: settings.title || "Etherpad",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import events from 'events';
|
|||
const express = require('../express');
|
||||
import log4js from 'log4js';
|
||||
const proxyaddr = require('proxy-addr');
|
||||
const settings = require('../../utils/Settings');
|
||||
import settings from '../../utils/Settings';
|
||||
import {Server, Socket} from 'socket.io'
|
||||
const socketIORouter = require('../../handler/SocketIORouter');
|
||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import fs from 'node:fs';
|
|||
const fsp = fs.promises;
|
||||
const toolbar = require('../../utils/toolbar');
|
||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||
const settings = require('../../utils/Settings');
|
||||
import settings, {getEpVersion} from '../../utils/Settings';
|
||||
import util from 'node:util';
|
||||
const webaccess = require('./webaccess');
|
||||
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||
|
|
@ -20,14 +20,14 @@ exports.socketio = (hookName: string, {io}: any) => {
|
|||
}
|
||||
|
||||
|
||||
exports.expressPreSession = async (hookName:string, {app, settings}:ArgsExpressType) => {
|
||||
exports.expressPreSession = async (hookName:string, {app}:ArgsExpressType) => {
|
||||
// This endpoint is intended to conform to:
|
||||
// https://www.ietf.org/archive/id/draft-inadarei-api-health-check-06.html
|
||||
app.get('/health', (req:any, res:any) => {
|
||||
res.set('Content-Type', 'application/health+json');
|
||||
res.json({
|
||||
status: 'pass',
|
||||
releaseId: settings.getEpVersion(),
|
||||
releaseId: getEpVersion(),
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -43,6 +43,10 @@ exports.expressPreSession = async (hookName:string, {app, settings}:ArgsExpressT
|
|||
});
|
||||
|
||||
app.get('/robots.txt', (req:any, res:any) => {
|
||||
if (!settings.skinName) {
|
||||
// if no skin is set, send the default robots.txt
|
||||
return res.sendFile(path.join(settings.root, 'src', 'static', 'robots.txt'));
|
||||
}
|
||||
let filePath =
|
||||
path.join(settings.root, 'src', 'static', 'skins', settings.skinName, 'robots.txt');
|
||||
res.sendFile(filePath, (err:any) => {
|
||||
|
|
@ -66,11 +70,13 @@ exports.expressPreSession = async (hookName:string, {app, settings}:ArgsExpressT
|
|||
}
|
||||
|
||||
|
||||
console.log("Favicon is", settings.favicon)
|
||||
const fns = [
|
||||
...(settings.favicon ? [path.resolve(settings.root, settings.favicon)] : []),
|
||||
path.join(settings.root, 'src', 'static', 'skins', settings.skinName, 'favicon.ico'),
|
||||
settings.skinName && path.join(settings.root, 'src', 'static', 'skins', settings.skinName, 'favicon.ico'),
|
||||
path.join(settings.root, 'src', 'static', 'favicon.ico'),
|
||||
];
|
||||
].filter(f=>f != null);
|
||||
console.log('FNS are', fns)
|
||||
for (const fn of fns) {
|
||||
try {
|
||||
await fsp.access(fn, fs.constants.R_OK);
|
||||
|
|
@ -178,7 +184,8 @@ const handleLiveReload = async (args: ArgsExpressType, padString: string, timeSl
|
|||
req,
|
||||
toolbar,
|
||||
isReadOnly,
|
||||
entrypoint: '/watch/pad?hash=' + hash
|
||||
entrypoint: '/watch/pad?hash=' + hash,
|
||||
settings: settings.getPublicSettings()
|
||||
})
|
||||
res.send(content);
|
||||
})
|
||||
|
|
@ -207,7 +214,8 @@ const handleLiveReload = async (args: ArgsExpressType, padString: string, timeSl
|
|||
req,
|
||||
toolbar,
|
||||
isReadOnly,
|
||||
entrypoint: '/watch/timeslider?hash=' + hash
|
||||
entrypoint: '/watch/timeslider?hash=' + hash,
|
||||
settings: settings.getPublicSettings()
|
||||
})
|
||||
res.send(content);
|
||||
})
|
||||
|
|
@ -334,7 +342,8 @@ exports.expressCreateServer = async (_hookName: string, args: ArgsExpressType, c
|
|||
req,
|
||||
toolbar,
|
||||
isReadOnly,
|
||||
entrypoint: "../"+fileNamePad
|
||||
entrypoint: "../"+fileNamePad,
|
||||
settings: settings.getPublicSettings()
|
||||
})
|
||||
res.send(content);
|
||||
});
|
||||
|
|
@ -348,7 +357,8 @@ exports.expressCreateServer = async (_hookName: string, args: ArgsExpressType, c
|
|||
res.send(eejs.require('ep_etherpad-lite/templates/timeslider.html', {
|
||||
req,
|
||||
toolbar,
|
||||
entrypoint: "../../"+fileNameTimeSlider
|
||||
entrypoint: "../../"+fileNameTimeSlider,
|
||||
settings: settings.getPublicSettings()
|
||||
}));
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import {minify} from '../../utils/Minify';
|
|||
import path from 'node:path';
|
||||
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
||||
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||
const settings = require('../../utils/Settings');
|
||||
import settings from '../../utils/Settings';
|
||||
|
||||
// Rewrite tar to include modules with no extensions and proper rooted paths.
|
||||
const getTar = async () => {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {SocketClientRequest} from "../../types/SocketClientRequest";
|
|||
import {WebAccessTypes} from "../../types/WebAccessTypes";
|
||||
import {SettingsUser} from "../../types/SettingsUser";
|
||||
const httpLogger = log4js.getLogger('http');
|
||||
const settings = require('../../utils/Settings');
|
||||
import settings from '../../utils/Settings';
|
||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||
import readOnlyManager from '../../db/ReadOnlyManager';
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ import type {MapArrayType} from "../types/MapType";
|
|||
import {I18nPluginDefs} from "../types/I18nPluginDefs";
|
||||
|
||||
const languages = require('languages4translatewiki');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const _ = require('underscore');
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import _ from 'underscore';
|
||||
const pluginDefs = require('../../static/js/pluginfw/plugin_defs');
|
||||
import existsSync from '../utils/path_exists';
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
|
||||
// returns all existing messages merged together and grouped by langcode
|
||||
// {es: {"foo": "string"}, en:...}
|
||||
|
|
@ -73,7 +73,7 @@ const getAllLocales = () => {
|
|||
'for Customization for Administrators, under Localization.');
|
||||
if (settings.customLocaleStrings) {
|
||||
if (typeof settings.customLocaleStrings !== 'object') throw wrongFormatErr;
|
||||
_.each(settings.customLocaleStrings, (overrides:MapArrayType<string> , langcode:string) => {
|
||||
_.each(settings.customLocaleStrings, (overrides , langcode) => {
|
||||
if (typeof overrides !== 'object') throw wrongFormatErr;
|
||||
_.each(overrides, (localeString:string|object, key:string) => {
|
||||
if (typeof localeString !== 'string') throw wrongFormatErr;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import Provider, {Account, Configuration} from 'oidc-provider';
|
|||
import {generateKeyPair, exportJWK, CryptoKey} from 'jose'
|
||||
import MemoryAdapter from "./OIDCAdapter";
|
||||
import path from "path";
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
import {IncomingForm} from 'formidable'
|
||||
import express from 'express';
|
||||
import {format} from 'url'
|
||||
|
|
@ -138,7 +138,7 @@ export const expressCreateServer = async (hookName: string, args: ArgsExpressTyp
|
|||
} else if (token.kind === "ClientCredentials") {
|
||||
let extraParams: MapArrayType<string> = {}
|
||||
|
||||
settings.sso.clients
|
||||
settings.sso.clients && settings.sso.clients
|
||||
.filter((client:any) => client.client_id === token.clientId)
|
||||
.forEach((client:any) => {
|
||||
if(client.extraParams !== undefined) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import pkg from '../package.json';
|
|||
import {checkForMigration} from "../static/js/pluginfw/installer";
|
||||
import axios from "axios";
|
||||
|
||||
const settings = require('./utils/Settings');
|
||||
import settings from './utils/Settings';
|
||||
|
||||
let wtfnode: any;
|
||||
if (settings.dumpOnUncleanExit) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import {Express} from "express";
|
||||
import {MapArrayType} from "./MapType";
|
||||
import {SettingsType} from "../utils/Settings";
|
||||
|
||||
export type ArgsExpressType = {
|
||||
app:Express,
|
||||
io: any,
|
||||
server:any
|
||||
settings: MapArrayType<any>
|
||||
settings: SettingsType
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import {AsyncQueueTask} from "../types/AsyncQueueTask";
|
|||
|
||||
const spawn = require('child_process').spawn;
|
||||
const async = require('async');
|
||||
const settings = require('./Settings');
|
||||
import settings from './Settings';
|
||||
const os = require('os');
|
||||
|
||||
// on windows we have to spawn a process for each convertion,
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const log4js = require('log4js');
|
||||
const path = require('path');
|
||||
const _ = require('underscore');
|
||||
import log4js from 'log4js';
|
||||
import path from 'path';
|
||||
import _ from 'underscore';
|
||||
|
||||
const absPathLogger = log4js.getLogger('AbsolutePaths');
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ const popIfEndsWith = (stringArray: string[], lastDesiredElements: string[]): st
|
|||
* @return {string} The identified absolute base path. If such path cannot be
|
||||
* identified, prints a log and exits the application.
|
||||
*/
|
||||
exports.findEtherpadRoot = () => {
|
||||
export const findEtherpadRoot = () => {
|
||||
if (etherpadRoot != null) {
|
||||
return etherpadRoot;
|
||||
}
|
||||
|
|
@ -130,12 +130,12 @@ exports.findEtherpadRoot = () => {
|
|||
* it is returned unchanged. Otherwise it is interpreted
|
||||
* relative to exports.root.
|
||||
*/
|
||||
exports.makeAbsolute = (somePath: string) => {
|
||||
export const makeAbsolute = (somePath: string) => {
|
||||
if (path.isAbsolute(somePath)) {
|
||||
return somePath;
|
||||
}
|
||||
|
||||
const rewrittenPath = path.join(exports.findEtherpadRoot(), somePath);
|
||||
const rewrittenPath = path.join(findEtherpadRoot(), somePath);
|
||||
|
||||
absPathLogger.debug(`Relative path "${somePath}" can be rewritten to "${rewrittenPath}"`);
|
||||
return rewrittenPath;
|
||||
|
|
@ -149,7 +149,7 @@ exports.makeAbsolute = (somePath: string) => {
|
|||
* a subdirectory of the base one
|
||||
* @return {boolean}
|
||||
*/
|
||||
exports.isSubdir = (parent: string, arbitraryDir: string): boolean => {
|
||||
export const isSubdir = (parent: string, arbitraryDir: string): boolean => {
|
||||
// modified from: https://stackoverflow.com/questions/37521893/determine-if-a-path-is-subdirectory-of-another-in-node-js#45242825
|
||||
const relative = path.relative(parent, arbitraryDir);
|
||||
return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
|
||||
|
|
|
|||
|
|
@ -21,32 +21,33 @@
|
|||
*/
|
||||
|
||||
// An object containing the parsed command-line options
|
||||
exports.argv = {};
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
export const argv: Record<string, string> = {};
|
||||
|
||||
const argvInternal = process.argv.slice(2);
|
||||
let arg, prevArg;
|
||||
|
||||
// Loop through args
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
arg = argv[i];
|
||||
for (let i = 0; i < argvInternal.length; i++) {
|
||||
arg = argvInternal[i];
|
||||
|
||||
// Override location of settings.json file
|
||||
if (prevArg === '--settings' || prevArg === '-s') {
|
||||
exports.argv.settings = arg;
|
||||
if (prevArg && prevArg === '--settings' || prevArg === '-s') {
|
||||
argv.settings = arg;
|
||||
}
|
||||
|
||||
// Override location of credentials.json file
|
||||
if (prevArg === '--credentials') {
|
||||
if (prevArg && prevArg === '--credentials') {
|
||||
exports.argv.credentials = arg;
|
||||
}
|
||||
|
||||
// Override location of settings.json file
|
||||
if (prevArg === '--sessionkey') {
|
||||
if (prevArg && prevArg === '--sessionkey') {
|
||||
exports.argv.sessionkey = arg;
|
||||
}
|
||||
|
||||
// Override location of APIKEY.txt file
|
||||
if (prevArg === '--apikey') {
|
||||
if (prevArg && prevArg === '--apikey') {
|
||||
exports.argv.apikey = arg;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const log4js = require('log4js');
|
|||
const os = require('os');
|
||||
const path = require('path');
|
||||
const runCmd = require('./run_cmd');
|
||||
const settings = require('./Settings');
|
||||
import settings from './Settings';
|
||||
|
||||
const logger = log4js.getLogger('LibreOffice');
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import mime from 'mime-types';
|
|||
import log4js from 'log4js';
|
||||
import {compressCSS, compressJS} from './MinifyWorker'
|
||||
|
||||
const settings = require('./Settings');
|
||||
import settings from './Settings';
|
||||
import {promises as fs} from 'fs';
|
||||
import path from 'node:path';
|
||||
const plugins = require('../../static/js/pluginfw/plugin_defs');
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
import semver from 'semver';
|
||||
const settings = require('./Settings');
|
||||
import settings, {getEpVersion} from './Settings';
|
||||
import axios from 'axios';
|
||||
const headers = {
|
||||
'User-Agent': 'Etherpad/' + settings.getEpVersion(),
|
||||
'User-Agent': 'Etherpad/' + getEpVersion(),
|
||||
}
|
||||
|
||||
type Infos = {
|
||||
|
|
@ -45,7 +45,7 @@ export const getLatestVersion = () => {
|
|||
const needsUpdate = async (cb?: Function) => {
|
||||
try {
|
||||
const info = await loadEtherpadInformations()
|
||||
if (semver.gt(info!.latestVersion, settings.getEpVersion())) {
|
||||
if (semver.gt(info!.latestVersion, getEpVersion())) {
|
||||
if (cb) return cb(true);
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import {ChildProcess} from "node:child_process";
|
|||
import {PromiseWithStd} from "../types/PromiseWithStd";
|
||||
import {Readable} from "node:stream";
|
||||
|
||||
const spawn = require('cross-spawn');
|
||||
const log4js = require('log4js');
|
||||
const path = require('path');
|
||||
const settings = require('./Settings');
|
||||
import spawn from 'cross-spawn';
|
||||
import log4js from 'log4js';
|
||||
import path from 'path';
|
||||
import settings from './Settings';
|
||||
|
||||
const logger = log4js.getLogger('runCmd');
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ module.exports = exports = (args: string[], opts:RunCMDOptions = {}) => {
|
|||
// process's `exit` handler so that we get a useful stack trace.
|
||||
const procFailedErr: Error & ErrorExtended = new Error();
|
||||
|
||||
const proc: ChildProcess = spawn(args[0], args.slice(1), opts);
|
||||
const proc: ChildProcess = spawn(args[0], args.slice(1), opts as any);
|
||||
const streams:[undefined, Readable|null, Readable|null] = [undefined, proc.stdout, proc.stderr];
|
||||
|
||||
let px: { reject: any; resolve: any; };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue