diff --git a/bin.js b/bin.js index 1242a91..b413040 100755 --- a/bin.js +++ b/bin.js @@ -24,30 +24,37 @@ cli.option('-n, --no', ': skip prompts (may cause failures)'); cli.option('-d, --dev', ': show detailed error messages (for debug purposes)'); cli - .command('apply', ': add the enhancer to the notion app') - .action(async (options) => { + .command('apply ', ': add the enhancer to the notion app') + .action(async (path, options) => { console.info('=== NOTION ENHANCEMENT LOG ==='); await require('./pkg/apply.js')({ + __notion: path, overwrite_version: options.yes ? 'y' : options.no ? 'n' : undefined, friendly_errors: !options.dev, }); console.info('=== END OF LOG ==='); }); cli - .command('remove', ': return notion to its pre-enhanced/pre-modded state') - .action(async (options) => { + .command( + 'remove ', + ': return notion to its pre-enhanced/pre-modded state' + ) + .action(async (path, options) => { console.info('=== NOTION RESTORATION LOG ==='); await require('./pkg/remove.js')({ + __notion: path, delete_data: options.yes ? 'y' : options.no ? 'n' : undefined, friendly_errors: !options.dev, }); console.info('=== END OF LOG ==='); }); cli - .command('check', ': check the current state of the notion app') - .action(async (options) => { + .command('check ', ': check the current state of the notion app') + .action(async (path, options) => { try { - const status = await require('./pkg/check.js')(); + const status = await require('./pkg/check.js')({ + __notion: path, + }); console.info(options.dev ? status : status.msg); } catch (err) { console.error( diff --git a/pkg/apply.js b/pkg/apply.js index 7147563..24ecfa3 100644 --- a/pkg/apply.js +++ b/pkg/apply.js @@ -10,7 +10,7 @@ const fs = require('fs-extra'), path = require('path'), { readdirIterator } = require('readdir-enhanced'), { extractAll } = require('asar'), - { readline, getNotionResources } = require('./helpers.js'), + { readline } = require('./helpers.js'), { version } = require('../package.json'); // === title === @@ -21,11 +21,14 @@ const fs = require('fs-extra'), // ~~ exit // ### error ### -module.exports = async function ({ overwrite_version, friendly_errors } = {}) { - const __notion = getNotionResources(); +module.exports = async function ({ + __notion, + overwrite_version, + friendly_errors, +} = {}) { try { // handle pre-existing installations: app.asar present? version set in data folder? overwrite? - const check_app = await require('./check.js')(); + const check_app = await require('./check.js')({ __notion }); switch (check_app.code) { case 1: throw Error(check_app.msg); @@ -55,6 +58,7 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) { ); if ( !(await require('./remove.js')({ + __notion, delete_data: 'n', friendly_errors, })) diff --git a/pkg/check.js b/pkg/check.js index 6a19fde..3a029a4 100644 --- a/pkg/check.js +++ b/pkg/check.js @@ -8,12 +8,10 @@ const fs = require('fs-extra'), path = require('path'), - { getNotionResources } = require('./helpers.js'), { version } = require('../package.json'); -module.exports = async function () { - const __notion = getNotionResources(), - resolvePath = (filepath) => path.resolve(`${__notion}/${filepath}`), +module.exports = async function ({ __notion }) { + const resolvePath = (filepath) => path.resolve(`${__notion}/${filepath}`), pathExists = (filepath) => fs.pathExists(resolvePath(filepath)), version_path = 'app/ENHANCER_VERSION.txt', packed = await pathExists('app.asar.bak'); diff --git a/pkg/remove.js b/pkg/remove.js index b6e301c..b31904b 100644 --- a/pkg/remove.js +++ b/pkg/remove.js @@ -8,7 +8,7 @@ const fs = require('fs-extra'), path = require('path'), - { readline, getNotionResources, __data } = require('./helpers.js'); + { readline, __data } = require('./helpers.js'); // === title === // ...information @@ -18,10 +18,13 @@ const fs = require('fs-extra'), // ~~ exit // ### error ### -module.exports = async function ({ delete_data, friendly_errors } = {}) { +module.exports = async function ({ + __notion, + delete_data, + friendly_errors, +} = {}) { try { - const __notion = getNotionResources(), - check_app = await require('./check.js')(); + const check_app = await require('./check.js')({ __notion }); // extracted asar: modded if (check_app.code > 1 && check_app.executable) { console.info(` ...removing enhancements`);