mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Server starts up.
This commit is contained in:
parent
aa6323e488
commit
798543fb45
14 changed files with 121 additions and 4260 deletions
|
@ -79,32 +79,32 @@ const closeServer = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createServer = async () => {
|
export const createServer = async () => {
|
||||||
console.log('Report bugs at https://github.com/ether/etherpad-lite/issues');
|
logger.info('Report bugs at https://github.com/ether/etherpad-lite/issues');
|
||||||
|
|
||||||
serverName = `Etherpad ${getGitCommit()} (https://etherpad.org)`;
|
serverName = `Etherpad ${getGitCommit()} (https://etherpad.org)`;
|
||||||
|
|
||||||
console.log(`Your Etherpad version is ${getEpVersion()} (${getGitCommit()})`);
|
logger.info(`Your Etherpad version is ${getEpVersion()} (${getGitCommit()})`);
|
||||||
|
|
||||||
await restartServer();
|
await restartServer();
|
||||||
|
|
||||||
if (ip.length===0) {
|
if (ip.length===0) {
|
||||||
// using Unix socket for connectivity
|
// using Unix socket for connectivity
|
||||||
console.log(`You can access your Etherpad instance using the Unix socket at ${port}`);
|
logger.info(`You can access your Etherpad instance using the Unix socket at ${port}`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`You can access your Etherpad instance at http://${ip}:${port}/`);
|
logger.info(`You can access your Etherpad instance at http://${ip}:${port}/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_.isEmpty(users)) {
|
if (!_.isEmpty(users)) {
|
||||||
console.log(`The plugin admin page is at http://${ip}:${port}/admin/plugins`);
|
logger.info(`The plugin admin page is at http://${ip}:${port}/admin/plugins`);
|
||||||
} else {
|
} else {
|
||||||
console.warn('Admin username and password not set in settings.json. ' +
|
logger.info('Admin username and password not set in settings.json. ' +
|
||||||
'To access admin please uncomment and edit "users" in settings.json');
|
'To access admin please uncomment and edit "users" in settings.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
const env = process.env.NODE_ENV || 'development';
|
const env = process.env.NODE_ENV || 'development';
|
||||||
|
|
||||||
if (env !== 'production') {
|
if (env !== 'production') {
|
||||||
console.warn('Etherpad is running in Development mode. This mode is slower for users and ' +
|
logger.warn('Etherpad is running in Development mode. This mode is slower for users and ' +
|
||||||
'less secure than production mode. You should set the NODE_ENV environment ' +
|
'less secure than production mode. You should set the NODE_ENV environment ' +
|
||||||
'variable to production by using: export NODE_ENV=production');
|
'variable to production by using: export NODE_ENV=production');
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,14 @@ import {getPadId, isReadOnlyId} from "../../db/ReadOnlyManager";
|
||||||
import {UserIndexedModel} from "../../models/UserIndexedModel";
|
import {UserIndexedModel} from "../../models/UserIndexedModel";
|
||||||
|
|
||||||
const httpLogger = log4js.getLogger('http');
|
const httpLogger = log4js.getLogger('http');
|
||||||
|
|
||||||
|
import {aCallFirst as hookCall} from "../../../static/js/pluginfw/hooks";
|
||||||
|
|
||||||
deprecationNotices.authFailure = 'use the authnFailure and authzFailure hooks instead';
|
deprecationNotices.authFailure = 'use the authnFailure and authzFailure hooks instead';
|
||||||
|
|
||||||
// Promisified wrapper around hooks.aCallFirst.
|
// Promisified wrapper around hooks.aCallFirst.
|
||||||
const aCallFirst = (hookName, context, pred = null) => new Promise((resolve, reject) => {
|
const aCallFirst = (hookName, context, pred = null) => new Promise((resolve, reject) => {
|
||||||
// FIXME Why are there 4 arguments but only 3 parameters?
|
hookCall(hookName, context, (err, r) => err != null ? reject(err) : resolve(r));
|
||||||
aCallFirst(hookName, context, (err, r) => err != null ? reject(err) : resolve(r));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const aCallFirst0 =
|
const aCallFirst0 =
|
||||||
|
|
|
@ -47,7 +47,7 @@ checkDeprecationStatus('12.17.0', '1.9.0');
|
||||||
|
|
||||||
import db = require('./db/DB');
|
import db = require('./db/DB');
|
||||||
import {} from './db/DB'
|
import {} from './db/DB'
|
||||||
import express = require('./hooks/express');
|
import {createServer, server} from './hooks/express';
|
||||||
import hooks = require('../static/js/pluginfw/hooks');
|
import hooks = require('../static/js/pluginfw/hooks');
|
||||||
import pluginDefs = require('../static/js/pluginfw/plugin_defs');
|
import pluginDefs = require('../static/js/pluginfw/plugin_defs');
|
||||||
import plugins = require('../static/js/pluginfw/plugins');
|
import plugins = require('../static/js/pluginfw/plugins');
|
||||||
|
@ -87,7 +87,7 @@ export const start = async () => {
|
||||||
// Retry. Don't fall through because it might have transitioned to STATE_TRANSITION_FAILED.
|
// Retry. Don't fall through because it might have transitioned to STATE_TRANSITION_FAILED.
|
||||||
return await start();
|
return await start();
|
||||||
case State.RUNNING:
|
case State.RUNNING:
|
||||||
return express.server;
|
return server;
|
||||||
case State.STOPPING:
|
case State.STOPPING:
|
||||||
case State.STOPPED:
|
case State.STOPPED:
|
||||||
case State.EXITING:
|
case State.EXITING:
|
||||||
|
@ -152,7 +152,7 @@ export const start = async () => {
|
||||||
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 hooks.aCallAll('loadSettings', {settings});
|
||||||
await hooks.aCallAll('createServer');
|
await hooks.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;
|
||||||
|
@ -163,9 +163,8 @@ export const start = async () => {
|
||||||
logger.info('Etherpad is running');
|
logger.info('Etherpad is running');
|
||||||
state = State.RUNNING;
|
state = State.RUNNING;
|
||||||
startDoneGate.resolve();
|
startDoneGate.resolve();
|
||||||
|
|
||||||
// Return the HTTP server to make it easier to write tests.
|
// Return the HTTP server to make it easier to write tests.
|
||||||
return express.server;
|
return server;
|
||||||
};
|
};
|
||||||
|
|
||||||
const stopDoneGate = new Gate();
|
const stopDoneGate = new Gate();
|
||||||
|
@ -277,7 +276,7 @@ export const exit = async (err = null) => {
|
||||||
|
|
||||||
logger.info('Waiting for Node.js to exit...');
|
logger.info('Waiting for Node.js to exit...');
|
||||||
state = State.WAITING_FOR_EXIT;
|
state = State.WAITING_FOR_EXIT;
|
||||||
/* eslint-enable no-process-exit */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (require.main === module) start();
|
start()
|
||||||
|
.then(c=>logger.info("Server started"));
|
||||||
|
|
|
@ -24,7 +24,7 @@ import {promises as fs} from "fs";
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
import {exportCMD} from "./run_cmd";
|
import exportCMD from "./run_cmd";
|
||||||
|
|
||||||
import {soffice} from "./Settings";
|
import {soffice} from "./Settings";
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import exp from "constants";
|
import exp from "constants";
|
||||||
|
// FIXME Is there a better way to enter dynamic package.json path
|
||||||
|
// @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';
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import spawn from 'cross-spawn';
|
import spawn from 'cross-spawn';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {root} from "./Settings";
|
import {root} from './Settings';
|
||||||
import {CMDOptions, CMDPromise} from '../models/CMDOptions'
|
import {CustomError} from "./customError";
|
||||||
|
|
||||||
const logger = log4js.getLogger('runCmd');
|
const logger = log4js.getLogger('runCmd');
|
||||||
import {CustomError} from './customError'
|
|
||||||
|
type CMDPromise = {
|
||||||
|
stdout: Promise<string>,
|
||||||
|
stderr: Promise<string>,
|
||||||
|
status: Promise<number>,
|
||||||
|
signal: Promise<string>,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const logLines = (readable, logLineFn) => {
|
const logLines = (readable, logLineFn) => {
|
||||||
readable.setEncoding('utf8');
|
readable.setEncoding('utf8');
|
||||||
// The process won't necessarily write full lines every time -- it might write a part of a line
|
// The process won't necessarily write full lines every time -- it might write a part of a line
|
||||||
|
@ -69,14 +79,23 @@ const logLines = (readable, logLineFn) => {
|
||||||
* - `stderr`: Similar to `stdout` but for stderr.
|
* - `stderr`: Similar to `stdout` but for stderr.
|
||||||
* - `child`: The ChildProcess object.
|
* - `child`: The ChildProcess object.
|
||||||
*/
|
*/
|
||||||
export const exportCMD: (args: string[], opts?:CMDOptions)=>void = async (args, opts = {
|
|
||||||
cwd: undefined,
|
type RunOpts = {
|
||||||
stdio: undefined,
|
cwd?: string;
|
||||||
env: undefined
|
env?: any;
|
||||||
|
stdio?: any;
|
||||||
|
detached?: boolean;
|
||||||
|
uid?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const run_cmd = (args, opts:RunOpts = {
|
||||||
|
stdio: undefined
|
||||||
}) => {
|
}) => {
|
||||||
logger.debug(`Executing command: ${args.join(' ')}`);
|
logger.info(`Executing command: ${args.join(' ')}`);
|
||||||
|
|
||||||
opts = {cwd: root, ...opts};
|
opts = {cwd: root, ...opts};
|
||||||
logger.debug(`cwd: ${opts.cwd}`);
|
logger.info(`cwd: ${opts.cwd}`);
|
||||||
|
|
||||||
// Log stdout and stderr by default.
|
// Log stdout and stderr by default.
|
||||||
const stdio =
|
const stdio =
|
||||||
|
@ -85,24 +104,20 @@ export const exportCMD: (args: string[], opts?:CMDOptions)=>void = async (args,
|
||||||
: opts.stdio === 'string' ? [null, 'string', 'string']
|
: opts.stdio === 'string' ? [null, 'string', 'string']
|
||||||
: Array(3).fill(opts.stdio);
|
: Array(3).fill(opts.stdio);
|
||||||
const cmdLogger = log4js.getLogger(`runCmd|${args[0]}`);
|
const cmdLogger = log4js.getLogger(`runCmd|${args[0]}`);
|
||||||
if (stdio[1] == null && stdio instanceof Array) stdio[1] = (line) => cmdLogger.info(line);
|
if (stdio[1] == null) stdio[1] = (line) => cmdLogger.info(line);
|
||||||
if (stdio[2] == null && stdio instanceof Array) stdio[2] = (line) => cmdLogger.error(line);
|
if (stdio[2] == null) stdio[2] = (line) => cmdLogger.error(line);
|
||||||
const stdioLoggers = [];
|
const stdioLoggers = [];
|
||||||
const stdioSaveString = [];
|
const stdioSaveString = [];
|
||||||
for (const fd of [1, 2]) {
|
for (const fd of [1, 2]) {
|
||||||
if (typeof stdio[fd] === 'function') {
|
if (typeof stdio[fd] === 'function') {
|
||||||
stdioLoggers[fd] = stdio[fd];
|
stdioLoggers[fd] = stdio[fd];
|
||||||
if (stdio instanceof Array)
|
stdio[fd] = 'pipe';
|
||||||
stdio[fd] = 'pipe';
|
|
||||||
} else if (stdio[fd] === 'string') {
|
} else if (stdio[fd] === 'string') {
|
||||||
stdioSaveString[fd] = true;
|
stdioSaveString[fd] = true;
|
||||||
if (stdio instanceof Array)
|
stdio[fd] = 'pipe';
|
||||||
stdio[fd] = 'pipe';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opts.stdio instanceof Array) {
|
opts.stdio = stdio;
|
||||||
opts.stdio = stdio;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On Windows the PATH environment var might be spelled "Path".
|
// On Windows the PATH environment var might be spelled "Path".
|
||||||
const pathVarName =
|
const pathVarName =
|
||||||
|
@ -123,15 +138,13 @@ export const exportCMD: (args: string[], opts?:CMDOptions)=>void = async (args,
|
||||||
|
|
||||||
// Create an error object to use in case the process fails. This is done here rather than in the
|
// Create an error object to use in case the process fails. This is done here rather than in the
|
||||||
// process's `exit` handler so that we get a useful stack trace.
|
// process's `exit` handler so that we get a useful stack trace.
|
||||||
const procFailedErr:CustomError = new CustomError({});
|
const procFailedErr = new CustomError({});
|
||||||
|
|
||||||
const proc = spawn(args[0], args.slice(1), opts);
|
const proc = spawn(args[0], args.slice(1), opts);
|
||||||
const streams = [undefined, proc.stdout, proc.stderr];
|
const streams = [undefined, proc.stdout, proc.stderr];
|
||||||
|
|
||||||
let px;
|
let px;
|
||||||
const p = await new Promise<CMDPromise>((resolve, reject) => {
|
const p = new Promise<string>((resolve, reject) => { px = {resolve, reject}; });
|
||||||
px = {resolve, reject};
|
|
||||||
});
|
|
||||||
[, p.stdout, p.stderr] = streams;
|
[, p.stdout, p.stderr] = streams;
|
||||||
p.child = proc;
|
p.child = proc;
|
||||||
|
|
||||||
|
@ -141,7 +154,6 @@ export const exportCMD: (args: string[], opts?:CMDOptions)=>void = async (args,
|
||||||
if (stdioLoggers[fd] != null) {
|
if (stdioLoggers[fd] != null) {
|
||||||
logLines(streams[fd], stdioLoggers[fd]);
|
logLines(streams[fd], stdioLoggers[fd]);
|
||||||
} else if (stdioSaveString[fd]) {
|
} else if (stdioSaveString[fd]) {
|
||||||
//FIXME How to solve this?
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
p[[null, 'stdout', 'stderr'][fd]] = stdioStringPromises[fd] = (async () => {
|
p[[null, 'stdout', 'stderr'][fd]] = stdioStringPromises[fd] = (async () => {
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
|
@ -166,3 +178,4 @@ export const exportCMD: (args: string[], opts?:CMDOptions)=>void = async (args,
|
||||||
});
|
});
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
export default run_cmd;
|
||||||
|
|
4249
src/package-lock.json
generated
4249
src/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -53,7 +53,6 @@
|
||||||
"log4js": "^6.9.1",
|
"log4js": "^6.9.1",
|
||||||
"measured-core": "^2.0.0",
|
"measured-core": "^2.0.0",
|
||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
"npm": "^6.14.15",
|
|
||||||
"openapi-backend": "^5.9.2",
|
"openapi-backend": "^5.9.2",
|
||||||
"proxy-addr": "^2.0.7",
|
"proxy-addr": "^2.0.7",
|
||||||
"rate-limiter-flexible": "^2.4.1",
|
"rate-limiter-flexible": "^2.4.1",
|
||||||
|
@ -79,9 +78,12 @@
|
||||||
"etherpad-lite": "node/server.js"
|
"etherpad-lite": "node/server.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/cross-spawn": "^6.0.2",
|
||||||
"@types/express": "4.17.17",
|
"@types/express": "4.17.17",
|
||||||
"@types/jquery": "^3.5.16",
|
"@types/jquery": "^3.5.16",
|
||||||
"@types/js-cookie": "^3.0.3",
|
"@types/js-cookie": "^3.0.3",
|
||||||
|
"i18next": "^23.2.3",
|
||||||
|
"i18next-fs-backend": "^2.1.5",
|
||||||
"@types/node": "^20.3.1",
|
"@types/node": "^20.3.1",
|
||||||
"@types/underscore": "^1.11.5",
|
"@types/underscore": "^1.11.5",
|
||||||
"concurrently": "^8.2.0",
|
"concurrently": "^8.2.0",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import * as pluginUtils from "./shared.js";
|
import * as pluginUtils from "./shared.js";
|
||||||
import * as defs from "./plugin_defs.js";
|
import * as defs from "./plugin_defs.js";
|
||||||
|
import {getLogger} from "log4js";
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const adoptPluginsFromAncestorsOf = (frame) => {
|
const adoptPluginsFromAncestorsOf = (frame) => {
|
||||||
|
@ -37,9 +38,12 @@ export const update = (cb) => {
|
||||||
// of execution on Firefox. This schedules the response in the run-loop,
|
// of execution on Firefox. This schedules the response in the run-loop,
|
||||||
// which appears to fix the issue.
|
// which appears to fix the issue.
|
||||||
const callback = () => setTimeout(cb, 0);
|
const callback = () => setTimeout(cb, 0);
|
||||||
jQuery.getJSON(`${exports.baseURL}pluginfw/plugin-definitions.json?v=${clientVars.randomVersionString}`).done((data) => {
|
jQuery.getJSON(`${exports.baseURL}pluginfw/plugin-definitions.json?v=${clientVars.randomVersionString}`)
|
||||||
|
.done((data) => {
|
||||||
defs.plugins = data.plugins;
|
defs.plugins = data.plugins;
|
||||||
defs.parts = data.parts;
|
defs.parts = data.parts;
|
||||||
|
const logger = getLogger("client_plugins")
|
||||||
|
logger.info(data.parts)
|
||||||
defs.hooks = pluginUtils.extractHooks(defs.parts, 'client_hooks');
|
defs.hooks = pluginUtils.extractHooks(defs.parts, 'client_hooks');
|
||||||
defs.loaded = true;
|
defs.loaded = true;
|
||||||
callback();
|
callback();
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {aCallAll} from "./hooks";
|
||||||
|
|
||||||
import request from "request";
|
import request from "request";
|
||||||
|
|
||||||
import {exportCMD} from "../../../node/utils/run_cmd";
|
import exportCMD from "../../../node/utils/run_cmd";
|
||||||
|
|
||||||
import {reloadSettings} from "../../../node/utils/Settings";
|
import {reloadSettings} from "../../../node/utils/Settings";
|
||||||
import {InstallerModel} from "../../module/InstallerModel";
|
import {InstallerModel} from "../../module/InstallerModel";
|
||||||
|
|
|
@ -25,7 +25,7 @@ export let parts = [];
|
||||||
// - version
|
// - version
|
||||||
// - path
|
// - path
|
||||||
// - realPath
|
// - realPath
|
||||||
export const plugins = {};
|
export let plugins = {};
|
||||||
|
|
||||||
export const setPlugins = (newPlugins) => {
|
export const setPlugins = (newPlugins) => {
|
||||||
Object.assign(plugins, newPlugins);
|
Object.assign(plugins, newPlugins);
|
||||||
|
|
|
@ -8,13 +8,13 @@ import log4js from "log4js";
|
||||||
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
import {exportCMD} from "../../../node/utils/run_cmd";
|
import exportCMD from "../../../node/utils/run_cmd";
|
||||||
|
|
||||||
import {tsort} from "./tsort";
|
import tsort from "./tsort";
|
||||||
|
|
||||||
import {extractHooks} from "./shared";
|
import {extractHooks} from "./shared";
|
||||||
|
|
||||||
import {loaded, parts, plugins, setHooks, setLoaded, setParts, setPlugins} from "./plugin_defs";
|
import {parts, plugins, setHooks, setLoaded, setParts, setPlugins} from "./plugin_defs";
|
||||||
import {PluginInfo} from "../../module/PluginInfo";
|
import {PluginInfo} from "../../module/PluginInfo";
|
||||||
|
|
||||||
const logger = log4js.getLogger('plugins');
|
const logger = log4js.getLogger('plugins');
|
||||||
|
@ -95,8 +95,8 @@ export const pathNormalization = (part, hookFnName, hookName) => {
|
||||||
|
|
||||||
export const update = async () => {
|
export const update = async () => {
|
||||||
const packages = await getPackages();
|
const packages = await getPackages();
|
||||||
let parts:{[keys: string]:any} = {}; // Key is full name. sortParts converts this into a topologically sorted array.
|
let parts = []; // Key is full name. sortParts converts this into a topologically sorted array.
|
||||||
let plugins = {};
|
let plugins = {}
|
||||||
|
|
||||||
// Load plugin metadata ep.json
|
// Load plugin metadata ep.json
|
||||||
await Promise.all(Object.keys(packages).map(async (pluginName) => {
|
await Promise.all(Object.keys(packages).map(async (pluginName) => {
|
||||||
|
@ -105,6 +105,7 @@ export const update = async () => {
|
||||||
}));
|
}));
|
||||||
logger.info(`Loaded ${Object.keys(packages).length} plugins`);
|
logger.info(`Loaded ${Object.keys(packages).length} plugins`);
|
||||||
|
|
||||||
|
logger.info(parts)
|
||||||
setPlugins(plugins);
|
setPlugins(plugins);
|
||||||
setParts(sortParts(parts))
|
setParts(sortParts(parts))
|
||||||
setHooks(extractHooks(parts, 'hooks', pathNormalization));
|
setHooks(extractHooks(parts, 'hooks', pathNormalization));
|
||||||
|
@ -123,7 +124,10 @@ const getPackages = async () => {
|
||||||
// unset or set to `development`) because otherwise `npm ls` will not mention any packages
|
// unset or set to `development`) because otherwise `npm ls` will not mention any packages
|
||||||
// that are not included in `package.json` (which is expected to not exist).
|
// that are not included in `package.json` (which is expected to not exist).
|
||||||
const cmd = ['npm', 'ls', '--long', '--json', '--depth=0', '--no-production'];
|
const cmd = ['npm', 'ls', '--long', '--json', '--depth=0', '--no-production'];
|
||||||
const {dependencies = {}} = JSON.parse(await exportCMD(cmd, {stdio: [null, 'string']}) as unknown as string);
|
logger.info("Before exportCMD")
|
||||||
|
const cmdReturn = await exportCMD(cmd, {stdio: [null, 'string']})
|
||||||
|
logger.info("After exportCMD")
|
||||||
|
const {dependencies = {}} = JSON.parse(cmdReturn as string);
|
||||||
await Promise.all(Object.entries(dependencies).map(async ([pkg, info]) => {
|
await Promise.all(Object.entries(dependencies).map(async ([pkg, info]) => {
|
||||||
if (!pkg.startsWith(prefix)) {
|
if (!pkg.startsWith(prefix)) {
|
||||||
delete dependencies[pkg];
|
delete dependencies[pkg];
|
||||||
|
|
|
@ -33,7 +33,7 @@ export const loadFn = (path, hookName) => {
|
||||||
return fn;
|
return fn;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const extractHooks = (parts, hookSetName, normalizer) => {
|
export const extractHooks = (parts: any[], hookSetName, normalizer) => {
|
||||||
const hooks = {};
|
const hooks = {};
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
for (const [hookName, regHookFnName] of Object.entries(part[hookSetName] || {})) {
|
for (const [hookName, regHookFnName] of Object.entries(part[hookSetName] || {})) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ export const tsort = (edges: (string|number)[][]) => {
|
||||||
Object.keys(nodes).forEach(visit);
|
Object.keys(nodes).forEach(visit);
|
||||||
|
|
||||||
return sorted;
|
return sorted;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TEST
|
* TEST
|
||||||
|
@ -111,3 +111,5 @@ if (typeof exports === 'object' && exports === this) {
|
||||||
module.exports = tsort;
|
module.exports = tsort;
|
||||||
if (process.argv[1] === __filename) tsortTest();
|
if (process.argv[1] === __filename) tsortTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default tsort;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue