mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-07-22 01:28:52 +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
|
|
@ -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