mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-04 04:39:03 +00:00
-n cli option, safer handling of application/removal file manipulation
This commit is contained in:
parent
c2a0b8e857
commit
84e895dccc
@ -22,8 +22,10 @@ a flexibility update.
|
||||
- new: css variables for increasing line spacing/paragraph margins.
|
||||
- new: patch the notion:// url scheme/protocol to work on linux.
|
||||
- new: menu shows theme conflicts + a core mod option to auto-resolve theme conflicts.
|
||||
- new: a `-n` cli option.
|
||||
- improved: menu will now respect integrated titlebar setting.
|
||||
- improved: use keyup listeners instead of a globalShortcut for the enhancements menu toggle.
|
||||
- improved: overwrite `app.asar.bak` if already exists (e.g. for app updates).
|
||||
- bugfix: removed messenger emoji set as the provider no longer supports it.
|
||||
- bugfix: remove shadow around light mode board headers
|
||||
\+ minor text colour fixes for night shift theming.
|
||||
@ -58,8 +60,6 @@ a fork of notion-deb-builder that does generate an app.asar has been created and
|
||||
- bugfix: night shift working on macOS.
|
||||
- bugfix: windows are properly hidden/shown on macOS.
|
||||
- extension: "tweaks" = common style/layout changes.
|
||||
- new: a `-n` cli option.
|
||||
- improved: overwrite `app.asar.bak` if already exists.
|
||||
- improved: additionally menu item descriptions on hover.
|
||||
|
||||
### v0.9.1 (2020-09-26)
|
||||
|
@ -91,6 +91,7 @@ For more info, run any command with the `--help` flag:
|
||||
|
||||
Options:
|
||||
-y, --yes : skip prompts (may overwrite data)
|
||||
-n, --no : skip prompts (may cause failures)
|
||||
-d, --dev : show detailed error messages (not recommended)
|
||||
-h, --help : display usage information
|
||||
-v, --version : display version number
|
||||
|
6
bin.js
6
bin.js
@ -20,6 +20,7 @@ const cli = require('cac')('notion-enhancer'),
|
||||
// ### error ###
|
||||
|
||||
cli.option('-y, --yes', ': skip prompts (may overwrite data)');
|
||||
cli.option('-n, --no', ': skip prompts (may cause failures)');
|
||||
cli.option('-d, --dev', ': show detailed error messages');
|
||||
|
||||
cli
|
||||
@ -27,7 +28,7 @@ cli
|
||||
.action(async (options) => {
|
||||
console.info('=== NOTION ENHANCEMENT LOG ===');
|
||||
await require('./pkg/apply.js')({
|
||||
overwrite_version: options.yes,
|
||||
overwrite_version: options.yes ? 'y' : options.no ? 'n' : undefined,
|
||||
friendly_errors: !options.dev,
|
||||
});
|
||||
console.info('=== END OF LOG ===');
|
||||
@ -37,8 +38,7 @@ cli
|
||||
.action(async (options) => {
|
||||
console.info('=== NOTION RESTORATION LOG ===');
|
||||
await require('./pkg/remove.js')({
|
||||
overwrite_asar: options.yes,
|
||||
delete_data: options.yes,
|
||||
delete_data: options.yes ? 'y' : options.no ? 'n' : undefined,
|
||||
friendly_errors: !options.dev,
|
||||
});
|
||||
console.info('=== END OF LOG ===');
|
||||
|
198
package-lock.json
generated
198
package-lock.json
generated
@ -1,198 +0,0 @@
|
||||
{
|
||||
"name": "notion-enhancer",
|
||||
"version": "0.9.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@jsdevtools/file-path-filter": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@jsdevtools/file-path-filter/-/file-path-filter-3.0.2.tgz",
|
||||
"integrity": "sha512-+SbZG6stIE/nRF2PpRnubtuzhh4pouDsk/hEWwM5mKsSKlFfr4ziAE5VMogGG/K++i9NHbUTxxW0y4vdM678ew==",
|
||||
"requires": {
|
||||
"glob-to-regexp": "^0.4.1"
|
||||
}
|
||||
},
|
||||
"@jsdevtools/readdir-enhanced": {
|
||||
"version": "6.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@jsdevtools/readdir-enhanced/-/readdir-enhanced-6.0.4.tgz",
|
||||
"integrity": "sha512-I6D6Omu6C7XWHzvlVbXeCS0FSxYYQ13XzdrFuo1K30unnRSpdt9AxY2KyJZbYJyfI2uNNidqDkG9/K/y699AjA==",
|
||||
"requires": {
|
||||
"@jsdevtools/file-path-filter": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"@types/glob": {
|
||||
"version": "7.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz",
|
||||
"integrity": "sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w==",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"@types/minimatch": "*",
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/minimatch": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
|
||||
"optional": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.11.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz",
|
||||
"integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==",
|
||||
"optional": true
|
||||
},
|
||||
"asar": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/asar/-/asar-3.0.3.tgz",
|
||||
"integrity": "sha512-k7zd+KoR+n8pl71PvgElcoKHrVNiSXtw7odKbyNpmgKe7EGRF9Pnu3uLOukD37EvavKwVFxOUpqXTIZC5B5Pmw==",
|
||||
"requires": {
|
||||
"@types/glob": "^7.1.1",
|
||||
"chromium-pickle-js": "^0.2.0",
|
||||
"commander": "^5.0.0",
|
||||
"glob": "^7.1.6",
|
||||
"minimatch": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"at-least-node": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
|
||||
"integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg=="
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"cac": {
|
||||
"version": "6.6.1",
|
||||
"resolved": "https://registry.npmjs.org/cac/-/cac-6.6.1.tgz",
|
||||
"integrity": "sha512-uhki4T3Ax68hw7Dufi0bATVAF8ayBSwOKUEJHjObPrUN4tlQ8Lf7oljpTje/mArLxYN0D743c2zJt4C1bVTCqg=="
|
||||
},
|
||||
"chromium-pickle-js": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
|
||||
"integrity": "sha1-BKEGZywYsIWrd02YPfo+oTjyIgU="
|
||||
},
|
||||
"commander": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz",
|
||||
"integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg=="
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz",
|
||||
"integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==",
|
||||
"requires": {
|
||||
"at-least-node": "^1.0.0",
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"glob-to-regexp": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz",
|
||||
"integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw=="
|
||||
},
|
||||
"graceful-fs": {
|
||||
"version": "4.2.4",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
|
||||
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw=="
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz",
|
||||
"integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6",
|
||||
"universalify": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"readdir-enhanced": {
|
||||
"version": "6.0.4",
|
||||
"resolved": "https://registry.npmjs.org/readdir-enhanced/-/readdir-enhanced-6.0.4.tgz",
|
||||
"integrity": "sha512-MWY048D/nEpHwqdnsBiUxpqjJPkEw2i2RmY5gM2Gadn0rkHS/DhUBqrYTkOqKHF4RoUlYZZ8GnP4ymlRGuo30A==",
|
||||
"requires": {
|
||||
"@jsdevtools/readdir-enhanced": "6.0.4"
|
||||
}
|
||||
},
|
||||
"universalify": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz",
|
||||
"integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug=="
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
}
|
||||
}
|
||||
}
|
37
pkg/apply.js
37
pkg/apply.js
@ -31,31 +31,40 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
||||
return true;
|
||||
case 2:
|
||||
console.warn(` * ${check_app.msg}`);
|
||||
do {
|
||||
const valid = () =>
|
||||
typeof overwrite_version === 'string' &&
|
||||
['y', 'n', ''].includes(overwrite_version.toLowerCase());
|
||||
if (valid()) {
|
||||
console.info(
|
||||
` > overwrite? [Y/n]: ${overwrite_version.toLowerCase()}`
|
||||
);
|
||||
}
|
||||
while (!valid()) {
|
||||
process.stdout.write(' > overwrite? [Y/n]: ');
|
||||
overwrite_version = await helpers.readline();
|
||||
} while (
|
||||
overwrite_version &&
|
||||
!['y', 'n'].includes(overwrite_version.toLowerCase())
|
||||
);
|
||||
overwrite_version =
|
||||
!overwrite_version || overwrite_version.toLowerCase() === 'y';
|
||||
if (!overwrite_version) {
|
||||
}
|
||||
if (overwrite_version.toLowerCase() === 'n') {
|
||||
console.info(' ~~ keeping previous version: exiting.');
|
||||
return false;
|
||||
}
|
||||
console.info(
|
||||
' -- removing previous enhancements before applying new version.'
|
||||
);
|
||||
await require('./remove.js')({
|
||||
overwrite_asar: true,
|
||||
delete_data: false,
|
||||
});
|
||||
if (
|
||||
!(await require('./remove.js')({
|
||||
delete_data: 'n',
|
||||
friendly_errors,
|
||||
}))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
console.info(' ...unpacking app.asar.');
|
||||
const asar_app = path.resolve(`${helpers.__notion}/app.asar`);
|
||||
const asar_app = path.resolve(`${helpers.__notion}/app.asar`),
|
||||
asar_bak = path.resolve(`${helpers.__notion}/app.asar.bak`);
|
||||
extractAll(asar_app, `${path.resolve(`${helpers.__notion}/app`)}`);
|
||||
await fs.move(asar_app, path.resolve(`${helpers.__notion}/app.asar.bak`));
|
||||
if (await fs.pathExists(asar_bak)) fs.remove(asar_bak);
|
||||
await fs.move(asar_app, asar_bak);
|
||||
|
||||
// patching launch script target of custom wrappers
|
||||
if (
|
||||
|
@ -108,19 +108,23 @@ example usage:
|
||||
```js
|
||||
console.warn(' * conflicting file found.');
|
||||
let overwrite;
|
||||
do {
|
||||
while (
|
||||
typeof overwrite !== 'string' ||
|
||||
!['y', 'n', ''].includes(overwrite.toLowerCase())
|
||||
) {
|
||||
// using stdout.write means that there is no newline
|
||||
// between prompt and input.
|
||||
process.stdout.write(' > overwrite? [Y/n]: ');
|
||||
overwrite = await helpers.readline();
|
||||
process.stdout.write(' > delete? [Y/n]: ');
|
||||
// ask for a Y/n until a valid answer is received.
|
||||
// pressing enter without input is assumed to be a "yes".
|
||||
} while (overwrite && !['y', 'n'].includes(overwrite.toLowerCase()));
|
||||
overwrite = !overwrite || overwrite.toLowerCase() === 'y';
|
||||
if (overwrite) {
|
||||
console.info(' -- overwriting file.');
|
||||
overwrite = await helpers.readline();
|
||||
}
|
||||
if (overwrite.toLowerCase() === 'n') {
|
||||
console.info(' -- keeping file: skipping step.');
|
||||
} else {
|
||||
// do stuff
|
||||
} else console.info(' -- keeping file: skipping step.');
|
||||
console.info(' -- overwriting file.');
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
@ -18,11 +18,7 @@ const fs = require('fs-extra'),
|
||||
// ~~ exit
|
||||
// ### error ###
|
||||
|
||||
module.exports = async function ({
|
||||
overwrite_asar,
|
||||
delete_data,
|
||||
friendly_errors,
|
||||
} = {}) {
|
||||
module.exports = async function ({ delete_data, friendly_errors } = {}) {
|
||||
try {
|
||||
// extracted asar: modded
|
||||
const app_folder = path.resolve(`${helpers.__notion}/app`);
|
||||
@ -38,50 +34,30 @@ module.exports = async function ({
|
||||
|
||||
if (await fs.pathExists(path.resolve(`${helpers.__notion}/app.asar`))) {
|
||||
console.warn(' * app.asar already exists!');
|
||||
if (overwrite_asar === undefined) {
|
||||
do {
|
||||
process.stdout.write(' > overwrite? [Y/n]: ');
|
||||
overwrite_asar = await helpers.readline();
|
||||
} while (
|
||||
overwrite_asar &&
|
||||
!['y', 'n'].includes(overwrite_asar.toLowerCase())
|
||||
);
|
||||
overwrite_asar =
|
||||
!overwrite_asar || overwrite_asar.toLowerCase() === 'y';
|
||||
}
|
||||
console.info(
|
||||
overwrite_asar
|
||||
? ' -- overwriting app.asar with app.asar.bak'
|
||||
: ' -- removing app.asar.bak'
|
||||
);
|
||||
}
|
||||
|
||||
await (overwrite_asar || overwrite_asar === undefined
|
||||
? fs.move(asar_bak, path.resolve(`${helpers.__notion}/app.asar`), {
|
||||
overwrite: true,
|
||||
})
|
||||
: fs.remove(asar_bak));
|
||||
console.info(' -- removing app.asar.bak');
|
||||
fs.remove(asar_bak);
|
||||
} else
|
||||
await fs.move(asar_bak, path.resolve(`${helpers.__notion}/app.asar`));
|
||||
} else console.warn(` * ${asar_bak} not found: step skipped.`);
|
||||
|
||||
// cleaning data folder: ~/.notion-enhancer
|
||||
if (await fs.pathExists(helpers.__data)) {
|
||||
console.info(` ...data folder ${helpers.__data} found.`);
|
||||
if (delete_data === undefined) {
|
||||
do {
|
||||
process.stdout.write(' > delete? [Y/n]: ');
|
||||
delete_data = await helpers.readline();
|
||||
} while (
|
||||
delete_data &&
|
||||
!['y', 'n'].includes(delete_data.toLowerCase())
|
||||
);
|
||||
delete_data = !delete_data || delete_data.toLowerCase() === 'y';
|
||||
const valid = () =>
|
||||
typeof delete_data === 'string' &&
|
||||
['y', 'n', ''].includes(delete_data.toLowerCase());
|
||||
if (valid())
|
||||
console.info(` > delete? [Y/n]: ${delete_data.toLowerCase()}`);
|
||||
while (!valid()) {
|
||||
process.stdout.write(' > delete? [Y/n]: ');
|
||||
delete_data = await helpers.readline();
|
||||
}
|
||||
console.info(
|
||||
delete_data
|
||||
? ` -- deleting ${helpers.__data}`
|
||||
: ` -- keeping ${helpers.__data}`
|
||||
delete_data.toLowerCase() === 'n'
|
||||
? ` -- keeping ${helpers.__data}`
|
||||
: ` -- deleting ${helpers.__data}`
|
||||
);
|
||||
if (delete_data) await fs.remove(helpers.__data);
|
||||
if (delete_data.toLowerCase() !== 'n') await fs.remove(helpers.__data);
|
||||
} else console.warn(` * ${helpers.__data} not found: step skipped.`);
|
||||
|
||||
// patching launch script target of custom wrappers
|
||||
|
Loading…
Reference in New Issue
Block a user