Commit Graph

17 Commits

Author SHA1 Message Date
John McLear 2ea8ea1275 restructure: move bin/ and tests/ to src/
Also add symlinks from the old `bin/` and `tests/` locations to avoid
breaking scripts and other tools.

Motivations:

  * Scripts and tests no longer have to do dubious things like:

        require('ep_etherpad-lite/node_modules/foo')

    to access packages installed as dependencies in
    `src/package.json`.

  * Plugins can access the backend test helper library in a non-hacky
    way:

        require('ep_etherpad-lite/tests/backend/common')

  * We can delete the top-level `package.json` without breaking our
    ability to lint the files in `bin/` and `tests/`.

    Deleting the top-level `package.json` has downsides: It will cause
    `npm` to print warnings whenever plugins are installed, npm will
    no longer be able to enforce a plugin's peer dependency on
    ep_etherpad-lite, and npm will keep deleting the
    `node_modules/ep_etherpad-lite` symlink that points to `../src`.

    But there are significant upsides to deleting the top-level
    `package.json`: It will drastically speed up plugin installation
    because `npm` doesn't have to recursively walk the dependencies in
    `src/package.json`. Also, deleting the top-level `package.json`
    avoids npm's horrible dependency hoisting behavior (where it moves
    stuff from `src/node_modules/` to the top-level `node_modules/`
    directory). Dependency hoisting causes numerous mysterious
    problems such as silent failures in `npm outdated` and `npm
    update`. Dependency hoisting also breaks plugins that do:

        require('ep_etherpad-lite/node_modules/foo')
2021-02-04 17:15:08 -05:00
John McLear efde0b787a
npm-load-remove: checkPad.js example (#4711)
* npm-load-remove: checkPad.js example

* npm-load-remove: checkPad.js example

* npm-load-remove: checkPad.js example

* npm-load-remove: checkPad.js example

* npm-load-remove: checkPad.js example

* npm-load-remove: checkPad.js example

* npm-load-remove: checkPadDeltas

* npm-load-remove: extractPadData

* npm-load-remove: importSqlFile

* npm-load-remove: rebuildPad

* npm-load-remove: repairPad

* npm-load-remove: checkAllPads

* npm-load-remove: migrateDirtyDBtoRealDB

* npm-load-remove: migrateDirtyDBtoRealDB path

* npm-load-remove: migrateDirtyDBtoRealDB dbclose fix

* npm-load-remove: migrateDirtyDBtoRealDB remove commented out line

* npm-load-remove: migrateDirtyDBtoRealDB reintroduce util
2021-02-04 20:53:30 +00:00
Richard Hansen 0ad0160b7c bin/rebuildPad.js: Fix check for existing rev 2021-01-30 07:45:37 +00:00
Richard Hansen 846e3e9fbd bin/rebuildPad.js: Don't overwrite DB settings
There's no need, and setting `json` to true breaks databases that do
their own serialization of ECMAScript objects.
2021-01-30 07:45:37 +00:00
Richard Hansen bf209ddad3 bin/rebuildPad.js: Close the database when done
This prevents loss of data due to unflushed writes.
2021-01-30 07:45:37 +00:00
Richard Hansen 809dc6e367 bin/rebuildPad.js: PadManager must be loaded before Pad
There is a circular dependency between the two; loading PadManager
first ensures that PadManager's Pad variable is not undefined.
2021-01-30 07:45:37 +00:00
Richard Hansen 5b519b9a9c bin/rebuildPad.js: Asyncify 2021-01-30 07:45:37 +00:00
Richard Hansen 72c2abab8d bin/rebuildPad.js: Fix sequencing of asynchronous functions 2021-01-30 07:45:37 +00:00
Richard Hansen 69efd16a6d bin/rebuildPad.js: Add missing calls to `util.callbackify` 2021-01-30 07:45:37 +00:00
John McLear 2fdc737355
bugfix, lint and refactor all bin scripts (#4617)
* bugfix, lint and refactor all bin scripts

* for squash: throw Error(message) rather than log(message); throw Error()

* for squash: Exit non-0 on unhandled Promise rejection

Many of the recent lint changes have converted normal functions to
async functions, and an error thrown in an async function does not
cause Node.js to exit by default.

* for squash: fix `require()` paths

* for squash: remove erroneous `Object.keys()` call

* for squash: fix missing `continue` statements

* for squash: Fix HTTP method for deleteSession

* for squash: delete erroneous throw

Throw is only for errors, not successful completion.

* for squash: redo migrateDirtyDBtoRealDB.js to fix async bugs

* for squash: fix erroneous use of `for..of`

* for squash: Add line break between statements

* for squash: put closing paren on same line as last arg

* for squash: Move `log()` back up where it was

to minimize the diff to develop

* for squash: indentation fixes

* for squash: typo fix

* for squash: wrap long lines

* for squash: use `util.callbackify` to silence promise/no-callback-in-promise warning

* for squash: use double quotes to improve readability

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-01-18 08:53:15 +00:00
Richard Hansen b8d07a42eb lint: Run `eslint --fix` on `bin/` and `tests/` 2020-11-24 20:06:12 +00:00
Richard Hansen 3365e944bf async-ify more functions, and await completion
Where feasible I put the await at the end of the function to
minimize the impact on latency.

My motivation for this change: Eliminate a race condition in tests I
am writing.
2020-09-22 14:10:44 +01:00
brunob edfc7a4916 bin: use correct ueberdb module path "ueberDB" -> "ueberdb2" in tools in /bin
This change is analogous to #2998 (e11decc6f8).
2020-05-15 01:22:41 +02:00
Robin Schneider c9924ee706
Give better error message when rebuildPad.js hits a non-existing rev. 2015-10-07 12:42:19 +02:00
Timothy Chavez c7b1aebfe8 Make changes based on code review
Simplified the cloning process, added validation checks to ensure the
new pad ID is valid and that a pad doesn't already exist with that ID.
Also fixed a bug in the chatHead cloning loop and added the ability to
specify a pad ID on the command the line (defaulting to the original
"-rebuilt" pad ID formula)
2014-12-03 20:11:39 -06:00
Timothy Chavez 25ccb6cfc3 Simplify the rebuild process
The majority of the information needed to build the new pad can be
communicated by simply cloning the rev using a db.set().
2014-11-20 22:09:21 -06:00
Timothy Chavez 01f6d85371 Restore pad to new location at a given revision
This script gives an admin with shell access the ability to restore a
pad at a given revision by essentially rebuilding it at a new location
with data associated with the original pad.  The upsides to creating a
new pad vs. changing the original are: 1) avoiding service disruptions
(no deletes, no moving targets - builds from previous revision); and 2)
preservation of data (no deletes, no overwriting of the source pad).
The most obvious downside is the pad has a new ID which could require
folks to update their links, bookmarks, etc. to point at the new
location.
2014-11-19 13:09:37 -06:00