From efde0b787a82829ba382c337839dc78fb4562555 Mon Sep 17 00:00:00 2001 From: John McLear Date: Thu, 4 Feb 2021 20:53:30 +0000 Subject: [PATCH] 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 --- bin/checkAllPads.js | 5 ----- bin/checkPad.js | 5 ----- bin/checkPadDeltas.js | 4 ---- bin/extractPadData.js | 5 ----- bin/importSqlFile.js | 5 ----- bin/migrateDirtyDBtoRealDB.js | 10 ++-------- bin/rebuildPad.js | 5 ----- bin/repairPad.js | 5 ----- 8 files changed, 2 insertions(+), 42 deletions(-) diff --git a/bin/checkAllPads.js b/bin/checkAllPads.js index 356112e5..7f8a7140 100644 --- a/bin/checkAllPads.js +++ b/bin/checkAllPads.js @@ -7,14 +7,9 @@ // unhandled rejection into an uncaught exception, which does cause Node.js to exit. process.on('unhandledRejection', (err) => { throw err; }); -const npm = require('ep_etherpad-lite/node_modules/npm'); -const util = require('util'); - if (process.argv.length !== 2) throw new Error('Use: node bin/checkAllPads.js'); (async () => { - await util.promisify(npm.load)({}); - // initialize the database require('ep_etherpad-lite/node/utils/Settings'); const db = require('ep_etherpad-lite/node/db/DB'); diff --git a/bin/checkPad.js b/bin/checkPad.js index 20b3fa22..53a3e10d 100644 --- a/bin/checkPad.js +++ b/bin/checkPad.js @@ -7,9 +7,6 @@ // unhandled rejection into an uncaught exception, which does cause Node.js to exit. process.on('unhandledRejection', (err) => { throw err; }); -const npm = require('ep_etherpad-lite/node_modules/npm'); -const util = require('util'); - if (process.argv.length !== 3) throw new Error('Use: node bin/checkPad.js $PADID'); // get the padID @@ -17,8 +14,6 @@ const padId = process.argv[2]; let checkRevisionCount = 0; (async () => { - await util.promisify(npm.load)({}); - // initialize database require('ep_etherpad-lite/node/utils/Settings'); const db = require('ep_etherpad-lite/node/db/DB'); diff --git a/bin/checkPadDeltas.js b/bin/checkPadDeltas.js index 4900595c..67cc8f15 100644 --- a/bin/checkPadDeltas.js +++ b/bin/checkPadDeltas.js @@ -14,12 +14,8 @@ const padId = process.argv[2]; const expect = require('../tests/frontend/lib/expect'); const diff = require('ep_etherpad-lite/node_modules/diff'); -const npm = require('ep_etherpad-lite/node_modules/npm'); -const util = require('util'); (async () => { - await util.promisify(npm.load)({}); - // initialize database require('ep_etherpad-lite/node/utils/Settings'); const db = require('ep_etherpad-lite/node/db/DB'); diff --git a/bin/extractPadData.js b/bin/extractPadData.js index 181a8c6b..dc413a9a 100644 --- a/bin/extractPadData.js +++ b/bin/extractPadData.js @@ -15,12 +15,7 @@ if (process.argv.length !== 3) throw new Error('Use: node extractPadData.js $PAD // get the padID const padId = process.argv[2]; -const npm = require('ep_etherpad-lite/node_modules/npm'); -const util = require('util'); - (async () => { - await util.promisify(npm.load)({}); - // initialize database require('ep_etherpad-lite/node/utils/Settings'); const db = require('ep_etherpad-lite/node/db/DB'); diff --git a/bin/importSqlFile.js b/bin/importSqlFile.js index 5927d82c..2ba450a7 100644 --- a/bin/importSqlFile.js +++ b/bin/importSqlFile.js @@ -4,9 +4,6 @@ // unhandled rejection into an uncaught exception, which does cause Node.js to exit. process.on('unhandledRejection', (err) => { throw err; }); -const npm = require('ep_etherpad-lite/node_modules/npm'); -const util = require('util'); - const startTime = Date.now(); const log = (str) => { @@ -47,8 +44,6 @@ const unescape = (val) => { }; (async () => { - await util.promisify(npm.load)({}); - const fs = require('fs'); const ueberDB = require('ep_etherpad-lite/node_modules/ueberdb2'); const settings = require('ep_etherpad-lite/node/utils/Settings'); diff --git a/bin/migrateDirtyDBtoRealDB.js b/bin/migrateDirtyDBtoRealDB.js index c79d9b74..bbf34cdd 100644 --- a/bin/migrateDirtyDBtoRealDB.js +++ b/bin/migrateDirtyDBtoRealDB.js @@ -4,14 +4,7 @@ // unhandled rejection into an uncaught exception, which does cause Node.js to exit. process.on('unhandledRejection', (err) => { throw err; }); -const npm = require('ep_etherpad-lite/node_modules/npm'); -const util = require('util'); - (async () => { - await util.promisify(npm.load)({}); - - process.chdir(`${npm.root}/..`); - // This script requires that you have modified your settings.json file // to work with a real database. Please make a backup of your dirty.db // file before using this script, just to be safe. @@ -20,6 +13,7 @@ const util = require('util'); // `node --max-old-space-size=4096 bin/migrateDirtyDBtoRealDB.js` + const util = require('util'); const settings = require('ep_etherpad-lite/node/utils/Settings'); const dirtyDb = require('ep_etherpad-lite/node_modules/dirty'); const ueberDB = require('ep_etherpad-lite/node_modules/ueberdb2'); @@ -36,7 +30,7 @@ const util = require('util'); await db.init(); console.log('Waiting for dirtyDB to parse its file.'); - const dirty = dirtyDb('var/dirty.db'); + const dirty = dirtyDb(`${__dirname}/../var/dirty.db`); const length = await new Promise((resolve) => { dirty.once('load', resolve); }); console.log(`Found ${length} records, processing now.`); diff --git a/bin/rebuildPad.js b/bin/rebuildPad.js index 1bc942fe..a8daf728 100644 --- a/bin/rebuildPad.js +++ b/bin/rebuildPad.js @@ -13,16 +13,11 @@ if (process.argv.length !== 4 && process.argv.length !== 5) { throw new Error('Use: node bin/repairPad.js $PADID $REV [$NEWPADID]'); } -const npm = require('ep_etherpad-lite/node_modules/npm'); -const util = require('util'); - const padId = process.argv[2]; const newRevHead = process.argv[3]; const newPadId = process.argv[4] || `${padId}-rebuilt`; (async () => { - await util.promisify(npm.load)({}); - const db = require('ep_etherpad-lite/node/db/DB'); await db.init(); diff --git a/bin/repairPad.js b/bin/repairPad.js index ce0c6072..aef9102a 100644 --- a/bin/repairPad.js +++ b/bin/repairPad.js @@ -17,12 +17,7 @@ const padId = process.argv[2]; let valueCount = 0; -const npm = require('ep_etherpad-lite/node_modules/npm'); -const util = require('util'); - (async () => { - await util.promisify(npm.load)({}); - // initialize database require('ep_etherpad-lite/node/utils/Settings'); const db = require('ep_etherpad-lite/node/db/DB');