mirror of
				https://github.com/notion-enhancer/notion-enhancer.git
				synced 2025-10-31 22:28:08 +11:00 
			
		
		
		
	better erroring (#56), menu tweaking, gallery fullpage variable fix
This commit is contained in:
		
							parent
							
								
									ab7771cba9
								
							
						
					
					
						commit
						017cb66564
					
				| @ -34,7 +34,10 @@ otherwise: | ||||
| 
 | ||||
| the enhancements should be automatically applied on installation | ||||
| and automatically removed on uninstallation. | ||||
| if you want to do things yourself, though, you can. | ||||
| 
 | ||||
| on some platforms this may throw errors if done without | ||||
| elevated/admin permissions, though, so if it hasn't automatically | ||||
| installed you will still need to use these commands. | ||||
| 
 | ||||
| ``` | ||||
| Usage: | ||||
| @ -52,6 +55,7 @@ For more info, run any command with the `--help` flag: | ||||
| 
 | ||||
| Options: | ||||
|   -y, --yes      : skip prompts (may overwrite data) | ||||
|   -d, --dev      : show detailed error messages (not recommended) | ||||
|   -h, --help     : display usage information | ||||
|   -v, --version  : display version number | ||||
| ``` | ||||
| @ -231,7 +235,7 @@ these include: | ||||
| 
 | ||||
| **author:** [alexander-kazakov](https://github.com/alexander-kazakov/) | ||||
| 
 | ||||
| **version:** v0.2.1 | ||||
| **version:** v0.2.2 | ||||
| 
 | ||||
| ### right-to-left | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										19
									
								
								bin.js
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								bin.js
									
									
									
									
									
								
							| @ -20,26 +20,27 @@ const cli = require('cac')('notion-enhancer'), | ||||
| // ### error ###
 | ||||
| 
 | ||||
| cli.option('-y, --yes', ': skip prompts (may overwrite data)'); | ||||
| cli.option('-d, --dev', ': show detailed error messages'); | ||||
| 
 | ||||
| cli | ||||
|   .command('apply', ': add the enhancer to the notion app') | ||||
|   .action(async (options) => { | ||||
|     console.info('=== NOTION ENHANCEMENT LOG ==='); | ||||
|     await require('./pkg/apply.js')(); | ||||
|     await require('./pkg/apply.js')({ | ||||
|       overwrite_version: options.yes, | ||||
|       friendly_errors: !options.dev, | ||||
|     }); | ||||
|     console.info('=== END OF LOG ==='); | ||||
|   }); | ||||
| cli | ||||
|   .command('remove', ': return notion to its pre-enhanced/pre-modded state') | ||||
|   .action(async (options) => { | ||||
|     console.info('=== NOTION RESTORATION LOG ==='); | ||||
|     await require('./pkg/remove.js')( | ||||
|       options.yes | ||||
|         ? { | ||||
|             overwrite_asar: true, | ||||
|             delete_data: true, | ||||
|           } | ||||
|         : {} | ||||
|     ); | ||||
|     await require('./pkg/remove.js')({ | ||||
|       overwrite_asar: options.yes, | ||||
|       delete_data: options.yes, | ||||
|       friendly_errors: !options.dev, | ||||
|     }); | ||||
|     console.info('=== END OF LOG ==='); | ||||
|   }); | ||||
| cli | ||||
|  | ||||
| @ -46,7 +46,6 @@ | ||||
|   background: var(--theme--card) !important; | ||||
| } | ||||
| .dark | ||||
|   .notion-page-content | ||||
|   .notion-page-block.notion-collection-item | ||||
|   [style*='background: rgba(255, 255, 255, 0.05)'] { | ||||
|   background: var(--theme--gallery) !important; | ||||
|  | ||||
| @ -56,7 +56,6 @@ | ||||
|   background: var(--theme--card) !important; | ||||
| } | ||||
| .notion-body:not(.dark) | ||||
|   .notion-page-content | ||||
|   .notion-page-block.notion-collection-item | ||||
|   [style*='background: rgba(55, 53, 47, 0.024)'] { | ||||
|   background: var(--theme--gallery) !important; | ||||
|  | ||||
| @ -158,6 +158,11 @@ s { | ||||
|   background: var(--theme--bg_green); | ||||
| } | ||||
| 
 | ||||
| #alerts code { | ||||
|   background: transparent; | ||||
|   text-decoration: underline; | ||||
| } | ||||
| 
 | ||||
| [data-relaunch] { | ||||
|   text-decoration: underline dotted; | ||||
|   cursor: pointer; | ||||
|  | ||||
| @ -107,9 +107,7 @@ window['__start'] = async () => { | ||||
|         'warning', | ||||
|         version.sorted[0] == version.local | ||||
|           ? `update <b>v${version.repo}</b> available!<br>
 | ||||
|              run <code>npm i -g notion-enhancer</code><br> | ||||
|              (or <code>yarn global add notion-enhancer</code>),<br> | ||||
|              <u>and</u> <code>notion-enhancer apply</code>.` | ||||
|              run <code>npm i -g notion-enhancer</code>` | ||||
|           : `local build <b>v${raw_v}</b> is unstable.` | ||||
|       ).prepend(); | ||||
|     }); | ||||
|  | ||||
| @ -12,7 +12,7 @@ module.exports = { | ||||
|   tags: ['extension'], | ||||
|   name: 'property layout', | ||||
|   desc: 'auto-collapse page properties that usually push down page content.', | ||||
|   version: '0.2.1', | ||||
|   version: '0.2.2', | ||||
|   author: 'alexander-kazakov', | ||||
|   hacks: { | ||||
|     'renderer/preload.js'(store, __exports) { | ||||
|  | ||||
							
								
								
									
										10
									
								
								pkg/apply.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								pkg/apply.js
									
									
									
									
									
								
							| @ -22,7 +22,7 @@ const fs = require('fs-extra'), | ||||
| // ### error ###
 | ||||
| 
 | ||||
| let __notion = helpers.getNotion(); | ||||
| module.exports = async function ({ overwrite_version } = {}) { | ||||
| module.exports = async function ({ overwrite_version, friendly_errors } = {}) { | ||||
|   try { | ||||
|     await fs.ensureDir(helpers.data_folder); | ||||
| 
 | ||||
| @ -114,7 +114,13 @@ module.exports = async function ({ overwrite_version } = {}) { | ||||
|     return true; | ||||
|   } catch (err) { | ||||
|     console.error('### ERROR ###'); | ||||
|     console.error(err); | ||||
|     if (err.toString().includes('EACCESS') && friendly_errors) { | ||||
|       console.error( | ||||
|         'file access forbidden: try again with sudo or in an elevated/admin prompt.' | ||||
|       ); | ||||
|     } else if (err.toString().includes('EIO') && friendly_errors) { | ||||
|       console.error('file access failed: is notion running?'); | ||||
|     } else console.error(err); | ||||
|     return false; | ||||
|   } | ||||
| }; | ||||
|  | ||||
| @ -19,7 +19,11 @@ const fs = require('fs-extra'), | ||||
| // ### error ###
 | ||||
| 
 | ||||
| let __notion = helpers.getNotion(); | ||||
| module.exports = async function ({ overwrite_asar, delete_data } = {}) { | ||||
| module.exports = async function ({ | ||||
|   overwrite_asar, | ||||
|   delete_data, | ||||
|   friendly_errors, | ||||
| } = {}) { | ||||
|   try { | ||||
|     const file_operations = []; | ||||
| 
 | ||||
| @ -27,7 +31,7 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) { | ||||
|     const app_folder = path.resolve(`${__notion}/app`); | ||||
|     if (await fs.pathExists(app_folder)) { | ||||
|       console.info(` ...removing folder ${app_folder}`); | ||||
|       file_operations.push(fs.remove(app_folder)); | ||||
|       await fs.remove(app_folder); | ||||
|     } else console.warn(` * ${app_folder} not found: step skipped.`); | ||||
| 
 | ||||
|     // restoring original asar
 | ||||
| @ -55,13 +59,11 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) { | ||||
|         ); | ||||
|       } | ||||
| 
 | ||||
|       file_operations.push( | ||||
|         overwrite_asar || overwrite_asar === undefined | ||||
|           ? fs.move(asar_bak, path.resolve(`${__notion}/app.asar`), { | ||||
|               overwrite: true, | ||||
|             }) | ||||
|           : fs.remove(asar_bak) | ||||
|       ); | ||||
|       await (overwrite_asar || overwrite_asar === undefined | ||||
|         ? fs.move(asar_bak, path.resolve(`${__notion}/app.asar`), { | ||||
|             overwrite: true, | ||||
|           }) | ||||
|         : fs.remove(asar_bak)); | ||||
|     } else console.warn(` * ${asar_bak} not found: step skipped.`); | ||||
| 
 | ||||
|     // cleaning data folder: ~/.notion-enhancer
 | ||||
| @ -83,12 +85,10 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) { | ||||
|           : ` -- keeping ${helpers.data_folder}` | ||||
|       ); | ||||
|       if (delete_data) { | ||||
|         file_operations.push(fs.remove(helpers.data_folder)); | ||||
|         await fs.remove(helpers.data_folder); | ||||
|       } else fs.remove(path.resolve(`${helpers.data_folder}/version.txt`)); | ||||
|     } else console.warn(` * ${helpers.data_folder} not found: step skipped.`); | ||||
| 
 | ||||
|     await Promise.all(file_operations); | ||||
| 
 | ||||
|     // patching launch script target of custom wrappers
 | ||||
|     if ( | ||||
|       [ | ||||
| @ -119,7 +119,13 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) { | ||||
|     return true; | ||||
|   } catch (err) { | ||||
|     console.error('### ERROR ###'); | ||||
|     console.error(err); | ||||
|     if (err.toString().includes('EACCESS') && friendly_errors) { | ||||
|       console.error( | ||||
|         'file access forbidden: try again with sudo or in an elevated/admin prompt.' | ||||
|       ); | ||||
|     } else if (err.toString().includes('EIO') && friendly_errors) { | ||||
|       console.error('file access failed: is notion running?'); | ||||
|     } else console.error(err); | ||||
|     return false; | ||||
|   } | ||||
| }; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user