better erroring (#56), menu tweaking, gallery fullpage variable fix

This commit is contained in:
dragonwocky 2020-08-29 00:14:29 +10:00
parent ab7771cba9
commit 017cb66564
Signed by: dragonwocky
GPG Key ID: C7A48B7846AA706D
9 changed files with 50 additions and 32 deletions

View File

@ -34,7 +34,10 @@ otherwise:
the enhancements should be automatically applied on installation the enhancements should be automatically applied on installation
and automatically removed on uninstallation. 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: Usage:
@ -52,6 +55,7 @@ For more info, run any command with the `--help` flag:
Options: Options:
-y, --yes : skip prompts (may overwrite data) -y, --yes : skip prompts (may overwrite data)
-d, --dev : show detailed error messages (not recommended)
-h, --help : display usage information -h, --help : display usage information
-v, --version : display version number -v, --version : display version number
``` ```
@ -231,7 +235,7 @@ these include:
**author:** [alexander-kazakov](https://github.com/alexander-kazakov/) **author:** [alexander-kazakov](https://github.com/alexander-kazakov/)
**version:** v0.2.1 **version:** v0.2.2
### right-to-left ### right-to-left

19
bin.js
View File

@ -20,26 +20,27 @@ const cli = require('cac')('notion-enhancer'),
// ### error ### // ### error ###
cli.option('-y, --yes', ': skip prompts (may overwrite data)'); cli.option('-y, --yes', ': skip prompts (may overwrite data)');
cli.option('-d, --dev', ': show detailed error messages');
cli cli
.command('apply', ': add the enhancer to the notion app') .command('apply', ': add the enhancer to the notion app')
.action(async (options) => { .action(async (options) => {
console.info('=== NOTION ENHANCEMENT LOG ==='); 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 ==='); console.info('=== END OF LOG ===');
}); });
cli cli
.command('remove', ': return notion to its pre-enhanced/pre-modded state') .command('remove', ': return notion to its pre-enhanced/pre-modded state')
.action(async (options) => { .action(async (options) => {
console.info('=== NOTION RESTORATION LOG ==='); console.info('=== NOTION RESTORATION LOG ===');
await require('./pkg/remove.js')( await require('./pkg/remove.js')({
options.yes overwrite_asar: options.yes,
? { delete_data: options.yes,
overwrite_asar: true, friendly_errors: !options.dev,
delete_data: true, });
}
: {}
);
console.info('=== END OF LOG ==='); console.info('=== END OF LOG ===');
}); });
cli cli

View File

@ -46,7 +46,6 @@
background: var(--theme--card) !important; background: var(--theme--card) !important;
} }
.dark .dark
.notion-page-content
.notion-page-block.notion-collection-item .notion-page-block.notion-collection-item
[style*='background: rgba(255, 255, 255, 0.05)'] { [style*='background: rgba(255, 255, 255, 0.05)'] {
background: var(--theme--gallery) !important; background: var(--theme--gallery) !important;

View File

@ -56,7 +56,6 @@
background: var(--theme--card) !important; background: var(--theme--card) !important;
} }
.notion-body:not(.dark) .notion-body:not(.dark)
.notion-page-content
.notion-page-block.notion-collection-item .notion-page-block.notion-collection-item
[style*='background: rgba(55, 53, 47, 0.024)'] { [style*='background: rgba(55, 53, 47, 0.024)'] {
background: var(--theme--gallery) !important; background: var(--theme--gallery) !important;

View File

@ -158,6 +158,11 @@ s {
background: var(--theme--bg_green); background: var(--theme--bg_green);
} }
#alerts code {
background: transparent;
text-decoration: underline;
}
[data-relaunch] { [data-relaunch] {
text-decoration: underline dotted; text-decoration: underline dotted;
cursor: pointer; cursor: pointer;

View File

@ -107,9 +107,7 @@ window['__start'] = async () => {
'warning', 'warning',
version.sorted[0] == version.local version.sorted[0] == version.local
? `update <b>v${version.repo}</b> available!<br> ? `update <b>v${version.repo}</b> available!<br>
run <code>npm i -g notion-enhancer</code><br> run <code>npm i -g notion-enhancer</code>`
(or <code>yarn global add notion-enhancer</code>),<br>
<u>and</u> <code>notion-enhancer apply</code>.`
: `local build <b>v${raw_v}</b> is unstable.` : `local build <b>v${raw_v}</b> is unstable.`
).prepend(); ).prepend();
}); });

