Commit graph

166 commits

Author SHA1 Message Date
SamTV12345
049231e4af
Feature/axios (#5776)
* Move from deprecated request package to axios.

* Fixed package.json

* Another check.

* Fixing npm - hopefully the last.

* Remove double parsing of JSON.

* Bump bundled npm to also get rid of request in the bundled npm.

* Revert "Bump bundled npm to also get rid of request in the bundled npm."

This reverts commit b60fa4f435c141bca332a5b344c36204eb0cc7b4.
2023-06-27 21:20:53 +02:00
Richard Hansen
1513932ca1 plugins: Give each plugin a plugin-specific logger object
This makes it possible for plugins to stop assuming that log4js is
available at `ep_etherpad-lite/node_modules/log4js`.
2022-02-21 15:13:57 -05:00
Richard Hansen
085bc8cbb3 plugins: Don't create .ep_initialized files
These files cause problems with Docker images and read-only
directories/mounts, and they have dubious value (any install-time
setup should instead be done at startup).
2021-11-13 17:43:33 -05:00
Richard Hansen
0aad3b74da pluginfw: Improve rendering of hook list
There are two main benefits:
  * HTML is no longer printed in the startup debug logs.
  * `require()` is no longer called on client-side files. This
    eliminates "Failed to load <file> for <plugin>: ReferenceError:
    window is not defined" errors when users visit
    `/admin/plugins/info`.
2021-03-03 11:19:37 +00:00
Richard Hansen
7e698baa80 pluginfw: Improve hook function load error message 2021-03-03 11:19:37 +00:00
Richard Hansen
6198e92706 tests: Pass --legacy-peer-deps flag to work around npm v7 bug
This flag is unknown to npm v6, but npm v6 silently ignores unknown
flags.
2021-02-22 03:36:12 -05:00
John McLear
ce83181ac3
Lgtm bugfixes (#4838)
* code tidy up: always evaluates

* tidy up: is always true

* tidy up: remove unused code

* always true/false variables

* unused variable

* tidy up: remove unused code in caretPosition.js

* for squash: Revert "tidy up: remove unused code in caretPosition.js"

The `if` condition was previously always true, so the body should be
preserved. If the body is preserved, other logic can be deleted. I
opened PR #4845 to clean it all up.

This reverts commit 75b03e5a7dc1ff9a8728ed2341fd9fe970d0615f.

* for squash: simplify

* for squash: Explain that the getter is used for its side effects

It's very weird to call a getter without using its return value. Add a
comment explaining why this is done so that the reader doesn't get
confused.

* for squash: Revert "tidy up: remove unused code"

The exception test was the purpose of the code.

This reverts commit 85153b167613b2513fff99e22b8ded8ea1e4547b.

* for squash: Log the tsort results

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-02-22 08:26:35 +00:00
webzwo0i
0bb3e65020 fix for caching plugin-definitions 2021-02-21 14:31:15 +00:00
Richard Hansen
b3b5af3c3c plugins: Use npm CLI to install/uninstall plugins
Using npm as a module has long been discouraged and will stop working
with npm v7.
2021-02-18 19:18:59 +00:00
Richard Hansen
1cfbf88f7c run_cmd: Enhance with ability to return stdout as string 2021-02-18 19:18:59 +00:00
Richard Hansen
d8bb5aa009 plugins: Eliminate unnecessary run_npm.js
I had anticipated more shared logic than we actually need (the
abstraction in `run_npm.js` is YAGNI).
2021-02-18 19:18:59 +00:00
Richard Hansen
689a75b381 plugins: Pass --no-production instead of setting NODE_ENV=development 2021-02-18 19:18:59 +00:00
Richard Hansen
dcf7891316 plugins: Improve logging of plugin events
This will make it easier to troubleshoot plugin and npm issues.
2021-02-18 19:18:59 +00:00
Richard Hansen
4253a2ea8f plugins: Move hook call and plugin update out of try block
Exceptions thrown by these function calls are serious and should crash
Etherpad.
2021-02-18 19:18:59 +00:00
Richard Hansen
a8479e4a0e lint: Fix some ESLint errors in pluginfw 2021-02-18 19:18:59 +00:00
Richard Hansen
f868788417 Remove unnecessary path.normalize() calls
`path.join()` already normalizes.
2021-02-18 19:18:59 +00:00
Richard Hansen
fc9f236977 plugins: Use npm ls to list the installed plugins
This speeds up startup considerably, and we get rid of a lot of buggy
code.

This works with both npm v6.x and v7.x.
2021-02-09 22:18:35 +00:00
Richard Hansen
8b28e00784 restructure: Prefix bin/ and tests/ with src/
This is a follow-up to commit
2ea8ea1275.
2021-02-05 21:52:08 +00:00
Richard Hansen
5a865dfc7e pluginfw: Delete unused return value 2021-02-04 08:41:00 +00:00
Richard Hansen
a145b97682 pluginfw: Use for loops to improve readability 2021-02-04 08:41:00 +00:00
Richard Hansen
fdaacc44c8 pluginfw: Replace slide.asyncMap() with Promise.all() 2021-02-04 08:41:00 +00:00
Richard Hansen
746cc8cc34 pluginfw: In-line formatPluginsWithVersion()
There's only one caller of the function, so move the logic to where it
is used.
2021-02-04 08:41:00 +00:00
Richard Hansen
c5f0274116 lint: Move functions up to fix more lint errors 2021-02-04 08:41:00 +00:00
Richard Hansen
99ca57f3ab lint: src/static/js/pluginfw/shared.js 2021-02-04 08:41:00 +00:00
Richard Hansen
2c80c1f2da lint: src/static/js/pluginfw/read-installed.js 2021-02-04 08:41:00 +00:00
Richard Hansen
2b32bc1840 lint: src/static/js/pluginfw/plugins.js 2021-02-04 08:41:00 +00:00
Richard Hansen
9a86ebec2a pluginfw: Fix state reset logic 2021-02-04 08:41:00 +00:00
Richard Hansen
895764e047 pluginfw: Return from findUnmet() early if not given an object
For some reason strings are sometimes passed to `findUnmet()`, which
is obviously unexpected given the way the code is written. Rather than
figure out why strings are passed and how to safely avoid passing
strings, just return early. The net effect is the same, but returning
early avoids setting a property on a string, which is prohibited in
strict mode.
2021-02-04 08:41:00 +00:00
Richard Hansen
a06662fd00 pluginfw: Delete commented-out code 2021-02-04 08:41:00 +00:00
Richard Hansen
c64ee6ff4c pluginfw: Call npm.load() before using npm
This code is only used when testing `read-installed.js` by running it
directly (e.g., `node src/static/js/pluginfw/read-installed.js`).
2021-02-04 08:41:00 +00:00
Richard Hansen
05e0e8dbf7 hooks: New callAllSerial() function
This is necessary to migrate away from `callAll()` (which only
supports synchronous hook functions).
2021-02-02 09:09:02 +00:00
Richard Hansen
763fe6fc26 hooks: Document callFirst() and aCallFirst() 2021-02-02 09:09:02 +00:00
Richard Hansen
6f30ea7c38 hooks: Use callHookFn{Sync,Async}() for {call,aCall}First()
Benefits of `callHookFnSync()` and `callHookFnAsync()`:
  * They are a lot more forgiving than `hookCallWrapper()` was.
  * They perform useful sanity checks.
  * They have extensive unit test coverage.
  * They make the behavior of `callFirst()` and `aCallFirst()` match
    the behavior of `callAll()` and `aCallAll()`.
2021-02-02 09:09:02 +00:00
Richard Hansen
c11d60c5f6 hooks: Check context nullness, not truthiness 2021-02-02 09:09:02 +00:00
Richard Hansen
fd5d3ce777 hooks: Inline aCallFirst() into exports.aCallFirst() 2021-02-02 09:09:02 +00:00
Richard Hansen
77f480d954 hooks: Asyncify aCallFirst 2021-02-02 09:09:02 +00:00
Richard Hansen
22d02dbcbf hooks: Factor out value normalization 2021-02-02 09:09:02 +00:00
Richard Hansen
f316a3bacd hooks: Never pass a falsy error to a callback 2021-02-02 09:09:02 +00:00
Richard Hansen
708206449a hooks: Factor out callback attachment
The separate function will be reused in a future commit.
2021-02-02 09:09:02 +00:00
Richard Hansen
13e806ad7a hooks: Inline mapFirst() into aCallFirst() for readability
There's only one caller of the function, and the function is simple,
so there's no need for a separate function.
2021-02-02 09:09:02 +00:00
Richard Hansen
4ab7a99512 hooks: Inline syncMapFirst() into callFirst() for readability
There's only one caller of the function, and the function is simple,
so there's no need for a separate function.
2021-02-02 09:09:02 +00:00
Richard Hansen
53ccfa8703 hooks: Asyncify mapFirst 2021-02-02 09:09:02 +00:00
Richard Hansen
0b83ff8ec2 hooks: Simplify syncMapFirst iteration 2021-02-02 09:09:02 +00:00
Richard Hansen
c89db33ff0 hooks: Refine caveat comments about function parameter count 2021-02-02 09:09:02 +00:00
Richard Hansen
f02f288e80 hooks: Rename args to context for consistency 2021-02-02 09:09:02 +00:00
Richard Hansen
7dba847f21 hooks: Don't export syncMapFirst or mapFirst
Nobody uses these functions outside of this file.
2021-02-02 09:09:02 +00:00
Richard Hansen
6b42dabf6c hooks: Delete unused bubbleExceptions setting 2021-02-02 09:09:02 +00:00
Richard Hansen
47f0a7dacf lint: Fix more ESLint errors 2021-02-02 09:09:02 +00:00
Richard Hansen
1bc52f4913 hooks: Remove unnecessary callAllStr() function 2021-02-02 09:09:02 +00:00
John McLear
b3dda3b11c lint: src/static/js/pluginfw/*.js 2021-01-30 17:00:40 -05:00