Commit graph

148 commits

Author SHA1 Message Date
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
Richard Hansen
c1ef12b8da lint: Re-run eslint --fix 2021-01-29 01:14:03 -05:00
Hossein Marzban
34ee77993f
Lint: pluginfw tsort.js (#4576)
* lint: pluginfw tsort.js

* Don't comment out the `console.log()` call

Disabling the log message is out of scope for the pull request.

* Put const and let on separate lines

* Convert `tsort` from function to arrow function

ESLint doesn't complain about this due to a bug in
prefer-arrow/prefer-arrow-functions rule:
https://github.com/TristonJ/eslint-plugin-prefer-arrow/issues/24

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-20 06:18:49 +00:00
Richard Hansen
f54dcbc766 lint: Re-run eslint --fix 2020-12-16 22:09:48 +00:00
Hossein Marzban
6f309ac20a
lint: pluginfw/client_plugins (#4572) 2020-12-15 21:40:41 -05:00
webzwo0i
d25010d5d7
pluginfw: explicitly install the latest version of a plugin, fix for #4536 (#4543) 2020-12-05 14:08:02 +00:00
Richard Hansen
8e5fd19db2 lint: Run eslint --fix on src/ 2020-11-24 20:06:12 +00:00
Richard Hansen
cedd27e4fe plugins: Default the module name to the plugin name 2020-11-13 20:30:27 +00:00
Richard Hansen
afb025030c plugins: Use a log4js logger for npm messages 2020-11-13 20:30:27 +00:00
Richard Hansen
8a918fbc46 plugins: asyncify more functions 2020-11-13 20:30:27 +00:00
Richard Hansen
9f575ebc84 plugins: Delete unused ensure function 2020-11-13 20:30:27 +00:00
Richard Hansen
ac5614dadd plugins: Don't export callInit
It's unused outside of this module.

Also use an arrow function.
2020-11-13 20:30:27 +00:00
Richard Hansen
ba4794cf8a plugins: Call require('./hooks') at top level 2020-11-13 20:30:27 +00:00
Richard Hansen
14a9479e69 plugins: Use functions from fs.promises 2020-11-13 20:30:27 +00:00
Richard Hansen
d624aa936e plugins: Fix plugin name in error messages 2020-11-13 20:30:27 +00:00
Richard Hansen
36aceb3aba hooks: Rewrite callAll and aCallAll for consistency
Rewrite the `callAll` and `aCallAll` functions to support all
reasonable hook behaviors and to report errors for unreasonable
behaviors (e.g., calling the callback twice).

Now a hook function like the following works as expected when invoked
by `aCallAll`:

```
exports.myHookFn = (hookName, context, cb) => {
  cb('some value');
  return;
};
```
2020-10-24 16:08:50 +01:00
Richard Hansen
55939a0d7e hooks: Delete unused flatten function 2020-10-24 16:08:50 +01:00
Richard Hansen
a4927095ae CSP: Disable the indexCustomInlineScripts hook 2020-10-11 20:31:00 +01:00
Richard Hansen
052fbb944f
plugins: Delete noisy and useless debug message (#4409)
The debug statement mostly printed the following useless message over
and over, causing Travis CI logs to become truncated:

    [DEBUG] pluginfw - [ undefined ] returning
2020-10-11 09:51:53 +01:00