View File

@ -12,7 +12,7 @@ module.exports = {
tags: ['extension'], tags: ['extension'],
name: 'property layout', name: 'property layout',
desc: 'auto-collapse page properties that usually push down page content.', desc: 'auto-collapse page properties that usually push down page content.',
version: '0.2.1', version: '0.2.2',
author: 'alexander-kazakov', author: 'alexander-kazakov',
hacks: { hacks: {
'renderer/preload.js'(store, __exports) { 'renderer/preload.js'(store, __exports) {

View File

@ -22,7 +22,7 @@ const fs = require('fs-extra'),
// ### error ### // ### error ###
let __notion = helpers.getNotion(); let __notion = helpers.getNotion();
module.exports = async function ({ overwrite_version } = {}) { module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
try { try {
await fs.ensureDir(helpers.data_folder); await fs.ensureDir(helpers.data_folder);
@ -114,7 +114,13 @@ module.exports = async function ({ overwrite_version } = {}) {
return true; return true;
} catch (err) { } catch (err) {
console.error('### ERROR ###'); 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; return false;
} }
}; };

View File

@ -19,7 +19,11 @@ const fs = require('fs-extra'),
// ### error ### // ### error ###
let __notion = helpers.getNotion(); let __notion = helpers.getNotion();
module.exports = async function ({ overwrite_asar, delete_data } = {}) { module.exports = async function ({
overwrite_asar,
delete_data,
friendly_errors,
} = {}) {
try { try {
const file_operations = []; const file_operations = [];
@ -27,7 +31,7 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) {
const app_folder = path.resolve(`${__notion}/app`); const app_folder = path.resolve(`${__notion}/app`);
if (await fs.pathExists(app_folder)) { if (await fs.pathExists(app_folder)) {
console.info(` ...removing folder ${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.`); } else console.warn(` * ${app_folder} not found: step skipped.`);
// restoring original asar // restoring original asar
@ -55,13 +59,11 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) {
); );
} }
file_operations.push( await (overwrite_asar || overwrite_asar === undefined
overwrite_asar || overwrite_asar === undefined ? fs.move(asar_bak, path.resolve(`${__notion}/app.asar`), {
? fs.move(asar_bak, path.resolve(`${__notion}/app.asar`), { overwrite: true,
overwrite: true, })
}) : fs.remove(asar_bak));
: fs.remove(asar_bak)
);
} else console.warn(` * ${asar_bak} not found: step skipped.`); } else console.warn(` * ${asar_bak} not found: step skipped.`);
// cleaning data folder: ~/.notion-enhancer // cleaning data folder: ~/.notion-enhancer
@ -83,12 +85,10 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) {
: ` -- keeping ${helpers.data_folder}` : ` -- keeping ${helpers.data_folder}`
); );
if (delete_data) { 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 fs.remove(path.resolve(`${helpers.data_folder}/version.txt`));
} else console.warn(` * ${helpers.data_folder} not found: step skipped.`); } else console.warn(` * ${helpers.data_folder} not found: step skipped.`);
await Promise.all(file_operations);
// patching launch script target of custom wrappers // patching launch script target of custom wrappers
if ( if (
[ [
@ -119,7 +119,13 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) {
return true; return true;
} catch (err) { } catch (err) {
console.error('### ERROR ###'); 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; return false;
} }
}; };