mirror of
				https://github.com/notion-enhancer/notion-enhancer.git
				synced 2025-10-31 14:18:08 +11:00 
			
		
		
		
	require passing resources <path> to apply/remove/check commands
This commit is contained in:
		
							parent
							
								
									9bc15847c4
								
							
						
					
					
						commit
						ae7c2b6212
					
				
							
								
								
									
										21
									
								
								bin.js
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								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 <path>', ': 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 <path>', | ||||
|     ': 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 <path>', ': 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( | ||||
|  | ||||
							
								
								
									
										12
									
								
								pkg/apply.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								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, | ||||
|           })) | ||||
|  | ||||
| @ -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'); | ||||
|  | ||||
| @ -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`); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user